Posts

Showing posts from 2011

ip - How to transmit a file larger than 65,536 bytes using IPv4 -

i wanted know if there way send larger files 65,536 bytes using ipv4 you shouldn't using raw ip. there's reason implementation of tcp/ip typically called "stack". communication typically done layering protocols on top of each other. each layer takes layer below it, , either abstracts away aspect of lower-level protocol or adds useful functionality. a web server, example, ends using several layers of protocols: ethernet, wifi, or other such protocols, provides physical (or radio) connection , signaling rules enable machines talk each other @ all. ip, adds concept of routing , globally available addresses. tcp, adds concept of "ports", allows several apps use same ip address @ same time without stepping on each other's toes; abstracts discrete packets of ip full-duplex, arbitrary-length stream of bytes; and adds detection , correction of errors , lost/duplicate data. ssl and/or tls (sometimes), adds semi-transparent encryption

php - how to extend the get() method in eloquent -

how extend method get() in eloquent class, add code join whenever called. whenever method all() , find or get() called, add join: static::join('clientes', 'clientes.id', '=', 'faturas.cliente_id'); thanks have tried eager loading ? can set protected $with = array('clients'); in model. you overload newquery method extending model class. class basemodel extends model { public function newquery($excludedeleted = true) { $builder = parent::newquery($excludedeleted); $builder->join('clientes', 'clientes.id', '=', 'faturas.cliente_id'); return $builder; } }

Sign up counter - PHP? -

i looking find out how http://getfixedapp.com/ able show amount of users signed above sign link. used developer tools try see used. help? would easy php. on backend, increment variable each time signs up, , store variable inside database. you not able see using developer tools : php executed on server side , invisible on front end.

sql server - what are rdbms access methods and can I use thrift with rdbms? -

i reading professional nosql book,and there list of different nosql db access methods,but dont know access method in rdbms? odbc/jdbc , drivers counted access methods? or ado.net,linq sql,entity frame work,are counted access methods? what difference between ado.net/linq sql/entity frame work , odbc/jdbc,i mean both used access databases,so how differ? and other question why cant thrift/avro/rest/protobuf used rdbms,they services,why used nosql dbs? sounds pretty other question, @ least 75% of :-) what difference between ado.net/linq sql/entity frame work , odbc/jdbc, mean both used access databases,so how differ? they differ in several ways. first, dbms typically support few ways how connect them. less, more, heavily depends on dbms. next, of methods listed, linq, not available in environments. example, take arbitrary programming language not based on .net technology, , linq no longer option. and other question why cant thrift/avro/rest/protobuf used rdb

javascript - Saving and printing a google chart -

i have been trying save and/or print google chart no luck. have tried has been suggested https://gist.github.com/battlehorse/1333906 , can google visualization: pie chart output png image? cant seem working. copied , pasted code notepad , saved .html , opened firefox. when click save button, download box appears not recognise png , not download anything. anyone have ideas wrong it? thanks the download never recognized png - had rename manually. tested nverba fork of code, updates code reflect improvements in visualization api, , functions in chrome not firefox. since code used work in firefox, assume either update firefox or canvg library broke functionality in firefox (there's nothing specific in visualization api cause functionality in firefox break). since highly browser-specific tool anyway, recommend using chrome handle chart-to-image conversion.

How to generate event handlers with loop in Javascript? -

this question has answer here: javascript infamous loop issue? [duplicate] 5 answers for example, have 10 tags generated ajax response: <a href="#" id="b1">b1</a> <a href="#" id="b2">b2</a> <a href="#" id="b3">b3</a> <a href="#" id="b4">b4</a> <a href="#" id="b5">b5</a> <a href="#" id="b6">b6</a> <a href="#" id="b7">b7</a> <a href="#" id="b8">b8</a> <a href="#" id="b9">b9</a> <a href="#" id="b10">b10</a> i need assign onclick event each of them via loop: for(i=1; i<11; i++) { document.getelementbyid("b"+i).onclick=function() {

perl - How to run test in xt at once? -

is possible run tests in xt directory @ once command line? the prove tool has many options can tweak. useful invocation prove -l -r xt , includes lib/ folder in @inc , recurses subdirectories, , starts in xt folder. run test in directory structure like lib/ foo.pm xt/ 000-start.t 001-sometests/ 001-foo.t 002-bar.t

java - Call to get XML element returns null -

i have series of xml files looking through , grabbing specific element from. <key>a</key> i'm using snippet of code grab xml element, returns null instead of element looking for. not able change xml files. file key = new file(filepath); printwriter keywriter = new printwriter(key); file xmlfile = new file(configpath); documentbuilderfactory documentbuilderfactory = documentbuilderfactory.newinstance(); documentbuilder documentbuilder = documentbuilderfactory.newdocumentbuilder(); document document = documentbuilder.parse(xmlfile); nodelist nodes = document.getelementsbytagname("key"); element keyvalue = (element) nodes.item(0); keywriter.println(keyvalue); keywriter.close(); } i've tried using document method apache xmlconfiguration , getelementbyid have returned null far. i noticed in code passing element object writer's println function in: keywriter.println(keyvalue); this pr

starting an android native service with titanium module -

i started mobile module project following service class: package com.eliddell.testservice; import java.lang.reflect.method; import java.util.arraylist; import java.util.list; import java.util.timer; import java.util.timertask; import org.appcelerator.titanium.tibaseservice; import org.appcelerator.kroll.common.log; import android.app.activitymanager; import android.app.service; import android.app.activitymanager.runningserviceinfo; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; import android.graphics.pixelformat; import android.net.wifi.wifimanager; import android.os.batterymanager; import android.os.handler; import android.os.ibinder; import android.text.format.time; import android.view.gravity; import android.view.view; import android.view.windowmanager; import android.widget.relativelayout; import android.widget.textview; public class foregroundservice extends service { /* (non-javadoc) * @see an

asp.net mvc 4 - App Pool on IIS gets Hanged sporadically and we see white page on MVC Application -

we having mvc4 application on iis 8. application had dedicate app pool. app pool gets hanged sporadically , solution application , running doing iis reset. after iis reset, starts working normally. when eventviewer, see message "a worker process '' serving application pool 'xxx' failed stop listener channel protocol 'http' in allotted time. data field contains error number." this issue occurs in our customer site , works fine in our environment. i looked iis logs , not give information. any highly appreciated. for me, works manually recycle app pool in same situation. have issue iis on 2012r2. don't have clue why hangs, maybe ef or ormlite db framework deadlocks or such..

actionscript 3 - Targeting Colors from an Array -

in project want color choose tracked box. problem code track 1 of colors if there 2 of same colors on stage. if can me out thank every much. main.as package { import flash.display.sprite; import flash.events.event; import flash.geom.point; [swf(framerate='31', width='1000', height='500')] public class main extends sprite { private var balls:array; private var directions:array = [new point(-1,-1),new point(0,-1),new point(1,-1), new point(-1,0),new point(1,0), new point(-1,1),new point(0,1),new point(1,1) ]; private var ballnum: number = 10; private var ball:ball; private var box:box; /*private var padding:number = 20; private var ay:number = 5; private var gravity:number = 6; private var bounce:number = -0.9; */ public function main()

java - Using Groovy in POM file for delimiter switching works differently for different developers -

we using small segment of groovy code within our pom file replace backslash delimiters in main base directory forward slash delimiters. more information on this, see post: how convert file separator in maven however, problem have suggested groovy link works fine on 1 developers machine, not on another. what works first developer this: (the code mentioned in linked post) pom.properties['main.basedir']=project.basedir.absolutepath.replace('\\','/'); what works other developer following: pom.properties['main.basedir']=project.basedir.absolutepath.replace('\','/'); (note single backslash) the errors second developer sees when using double backslash are: [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 1:15.096s [info] finished at: tue sep 03 16:54:18 bst 2013 [info] final memory: 36m/298m [info] ----------------------------------------------------------

javascript - Google Apps Script formatDate using user's time zone instead of GMT -

i have line sets current date , time in cell: sheet.getrange(1,1).setvalue(new date()); then have line creates formatted date based on cell's value: var addeddate = sheet.getrange(1,1).getvalue(); var addedtime = utilities.formatdate(addeddate, "gmt", "hh:mm a"); the resulting addedtime seems in gmt time zone , need in user's time zone. eastern time (-0500), if subtract 5 hours time doesn't account daylight saving time (-0400). i checked documentation formatdate here: https://developers.google.com/apps-script/reference/utilities/utilities#formatdate(date,string,string) which links official java simpledateformat class documentation here: http://docs.oracle.com/javase/6/docs/api/java/text/simpledateformat.html ... can't find list of valid time zones there replace gmt with. you can directly spreadsheet time zone : var addeddate = sheet.getrange(1,1).getvalue(); var addedtime = utilities.formatdate(addeddate, spreadshee

r - fread (data.table) locks files -

Image
i have used fread data.table package , when try modify or delete file (just open notepad) windows says: how can unlock binding? edit: trying in r gives same cat(file="c:/users/mcarrie/desktop/test/test2.txt") error in file(file, ifelse(append, "a", "w")) : cannot open connection in addition: warning message: in file(file, ifelse(append, "a", "w")) : cannot open file 'c:/users/mcarrie/desktop/test/test2.txt': permission denied info: > sessioninfo() r version 3.0.1 (2013-05-16) platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] lc_collate=english_united kingdom.1252 lc_ctype=english_united kingdom.1252 [3] lc_monetary=english_united kingdom.1252 lc_numeric=c [5] lc_time=english_united kingdom.1252 attached base packages: [1] stats graphics grdevices utils datasets methods base other attached packages: [1] data.table_1.8.8 loaded via namespace (a

wordpress - Php error "Undefined variable:post" when using "get_post_thumbnail_id($post->ID)" -

i have line of php thumbnail image in custom wordpress widget: $footer_recent_thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->id), 'footer-recent-thumbnail' ); it produces 2 php errors: notice: customwidgets.php:75 - undefined variable: post notice: customwidgets.php:75 - trying property of non-object how can resolve this? same php use thumbnail on blog , doesn't give error there. my guess code in function, so: function dosomething($someparams) { // ... $fotoer_recent_thumb = // ..... // ... } in case, $post not exist in scope, , must imported adding following line inside function: global $post; alternatively, , more cleanly, pass parameter.

ruby on rails - Equivilent to where() on a Associations::CollectionProxy -

how go having condition in association? since it's returning collectionproxy there's barely information, in docs, it. can't figure out do, why wouldn't work? @new_notifications = self.notifications.where({:seen => false}) figured out! reason, passing hash statement problem. works: @notifs = self.notifications.where(seen = false) collectproxy subclass of relation means can expect. so, like: self.notifications.where(:seen => false) would work provided have has_many :notifications association on whatever self is.

Cannot set a variable in a batch file -

i have following... @echo off setlocal enabledelayedexpansion /f "skip=1" %%p in ('wmic cpu loadpercentage') @echo %%p echo ...this worked echo. pause /f "skip=1" %%p in ('wmic cpu loadpercentage') set cpu=%%p echo cpu %cpu% echo ...this did not work echo. pause how come can't set number in variable %cpu% it's blank! for /f "skip=1" %%p in ('wmic cpu loadpercentage') set cpu=%%p & goto :end_for :end_for wmic produces empty line @ end.you can try /format:csv @ end of wmic call prevent that. check this: http://www.dostips.com/forum/viewtopic.php?f=3&t=4266

mysql - alter table statment to insert duplicate into another table -

i have table in there column name sp varchar(10) not null . want column unique created unique index on column . table schema follows : create table if not exists `tblspmaster` ( `csn` bigint(20) not null auto_increment, `sp` varchar(10) not null, `fileimporteddate` date not null, `amzfilename` varchar(50) not null, `casperbatch` varchar(50) not null, `batchprocesseddate` date not null, `expirydate` date not null, `region` varchar(50) not null, `fccity` varchar(50) not null, `vendorid` int(11) not null, `locationid` int(11) not null, primary key (`csn`), unique key `sp` (`sp`) ) engine=innodb default charset=latin1 auto_increment=10000000000 ; now want if tries insert duplicate record record should inserted secondary table name tblduplicate . i have gone through question mysql - ignore insert error: duplicate entry not sure instead of insert tbl values (1,200) on duplicate key update value=200; can insert duplicate row table ? what changes nee

RavenDB Authorization Bundle proper user of SecureFor -

i attempting use ravendb's authorization bundle limit results of query (on workitems) permissions have been explicitly set on workitem documents. for example: i have user bob@bob.com userid of /users/1 , workitem has following permissions set in meta-data: "raven-document-authorization": { "tags": [], "permissions": [ { "operation": "/operations/workitem/search", "user": "users/1", "role": null, "allow": true, "priority": 1 } ] } i expect following code limit query (from bob's perspective) 1 workitem, because has permission to. using (var session = documentstore.opensession()) { session.securefor("raven/authorization/users/1", "/operations/workitem/search"); var workitemsquery = wi in session.query<workitem>() select wi; var debts = workitem

objective c - Auto-layout mangles the segues in the iPad version -

after number of tests found normal working ipad storyboard starts working weirdly upon introducing auto-layout. in particular seems not pop-up dismissed views recycling same view controller , badly handle queue of instantiated view controllers. when disable auto-layout works fine again. know if bug known apple or there fix? not been able complement question new information, posted new 1 at: triggering segues annotations

python - Creating a new thread that _really_ runs in parallel -

i have following code in class: def persistdbthread(self): while true: thread(target=self.__persistdb) time.sleep(10) def __persistdb(self): open(self.authdbpath, 'w') outfile: json.dump(self.authdb, outfile) the thread gets started in __ main__ start thread blocking in main execution. why this? know gil - it's in same process. task switching happens in same process in micro-thread, why doesn't switch back? thanks! sorry asking: def persistdbthread(self): thread(target=self.__persistdb).start() def __persistdb(self): while true: time.sleep(10) outfile = open(self.authdbpath, 'w') json.dump(self.authdb, outfile) you calling __persistdb soon. use target=self.__persistdb no parentheses @ end. when include parentheses, calling function before threading call made. without parentheses, pass function argument called later. you need call resulting thread object's s

Use several textures with obj model in three.js -

how can use 2 textures obj model three.js? i'm following obj webgl_obj_loader example uses male02 obj file. want use 2 textures clothes , face, male-02-1noculling.jpg , orig_02_-_defaul1noculling.jpg. in example, loads single texture , sets obj children three.mesh instances - child.material.map = texture how can change use 2 textures? how three.js know texture use body , texture use face? there format encapsulates model , textures single call three.js render everything? have viewer can accept file exported 3d editor , display it. thanks

c++ - Developing a Chromecast Server -

i want develop chromecast server, written in c++ of nokia qt5 framework. ssdp , http working, can switch , play movies on youtube via android youtube app, chrome browser extension, android app "remotecast", chromecast setup tool windows , google music app on android can't find server. both of apps find server, device description xml content nothing happens. chrome browser extension gets application path ("/apps/chromecast"), returns desired json string response when asked - but, after that, remote url says should need receiver id. can me that? i need working device description , answers these questions: what uuid for, sent usn header , sent device description? must uuid different sent response headers , device description? what "dial" services in device description needed? -> both descriptions cheapcast , leapcast aren't working find virtual device thank me or trying things :) edit uuid's nonsense, seems there never used

c++ - Overload Resolution in a Namespace -

i attempting call overloaded function inside namespace , struggling bit. working example 1: no namespace class c {}; inline void overloaded(int) {} template<typename t> void try_it(t value) { overloaded(value); } inline void overloaded(c) {} int main() { try_it(1); c c; try_it(c); return 0; } working example 2: overloads defined before template class c {}; namespace n { inline void overloaded(int) {} inline void overloaded(c) {} } template<typename t> void try_it(t value) { n::overloaded(value); } int main() { try_it(1); c c; try_it(c); return 0; } broken example 3: overloads after template class c {}; namespace n { inline void overloaded(int) {} } template<typename t> void try_it(t value) { n::overloaded(value); } namespace n { inline void overloaded(c) {} } int main() { try_it(1); c c; try_it(c); // /tmp/test.cpp: in function ‘void try_it(t) [with t = c]’: // /tmp/test.cpp:19:15: instanti

c# - Implement a generic class where the definition is on a base interface type but the implementation is on an interface derived from that base? -

is possible in c# implement generic class definition on base interface type implementation on interface derived base? i have base type core functionality need 2 different variations on type depending on if process working data data or integer data. i kluge base type have both data types i'd rather not. example of problem: public interface ia {} public interface ib : ia {} public class ca : ia {} public class cb : ib {} public interface ic<t1> t1 : ia { } public class c<tia> : ic<tia> tia : ia {} public class thing { public void some() { ia = new cb(); // fine ib of type ia c<ib> b = new c<ib>(); // fine - c<ib> y = new c<ia>(); // shouldn't work - doesn't work c<ia> x = new c<ib>(); // though ib of type ia not acceptable } } cannot implicitly convert type 'classlibrary1.c<classlibrary1.ia>' 'classlibrary1.c<classlibrary1.ib>'

javascript - Is it possible for a mailto to be changed on the frontend with HTML? -

i don't think can done, have phonegap app main developer on. captures form details email, , submits them. is possible email address of mailto link changed without modifying code? e.g., mail settings page user enter email address put there, used in mailto. you can change mailto url javascript but have mail composer plugin send mails, it's better using mailto

order of evaluation - Explain if (++value % 2 == 0 && ++count < limit) in java -

public class andoperator { public static void main(string[] arg) { int value = 8; int count = 10; int limit = 11; if (++value % 2 == 0 && ++count < limit) { system.out.println("here"); system.out.println(value); system.out.println(count); } else{ system.out.println("there"); system.out.println(value); system.out.println(count); } } } i getting output there 9 10 explain how count 10....? && short-circuit operator . evaluate 2nd expression if 1st expression evaluates true. since ++value % 2 == 0 false, hence doesn't evaluate 2nd expression, , doesn't increment count .

c# - Iterate properties and nested first level properties -

i have following classes public class car { public int carid { get; set;} public string description { get; set;} public engine engine { get; set;} } public class engine { public int engineid { get; set;} public int description { get; set;} } now want iterate properties in car , properties in engine, dont want hardcode property names "car or engine" example properties of car, obj instance of car. var properties = obj.gettype().getproperties(bindingflags.flattenhierarchy | bindingflags.instance | bindingflags.public); but doesnt iterate properties of engine. flattenhierarchy not think does, , instead follows inheritance hiearchy static members. if you'd sub-properties objects, you'll need yourself: static ienumerable<propertyinfo> flattenproperties(type type) { // assumption #1: not want "simple" types enumerated if (!type.isclass) return enumerable.empty<propertyinfo>(); // ass

How to edit HTML formatted text programatically with javascript without dealing with tags and HTML manually -

i want able edit html formatted text if plain text without losing formatting. example let's have html: <div> <b> <span style="color: rgb(68, 68, 68);">gmail available <i>wherever</i> are, device - desktop, laptop, phone or tablet. download app or go to&nbsp;</span><a href="https://www.gmail.com/">gmail.com</a><span style="color: rgb(68, 68, 68); font-family: arial, sans-serif; line-height: 18.1875px;">&nbsp;on mobile device started. </span> </b> <br> </div> i able like: trimmed = gettexttoedit(); tokens = trimmed.split(' '); replacement = "+"; (var i=0; i<tokens.length; i++) { t = tokens[i].tolowercase(); if (t == "gmail") t = replacement; } and have t, still formatted. is there way can edit text without manually dealing html tags , still keeping formatting? ok using library this. thanks! i think need h

javascript - jQuery.find() a form into an element not working -

dynamically generate formular defined div-container , grab send-action sending ajax. the generate html: <div class="mhuntform"> <form action="/wp-admin/admin-ajax.php" method="post"> <h2>title</h2> <p>a text</p> <div id="form" style="padding: 5px 0px;"> <p> <label for="email" style="display: inline-block; margin-right: 10px;">e-mail</label> <input type="email" name="email" id="email" placeholder="e-mail" style="width: 60%;"> </p> <p> <button name="mhskl_send" id="mhskl_send">anmelden</button> </p> </div> </form> </div> the formular defined admin wordpress-page. in javascript (jquery) know classname of div-container (here .mhuntform). in javascript try catch event: // mhuntskl.options.container = '.mhuntform' $(mhunts

ruby on rails - Carrierwave uploads don't appear on POST -

i'm following railscast tutorial carrierwave uploads , , have same files set up. upload works fine if upload file via console, form doesn't seem post correctly. i've got basic form, includes: <%= f.label :receipt %><br> <%= f.file_field :receipt %> rails 4 automatically include enctype="multipart/form-data" tag on form. when submit form, take @ server logs. upload shows in parameters: "receipt"=>#<actiondispatch::http::uploadedfile:0x007fcb25c624e0 @tempfile=#<tempfile:/var/folders/ty/yks2xd9n76z9p49qzprvt1900000gn/t/rackmultipart20130903-53712-17zblz4>, @original_filename="avatar.jpg", @content_type="image/jpeg", @headers="content-disposition: form-data; name=\"expense[receipt]\"; filename=\"avatar.jpg\"\r\ncontent-type: image/jpeg\r\n">}, however, insert statement doesn't include mention of receipt field or file. there isn't error. file not up

Retrieving form data into a php processor -

i having problem understanding how make foreach function work. have form, uses check boxes. tried loading them array of check boxes, couldn't foreach function work me. don't understand of this. let me post form data real quick: <form method="post" action="interests.php" name="interests"> <table width="500" cellspacing="3" cellpadding="3" bgcolor="#ff80ff" bordercolor="#800000"> <tr> <td><input type="checkbox" name="check1" value="1"></td> <td><input type="checkbox" name="check2" value="2"></td> <td><input type="checkbox" name="check3" value="3"></td> <td><input type="checkbox" name="check4" value="4"></td> </tr> <tr> <td><input type="ch

google apps script - is it possible to use getRowsData without a range? -

i using google app scrips , want iterate through spreadsheet updated weekly. (this why dont want set range want able iterate through entire sheet.) is possible? if yes can give example of how done? and if isn't idea, why not? thank you! example code function doget(e){ var ss = spreadsheetapp.openbyid('key in here'); var sheet = ss.getsheetbyname("form responses"); var range = sheet.getrange(1,1); var datarange = range.getvalue().tostring(); app.add(app.createhtml("there " + datarange + " posts today")) return app; something this, want able see whole sheet not range henrique abreu , srik provided correct answer - getdatarange on sheet should serve purpose. function doget(e){ var sheet = spreadsheetapp.openbyid('spreadsheetid').getsheetbyname('sheetname'); var data = sheet.getdatarange().getvalues();; ... } data 2-dimensional array, can iterate through it, last column/row containing con

css - Change text-align responsively (with Bootstrap 3)? -

i'm using bootstrap 3 blog. in custom css, added body { text-align: justify; ... } i result on bigger screens (tablet, desktop). on small screens (phone), justified text doesn't work due narrower columns plus blog's occasional use of long-ish-technical-terms-like-this . can responsively have text-align: justify only on bigger screens? is possible solely via css, or, need write custom js so? yes, (where breakpoint set @ 48em): body{ text-align: left; } @media screen , (min-width: 48em){ body{ text-align: justify; } } the second rule override first if viewport width greater 48em.

python - Image Upload Django Admin -

i'm new django , need upload image through admin use on portfolio site making. using sorl-thumbnail have images show on front end, don't know how call them once uploaded or upload them to. here models.py : from django.db import models # create models here. class casestudy(models.model): title = models.charfield(max_length=150) description = models.textfield() picture = models.imagefield(upload_to="static") def __unicode__(self): return self.title #makes title link in admin and here example how use sorl-thumbnail in template: {% thumbnail item.image "100x700" im %} <img style="margin:{{ im|margin:"100x700" }}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}"> {% endthumbnail %} any appreciated because django noob. upload them media, setup media serving ( https://docs.djangoproject.com/en/dev/howto/static-files/#serving-files-uploaded-by-a-user-d

objective c - Clear NSTableView Content -

i have nstableview gets filled data program. have reset button that, amongst uses other parts of program, should clear nstableview 's data. however, have absolutely no idea how this. i'm still learning obj-c. you can remove objects 1 one nstableview calling removerowsatindexes: ( documentation here ) , calling reloaddata on nstableview. if want clear of data, you'll need clear datasource (usually nsarray provide table data) , call reloaddata . clear datasource, if nsdictionary or nsarray, call removeallobjects on nsdictionary or nsarray. here's example of might do: [mydatasourcedictionary removeallobjects]; [mytableview reloaddata]; take @ apple's documentation on nstableview too.

python - Sed to remove everything after "." in file using * command? -

i have following data.txt: 95 flour. 47 water.s etc.. i need remove after period . in file yield this: 95 flour 47 water etc.. i have tried using these sed command without success, yield blank document: sed "s/'.*//" data.txt > cleaned.txt sed 's/\.*//' data.txt > cleaned.txt either escape . backslash literal . , or use brackets define character class: sed 's/\..*$//' data.txt > cleaned.txt sed 's/[.].*$//' data.txt > cleaned.txt you tried 's/\.*//' , "zero or more literal dots", different "literal dot followed 0 or more of anything", i.e. 's/\..*//' . added $ measure.

oauth - Can you get a users email with just OpenID? -

i'm trying wrap head around openid , oauth. from understand, openid says user of openid provider. if log site using openid, return "yes, person user of x site." if want retrieve users email address, need authorization well, oauth comes in. all being said, imply if openid username email address, there no way retrieve information without oauth well? here's post openid vs oauth . from understand, openid says user of openid provider. if log site using openid, return "yes, person user of x site." it depends on you're using openid provider , whether support attribute exchange - allow relay party ask additional attributes user (e.g. email). here's so question asking google/yahoo supported attribute exchange values. all being said, imply if openid username email address, there no way retrieve information without oauth well? again, depends on you're using openid/oauth (and possibly version of each protocol too

DotNetNuke 7 - Synchronizing files stored in Azure Folder Provider -

i have dotnetnuke version 7 installed on azure vm. created folder of type azure folder provider in file manager. upload files directly azure blob storage container , have dotnetnuke pick files not uploaded via file manager (which creates records of uploaded files in dbo.files table). possible via configuration? looking guidance on if possible. thank you. it turns out there documented issue dnn 7 files azure folder not synchronized. upgrading latest version resolves problem.

Cross-process locking with Android NDK? -

is there way lock e.g. using mutexes or file locks on android ndk, across processes? i want lock socket 1 process can send @ once. processes not forked, independent invocations. as writing shared library, cannot rely on shared location requires permissions write it, neither can use process local storage, because unable share other processes definition. goes app names too. i'm looking abstract namespaces af_unix sockets, mutex/semaphores. assuming processes have same user id, can use flock(2) lock file (could accessible both processes), or posix semaphore operations ( sem_open(3) ) use semaphore. if user ids different, mechanisms still work, have set file permissions more "open" -- introduces risk of malicious app performing denial-of-service attack grabbing lock.

LLVM tail call optimization -

here understanding of things: a function "f" tail recursive when calling last action. tail-recursion can optimized forming loop instead of calling function again; function's parameters updated in place, , body ran again. called recursive tail call optimization. llvm implements recursive tail call optimization when using fastcc, ghc, or hipe calling convention. http://llvm.org/docs/codegenerator.html#tail-call-optimization i have questions: let's consider silly example: int h(int x){ if (x <= 0) return x; else h(x-1); } 1) in example, keyword "tail" preceeds call. elsewhere read keyword optional. suppose function above translated llvm appropriately, last few lines need be %x' = load *i32 %x %m = tail call fastcc i32 @h(i32 %x') ret %m 2) meaning of inreg option in example? 3) not want perform tail call optimizations on place, recursive functions. there way can llvm perform optimization (when available) recursive

Using extendscript (javascript) how can I get the color values from the Photoshop color table -

i'm writing photoshop script in extendscript/javascript , i'm trying verify document using 1 color (plus transparency). change document mode indexed color , values in color table. i have changed document mode indexed color can't figure out how access color table or color values inside of it. my working alternative use colorsampler compare values of each pixel, can take couple of minutes run on larger documents , speed issue project. please let me know if there way access color table or if see way reduce time takes run function. function sample_color(doc, sample_rate) { var status = 'pass' var color_sampler = doc.colorsamplers.add([0,0]) var color_val = false //first (and only) color value in document var broke = false (x=1; x < doc.width; x+=sample_rate){ if (broke){ break } (y=1; y < doc.height; y+=sample_rate){ color_sampler.move([unitvalue(x, 'px'), unitvalue(y, 'p

algorithm - Generating Random Puzzle Boards for Rush Hour Game -

Image
if you're not familiar it, game consists of collection of cars of varying sizes, set either horizontally or vertically, on nxm grid has single exit. each car can move forward/backward in directions it's set in, long car not blocking it. can never change direction of car. there 1 special car, it's red one. it's set in same row exit in, , objective of game find series of moves (a move - moving car n steps or forward) allow red car drive out of maze. i've been trying think how generate instances problem, generating levels of difficulty based on minimum number solve board. any idea of algorithm or strategy that? thanks in advance! the board given in question has @ 4*4*4*5*5*3*5 = 24.000 possible configurations, given placement of cars. a graph 24.000 nodes not large todays computers. possible approach construct graph of positions (nodes positions, edges moves), find number of winning moves nodes (e.g. using dijkstra ) , select node large dis

How to save log-in state in Windows Phone 8? -

i'm trying build app wp8 login page. want save user login state end-user not have retype his/her credentials, app html page embedded in webbrowser control. can me how save login state ? first of if website trying log in not yours ask cannot done. now assuming using webbrowser in xaml code , website log in yours lets have login successfull method: there have call code: window.external.notify("loginsuccess"); then webbrowser should this: <phone:webbrowser horizontalalignment="stretch" name="webbrowsercontrol" verticalalignment="stretch" isscriptenabled="true" scriptnotify="javascriptnotify"/> and method gets called in .cs file should store success value isolated storage checked every time open login page: void javascriptnotify(object sender, notifyeventargs notifyargs) { // check if value correct: if (notifyargs.value.equals("loginsuccess")) { // save state iso

Timer (NSTimer scheduledTimerWithTimeInternval) and Bluetooth Delegate: CBPeripheralDelegate does not work with NSTimer -

i need create regular timer read rssi value of bluetooth peripheral. code has viewcontroller delegate object in turn delegate bluetooth: in viewcontroller: @property (weak, nonatomic) ioeble *blecontrollerofdiscoveredgateway; in class ioeble (ioeble.h): @protocol ioebledelegate <nsobject> @optional -(void) responsefromblecontroller:(nsstring *)sw; @required @end @interface ioeble : nsobject <cbcentralmanagerdelegate, cbperipheraldelegate> @property (nonatomic,assign) id <ioebledelegate> delegate; @property (strong, nonatomic) nsmutablearray *peripherals; @property (strong, nonatomic) cbcentralmanager *cm; @property (strong, nonatomic) cbperipheral *activeperipheral; @end in ioeble.m implemented 1 of delegate methods cbperipheraldelegate: - (void)peripheral:(cbperipheral *)peripheral didupdatevalueforcharacteristic:(cbcharacteristic *)characteristic error:(nserror *)error { // code here } in viewcontroller - trying create regular timer read rss

ios - Memory Warning Crash using ARC -

Image
this question has answer here: app crashes saying memory warning using arc [closed] 3 answers i using arc , app crashes saying received memory warning . have used apple instruments , got 5 it looks not have leaks cannot find wrong. crash has memory , due arc cannot use release , sort. first time dealing memory usage using arc. there away can debug since dealing 2 months. have code on git hub helpful if @ it. can find here. i confused may because need set uiimage instant user capture image nil each time. looks creating instance again without dealloc old image. how able clear stuff. need help. thanks. the solution adding @autoreleasepool {} statements code. if have loop allocating lot of memory, memory may not freed until application gets main run loop. you want change loops iterate many times this: for (id value in largearray) { @aut

How a Ruby class to initialize all included modules? -

see following sample code first: module first def initialize puts "second init" end def first puts "first" end end module second def initialize puts "second init" end def second puts "second" end end class myclass include first include second def initialize super() end end c = myclass.new c.first c.second output of program is: second init first second from output, can see myclass has included first , second modules, because has both first() , second() methods. in myclass constructor, try initialize both included modules super() , seems second 's constructor called. how initialize included modules? include inserts module in between present class , ancestors. since first , second included, ancestors of myclass is [myclass, second, first, ...] the keyword super looks first method available in ancestor class besides own class. , finds second#initialize . if

java - Understanding `+` in regular expression -

Image
i have regular expression remove usernames tweets. looks this: regexfinder = "(?:\\s|\\a)[@]+([a-za-z0-9-_]+):"; i'm trying understand each component does. far, i've got: ( used begin “group” element ?: starts non-capturing group (this means 1 removed final result) \\s matches against shorthand characters | or \\a matches @ start of string , matches position opposed character [@] matches against symbol (which used twitter usernames) + match previous followed ([a-za-z0-9- ] match against capital or small characters , numbers or hyphens i'm bit lost last bit though. tell me +): means? i'm assuming bracket ending group, don't colon or plus sign. if i've made mistakes in understanding of regex please feel free point out! the + means "one or more" of whatever follows. in case [@]+ means "one or more @ symbols" , [a-za-z0-9-_]+ means "one or more of letter, number, dash,

php - Instagram API dynamically login -

i have 2 pages allow user fetch images instagram index.php , home.php in index.php, provided login button allow user login. <?php $loginurl = $instagram->getloginurl(); echo "<a class='button' href='$loginurl'>sign in instagram</a>"; ?> in home.php, gets code return url index.php , images. my problem is, dont want direct user login, wish 1 php page save login id , password inside , dynamically login , save image db using 1 page means combine index.php , home.php without using button. how should this? new php , stuck in this. please , appreciate it. thanks!

jquery - fluid-fixed-fluid Layout using Bootstrap -

but i've read lot of others) i'm trying create fluid-fixed-fluid layout portfolio site. i've tried few different options online, see either offers fixed-fluid-fixed or layout has 2 fluid columns off side. i'd love have straight-forward 1024px middle (content) section 2 supporting fluid columns beside. i don't have code provide, i'll create sort of example go by. thanks in advance - feel kind of dumb asking this, haven't had think web in couple of years , feel way behind. <div class="row-fluid"> <div class="span3"></div> </div> <div id="row-fixed"> <div class="span6"></div> </div> <div id="row-fluid"> <div class="span3"></div> </div> this reminds me of in day...over ten years ago when saw lots of framesets. give frame width="*" , take width left on page. wish today's css offered

how to start asp.net mvc 4 ajax call -

plaese guide me start asp.net mvc 4 ajax enabled multi platform web application. have rest service hostrd in domain, want consume it. please guide me whether need access service javascript ajax call or create models @ server , request server ajax call. guides links appreaciated.. regards ani the exact way consume web service depend on content of service, , how want user interact, but, point of view, server should interacting webservice, , user server. is, guessed, "models" should reflect web service data structure. if want use ajax, use call methods in controller(s) load/update data webservice. it's bit difficult me go further without knowing talking about, give better idea of talking about, wrote own "api" deal amazon products advertising api, using rest service instead of soap. same api being used 3 differents web applications. inside each web application there ajax calls controller methods, in turn calls api methods. this mechanism works

c# - Smart Way to Handle Voice Commands in Code to Action a Command -

rather using switch/case or if boolean checks can long , awfully tedious, wonder if better way can sought handling , processing commands. e.g: if(settings.getname == command) { speak("i here"); } if("get news feed" == command) { myrssfeed rssnewsfeed = new myrssfeed(); rssnewsfeed.getfeed(); } the if commands go on... here snippet of switch statement: switch (command) { #region <-- time command --> case "time please": case "whats time": case "what time it": getcurrenttime(); break; #endregion <-- time command --> #region <-- date command --> case "whats date": case "what date it": case "whats date today": case "what date today": getcurrentdate(); break; #endregi