Posts

Showing posts from July, 2010

shell - About the usage of linux command "xargs" -

i have file love.txt loveyou.txt in directory useful ; want copy file directory /tmp . i use command: find ./useful/ -name "love*" | xargs cp /tmp/ but doesn't work, says: cp: target `./useful/loveyou.txt' not directory when use command: find ./useful/ -name "love*" | xargs -i cp {} /tmp/ it works fine, i want know why second works, , more usage of -i cp {} . xargs puts words coming standard input end of argument list of given command. first form therefore creates cp /tmp/ ./useful/love.txt ./useful/loveyou.txt which not work, because there more 2 arguments , last 1 not directory. the -i option tells xargs process 1 file @ time, though, replacing {} name, equivalent to cp ./useful/love.txt /tmp/ cp ./useful/loveyou.txt /tmp/ which works well.

php - CakePHP validate fields that aren't in the Database -

i have form values aren't in database. wan't validation on them made validation rules using field names. somehow validation rules aren't being used. i tried set different rules. file names correct since $hasmany connection works. i hope can help! form: <?php echo $this->form->create('map'); echo $this->form->input('min_x'); echo $this->form->input('max_x'); echo $this->form->input('min_y'); echo $this->form->input('max_y'); echo $this->form->end('submit'); ?> validation rules: public $validate = array( 'min_x' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ), 'max_x' => array( 'rule' => 'numeric', 'message' => 'please enter numeric value.' ), 'min_y' => array( 'rule' => 'n

What does "@" mean in makefile? -

we offen use @echo "do..." letting print do... . can tell me mean of condition ? count=$(shell ls | wc -l ) then @count=$( shell ls | grep abc | wc -l ) what's mean of second? it disables printing command line being executed. output command still appears. see this previous question or see makefile reference.

PHP vs Java MySQL connection pooling -

i have problem thought break down simplest. there 2 applications on lamp stack, 1 php , java , same thing: run simple query: select * test php execution takes 30 ms in total java excution takes 230 ms in total query run on local mysql client takes 10-15 ms in total java takes ~200 ms every time establish connection db. understand php uses kind of built in connection pooling, therefor doesn't need establish new connection every time , takes 30 ms result of it. is same thing possible on java? far failed achieve that. tried use apache commons dbcp connection pooling, no change @ all, still takes same time connect database. update: separate question i'm trying make connection pooling work on java, asking code example: java mysql connetion pool not working you misunderstanding concept , purpose of connection pooling. connection pooling meant maintain (set of) connections on single (java virtual) machine (typically, application server). goal allow

iphone - Having different locations of objects on a uiview -

i have application making uidatepicker , uitoolbar attached view. uitoolbar has animation set slide up. problem is. on iphone 4 toolbar needs finish animation @ lower position on iphone 5. how set height differently each device? you can distinguish iphone 5 iphone 4 this: if([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone && [uiscreen mainscreen].bounds.size.height == 568.0){ //is iphone 5 } else{ //is iphone 4 } then, set uitoolbar's frame appropriately each screen size. also, here's macro convenience (put in .pch file): #define is_4_inch_screen [[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone && [uiscreen mainscreen].bounds.size.height == 568.0

Checking two conditions before compiling using Ant build -

i want check presence of dependent files before code compiled. doing following <available file="xx" property="isxxavailable"/> <available file="yy" property="isyyavailable"/> for compilation want check whether both properties true. go ahead compilation <target name="compile" depends="init" unless="isxxavailable" unless="isyyavailable"> is possible check both properties during compiling you can 'and' 2 'available' condtions single 1 : <condition property="files.available"> <and> <available file="xx"/> <available file="yy"/> </and> </condition> then can use condition in same way doing in target http://ant.apache.org/manual/tasks/condition.html

ember.js - Show spinner next to navigation link when clicked -

say have few links in navigation: ... {{#linkto 'projects.trending' tagname="li"}} <a href="#" {{bindattr href="view.href"}}> trending projects</a> {{/linkto}} {{#linkto 'projects.all' tagname="li"}} <a href="#" {{bindattr href="view.href"}}> projects</a> {{/linkto}} ... when click 1 of these links, fetch data via ajax , go route. takes while fetch data, i'd show spinner. have global spinner @ top of page. cool show spinner next navigation link clicked, user sees page loading. what best/easiest approach implement this? you put span next each navigation link that's hidden default, , contains spinner. onclick, show span. hide of them after ajax done.

jaxb - XStreamAsAttribute not adding as attribute - xstream -

i wrote class converted xstream xml . i added @xstreamasattribute add xmlns attribute . got added nested tag in output my class file follows @xstreamalias("getconfigurationparametersresponse") public class getconfigurationparametersresponse extends baseresponse { @xstreamalias("xmlns") @xstreamasattribute final string xmlns = "http://www.collab.net/teamforge/integratedapp"; @xstreamalias("xmlns:ns2") @xstreamasattribute final string ns2="http://www.collab.net/teamforge/integratedapp"; @xstreamimplicit(itemfieldname="configurationparameter") protected list<configurationparameter> configurationparameter; public list<configurationparameter> getconfigurationparameter() { if (configurationparameter == null) { configurationparameter = new arraylist<configurationparameter>(); } return this.configurationparameter; } } t

IOS in-app purchases stopped working suddenly, fetching null identifiers -

my in-app purchases working until yesterday , today submitting app review. change made in app page in itunes, connected app (by checking) in-app purchases. from time, every time try in debug app buy test account, getting error: nsinvalidargumentexception', reason: 'invalid product identifier: (null)' i have already: re-installed app logged out store , used again test account but today nothing seems work. exact same code working perfect yesterday, same test account. may because did change in itunes? worrying happen when app gets approved , goes online. any appreciated. edit: the problem array _products stays nil. - (void)reload { _products = nil; nslog(@"reload called"); [[vimaiaphelper sharedinstance] requestproductswithcompletionhandler:^(bool success, nsarray *products) { if (success) { _products = products; nslog(@"success appstore"); } }]; (skproduct* product in _p

c# - Advice on image storing -

i developing app browse(and more things, not relevant) youtube lists. whenever video, display it's corresponding image , show in listview (or gridview, again not relevant). here dilemma: better store images locally after downloaded, or download them every time want them showed, i.e: this._image = new bitmapimage(new uri("http://domain.com/content/someimage.jpg")); you're going want see youtube has on matter; i'm sure it's got regarding in developer api documentation note preferred approach it. that said, take general advice; when you're querying system, want limit how annoying are. now, youtube's not going notice load of 1 app, of course, it's still habit keep. speaking, i'd prefer split difference: cache image based on video id , hold x hours, if user pulls same video in search 20 times didn't request thumbnail 20 times well. that way keep result relevant updating image every day or 2 (assuming searched video again). e

linux - Check for ftp authentication output for bash script -

i run automated backup shell script, works great, reason ftp blocks me few minutes. add retry , wait feature. below sample of code. echo "moving external server" cd /root/backup/ /usr/bin/ftp -n -i $ftp_server <<end_script user $ftp_username $ftp_password mput $file bye end_script after failed login message below authentication failed. blocked. login failed. incorrect sequence of commands: pass required after user i need capture such output , make code atempt sleep few minutes before trying again. ideas? if it's possible install additional programs onto system of interest encourage take @ lftp . with lftp possible set paramters time between reconnects etc. manually. to achieve aim lftp have invoke following lftp -u user,password ${ftp_server} <<end set ftp:retry-530 "authentication failed" set net:reconnect-interval-base 60 set net:reconnect-interval-multiplier 10 set net:max-retries 10 <some more cust

javascript - Find part of string throughout site and replace with new text -

i still having trouble understanding regex. not sure if can target whole page...but without knowledge of how format regex, getting play it. i have trademarked name appears throughout page. i'd use js add (r) end of every time appears. can jquery/js accomplish this? $("body").each(function() { this.innerhtml = this.innerhtml.replace( 'breathe right', 'breathe right(r)'); }); thanks! this use case css :after pseudo-element: css .product-name:after { content: " \00ae"; /* add restricted symbol after every element product-name class */ } html <span class="product-name">my product</span> working demo the easiest way wrap product name in span , tag class. i'm not sure if that's less work adding symbol markup begin with, though. the benefit of approach allow apply other styles product name, bolding text or changing font color. you can read more :af

jquery - replaceWith doesn't work the second time -

i need click on list item replace text in div text node in xml file. i click on list item , store result in variable. load xml, find title of node need, , make variable of result. run if statement if 2 variables equal, put xml in div. the first time click on list item, works. correct item in list matched correct node in xml , correct text placed in div. but when click on different list item, text not replaced. alert shows second click got right information, in end, div content not replaced. demo here: http://mwebphoto.com/mwebphoto/html/3rdjquerypage.html code here: <body> <div class="slideshowcontainer"> <div id="slideshow"></div> </div> <ul id="gallery_id"> <li id="newyork">new york</li> <li id="disconnection">disconnexion</li> <li id="jackatsea">jack @ sea</li> </ul> <script> $(document).ready(function(){ $(&q

c# - Updating using code first in Entity Framework 5 with detached entities -

i developing n-tier application detached entities (visual studio 2010). have not included class definitions seem irrelevant logic. the following code snippet works correctly , embedded in using dbcontext . dbcontext.entry(case).state = case.caseid == 0 ? entitystate.added : entitystate.modified; dbcontext.entry(case.woman).state = case.woman.caseid == 0 ? entitystate.added : entitystate.modified; dbcontext.entry(case.summary).state = case.summary.caseid == 0 ? entitystate.added : entitystate.modified; dbcontext.savechanges(); i have added collection icollection<cause> causes summary class. what want is: check see if new cause same saved cause , and, if so, change value of flag in saved cause insert new cause dbcontext there flag iscurrent in cause class; there 1 record set true ; needs set false if new cause different one. i welcome code-first based way of doing this. something should work: using (...) { cause c = db.causes.firstordefau

c# - Embedded resources in assembly containing culture name in filename will not load -

i'm trying embed email templates in class library. works fine, until use filename containing culture-name following notation: templatename.nl-nl.cshtml resource not seem available. example code: namespace manifestresources { class program { static void main(string[] args) { var assembly = assembly.getexecutingassembly(); // works fine var mailtemplate = assembly.getmanifestresourcestream("manifestresources.mailtemplate.cshtml"); // not ok, localized mail template null var localizedmailtemplate = assembly.getmanifestresourcestream("manifestresources.mailtemplate.nl-nl.cshtml"); } } } templates both have build action set 'embeddedresource'. obvious solution use different notation, notation. has solution problem? are sure have right name resourceset when open resourcestream? unless manifestresources project base namespace , .cshtml file li

php - strip_tags removes allowed tags when within attributes -

for reason, php's strig_tags( ) function removing brackets tags explicitly allowed, when tags appear within attribute. example: <div data-contents="<p>hello!</p>"></div> becomes <div data-contents="phello!/p"></div> i know, know. isn't practice. regardless, ideas? as warnings on man page state: **because strip_tags() not validate html, partial or broken tags can result in removal of more text/data expected. if want embed html inside attribute, must encoded, e.g. should have &lt;p&gt;hello!&lt;/p&gt; instead. strip tags "dumb" , remove looks tag, regardless of tag occurs in text, or if result in broken page or not.

JSON with PHP foreach -

ok per suggestion updated... default laravel returns json... have set return array still getting same row duplicated using: $limits = array(); foreach($pieces $coverage_limit){ $limits[] = coveragelimit::index($coverage_limit); } return json_encode($limits); } the $limits array hold last value coveragelimit::index() returns on iterate, suggest check on coveragelimit::index() return value if falls "marc b"'s answer. edit: foreach($pieces $key=>$coverage_limit) { $limits[$key] = coveragelimit::index($coverage_limit); } or foreach($pieces $coverage_limit) { array_push($limits, coveragelimit::index($coverage_limit)); } both should returns same marc b's answer

laravel - How to access values from a configuration file stored in subdirectory? -

accessing config values @ run-time in laravel 4 done using config class: config::get('app.timezone'); to organize config files, i'd put them different sub-directories. for example: /config/users/  ->   for user specific configuration /config/auth/    ->   authentication related and on... i read an elder tutorial (laravel v3) dayle rees him stating it's possible following: $option = config::get('ourconfig.sub.directory.size'); tried out no luck. according jason lewis never supported. then i've had @ laravel 4 api , found load() , getrequire() (more related functions can found here ). however, couldn't find way grab sub-dir config values in l4. so, is possible laravel 4? …and, if so, how? a solution problem works me is: config::get('subdir/file.key'); did try 1 yet or looking more complex method?

login - Adding a username/password to a URL -

i have web address i'm trying add functionality username/password included. this not super secure website, on 'https' because other 1 username/password that's used in organization, it's secure outside world. it's online school website portal login. i've tried this... username:password1@university.edu/portal/server.pt and this... https://xxx.university.edu/portal/server.pt?username=someuser&password=somepassword (thanks ali b) ...but doesn't work. understanding ms fixed bug allowed happen after ie6. any chance of workaround out there? reason after many people try log it, locks out trying attempt login, , when whole organization can't log in, that's problem. thoughts? edit: should known address accessed on ie8 only. it's our corporate browser. microsoft officially stopped supporting username/password combos in urls. ie 6 last ie support function. http://support.microsoft.com/default.aspx?scid=kb;[ln];83

android - onLocationChanged not called on some devices -

this question has been asked numerous times not find solution works. i developing application using fused location provider. in onconnected() method, requesting location updates , application logic initiated once location fix generated , onlocationchanged() called. (please refer code below). problem onlocationchanged() method never called on devices. use samsung tab 2 , samsung galaxy grand testing. code works fine on tab 2 not work on grand. not work, mean locationclient gets connected onlocationchanged() never called. earlier, used location manager getting location , in implementation, same problem occurred. so, tried implementing fused location provider still same problem. can me out issue? there missing here? public class mainactivity extends activity implements googleplayservicesclient.connectioncallbacks, onconnectionfailedlistener, locationlistener { locationclient locationclient; locationrequest lr; location loc1; static string address; @override protected

Jenkins CI Results CSV -

i attemtping integrate jenkins ci , aptest jenkins run automatically update aptest results. i have aptest importresults script below need way generate appropiate csv file containing results data jenkins. can help? aptest import results . do need results data in history of job / system dumped every single time? or looking incremental csv after completion of each build?

azure - Why do not CloudTableQuery.Begin/EndExecuteSegmented auto-hande continuation tokens -

i using .net storage client (june 2012) , have query following (from e in tablecontext.createquery<entity>(tablename) select e).astableservicequery(); this returns cloudtablequery type , documented as: “converts query of type dataservicequery cloudtablequery object handles continuation tokens , retries failed calls table service.” i have tried make cloudtablequery handle pagination “internally” in table service responses me. execute() method this, handles continuation tokens if there more results. on other hand, when try use asynchronous methods same operation ( beginexecutesegmented / endexecutesegmented pair), observed both overloads of beginexecutesegmented not handle pagination internally (as advertised in astableservicequery() docs). therefore wrote following snippet: while (true){ var ar = continuationtoken == null ? entities.beginexecutesegmented(null, null) : entities.beginexecutesegmented(continuationtoken, null, null)

jQuery ui droppable hoverClass activeClass -

i have code $( "div.column_14_int" ).droppable({ accept: "div.element-container", activeclass: "drop-cl", hoverclass: "drag-over", tolerance: 'pointer', greedy: true, drop: function( event, ui ) { $(ui.draggable).appendto( ); }, }); that works fine, when start dragging item, activeclass added droppable , work. when draggable item on droppable hoverclass added droppable, doesn't work: droppable element still has activeclass color. draggable item <div class='element-container delete_el w4-4'>\ <div class='element-handler'>\ <a href='#edit-element' class='edit revs-edit-element'>edit</a>\ <a href='#del' class='del-element'>x</a>\ </div><div class='element'>\ <span class='element-icon'>\ <img src='http://placehold.it/36x36&text=icon'></span>\ <span class=

php - Iterate mysqli unbuffered query result more than once -

problem: i have query returns large result set. large bring php. fatal memory max error , cannot increase memory limit. unbuffered queries i need iterate on array multiple times mysqli_data_seek doesn't work on unbuffered queries. mysqli_result::data_seek //i have buffered result set $bresult = $mysql->query("select * small_table"); //and large unbuffered result set $uresult = $mysqli->query("select * big_table", mysqli_use_result); //the join combine them takes long , large //the result set returned unbuffered query large store in php //there many rows in $bresult re-execute query or subset of each 1 foreach($bresult &$row) { //my solution search $uresult foreach row in $bresult values need $row['x'] = searchresult($uresult, $row['key']); //problem: after first search, $uresult @ , and cannot reset mysqli_result::data_seek } function searchresult($uresult, $val) while($row = $uresult->fetch_assoc()){

vba - How to split a Name Field that has incorrect data? -

i have table field called patrn_name set first_name, last_name m.i. examples: smith, james m jones, chris j. i trying break field first_name, last_name , mi fields. asked question , helped me use split() last_name field. however, when try use split() function first_name not work because field has records not follow name convention of field , instead follows: "town library - gw" or "donation new york city". when code encounters these types of names throws error "subscript out of range" on line using rst!first_name = split(trim(split(rst!patrn_name, ",")(1)), " ")(0). how can make code run on data follows standard name convention of field? function change_name() dim dbs dao.database dim rst dao.recordset set dbs = currentdb set rst = dbs.openrecordset("active patrons", dbopendynaset) rst.movefirst while not rst.eof rst.edit rst!last_name = split(rst!patrn_name, ",")(0) rst!first_name =

How to know when an object opacity reaches a value of 0 using jQuery -

i have object gradually goes transparent , set callback function when object's opacity reaches value of 0, can reset opacity , position when completed. here code far: var angle = 0; var reverseangle = 0; setinterval(function(){ angle+=3; reverseangle-=3; $("#part1, #part3, #part5, #part7").rotate(angle); $("#part4, #part2").rotate(reverseangle); $("#part9").animate({ opacity: "-=0.1", top: "-=1" }, 800); },50); you can add callback function end of animation. $("#part9").animate({ opacity: "-=0.1", top: "-=1" }, 800, function(){ if($(this).css("opacity") <= 0){ stuff } } ); i added <= , in case

c# - using asp.net data source to bind to controls vs binding controls to a context -

ok straight out of college , 1 month first developer job. in school have taught if use toolbox in asp.net (c#) makes things quicker , have less code type using drag , drop controls. have bind controls data source put on page. understand , know inside controls , data source can customize way acts or data brings , can bind these based off of other controls , things well. @ new job have told me stay away using drag , drop controls , code them hand used coding , learn more go can see , agree on. but told me not use data source controls tool box use this: protected void page_load(object sender, eventargs e) { populatedropdownlist(); } private void populatedropdownlist() { ilist<company> companies = null; using (var context = new companycontext()) { companies = context.companyrepository.tolist(); } ddcompanyname.datatextfield = "name"; ddcompanyname.datavaluefield = "id";

linux - plaintext output from pcap in tshark (with options from wireshark?) -

i'm trying run script allow me export pcap files plaintext versions wireshark. my issue need have packet summary line , packet details expanded , packet bytes , , each packet on new page under packet format options. believe packet summary line on default, packet details "as displayed" using -v flag. this man page i've been using. i have used command: tshark -v -r "$file" >> text_out.txt; any assistance appreciated. i need have packet summary line , packet details expanded , packet bytes tshark -pvx -r "$file" >>text_out.txt , @ least newer versions of tshark. and each packet on new page not supported in tshark, unfortunately.

python - Jinja2 not rendering quotes or amp in javascript/html; safe filter not solving -

first post; try keep short , sweet. i trying render edit form detects , populates input fields if values exist fields. i'm using flask jinja2 , when use {{ }} print operator, fields have double quotes , ampersands rendered &#34; , &amp; respectively. the catch: happens when print operator being used in javascript function. i've looked on solutions, , seemed jinja2 safe filter trick, when appended print value, invalidated of javascript. below code sample: function test() { var namefield=document.getelementbyid("thing"); namefield.value="{{ values[0] }}"; } 'values' python list. please let me know if can add clarify issue. the safe filter prevent html escaping , provide solution problem. however error in javascript because have double-quotes inside string limited double-quotes! suppose value of values[0] string: double-quote " , ampersand , get: function test() { var namefield=document.get

c# - Git cant diff or merge .cs file in utf-16 encoding -

a friend , working on same .cs file @ same time , when there's merge conflict git points out there's conflict file isnt loaded usual "head" ">>>" stuff because .cs files binary files. added numerous things (*.cs text , on)- our .gitattributes file make git treat text file didnt work. thats when realized git diff other .cs files , not one. reason because in unicode encoding contains chinese characters. so how make git diff or merge files in utf-16 or utf-8 format? the furstrating thing if push, gitlab shows whats different. dont how git can diff on server not bash. i had similar problem *.rc files c++ project , found best way solve use git's smudge , clean filters store in repository utf-8, , convert utf-16 when writing working directory. this way git such diffs, merges or whatever work on utf8 text without issue, working copy have utf16, keep visual studio happy. to configure this, make sure you're using version of git

computer vision - Skin / people detection in Java? -

does know java library or framework allow me detect people in picture (jpg, png, etc..)? i don't need detect faces, nor recognize them. all need know if there human being present in picture (or not). i used opencv project @ university. open source , supports many different languages, java. furthemore, has big user community. http://opencv.org/

python - How do I import the Dropbox SDK into a Google App Engine application? -

i want line import dropbox to work. downloaded python core api dropbox, , copied contents of zip file (otherwise working) app's folder. when run app, gives me following error: error 2013-08-07 19:47:04,111 wsgi.py:219] traceback (most recent call last): file "/home/myusername/downloads/google_appengine/google/appengine/runtime/wsgi.py", line 196, in handle handler = _config_handle.add_wsgi_middleware(self._loadhandler()) file "/home/myusername/downloads/google_appengine/google/appengine/runtime/wsgi.py", line 255, in _loadhandler handler = __import__(path[0]) file "/home/myusername/downloads/appname/appname.py", line 1, in <module> import dropbox file "/home/myusername/downloads/appname/dropbox/__init__.py", line 3, in <module> . import client, rest, session file "/home/myusername/downloads/appname/dropbox/client.py", line 14, in <module> .rest import errorresponse, restclient file "/home/myusern

c# - How to dynamically invoke delegates with known parameter base type? -

i trying implement own messaging system unity game. have basic version working - simplified example of follows: // messaging class: private dictionary<type, list<func<message, bool>>> listeners; // set other code. public void addlistener<t>(func<message, bool> listener) t : message { this.listeners[typeof(t)].add(listener); } public void sendmessage<t>(t message) t : message { foreach (func<message, bool> listener in this.listeners[typeof(t)]) { listener(message); } } // other class: private void start() { messaging.addlistener<mymessage>(this.messagehandler); // subscribe messages of type. } private bool messagehandler(message message) { // receive message message base type... mymessage message2 = (mymessage)message; // ...so have cast mymessage. // handle message. } this works fine. implement "magic" allow message handler called actual derived type, this: private bool messagehand

php - Only updating half the data to MySQL table -

the code below updating data in mysql table. written pulling data 1 query have tried adapt pull data 2 queries improve ordering. of records update when submit button clicked , i'm not sure how fix it. the original code was: if(isset($_post['submit'])){ $password = $_post['password']; $total = $_post['total']; $park_id = $_post['park_id']; if($password=="****"){ for($i =1; $i<=$total; $i++){ $ride_id = $_post['ride_id'.$i]; $name = $_post['ride_name'.$i]; $type = $_post['type'.$i]; $topride = $_post['topride'.$i]; $info = $_post['info'.$i]; $speed = $_post['speed'.$i]; $height = $_post['height'.$i]; $length = $_post['length'.$i]; $inversions = $_post['inversions'.$i]; $query = "update tpf_rides set na

HighCharts - Logarithmic X Axis malfunction -

whenever change x axis of existing chart linear logarithmic, chart doesn't scale in same manner when y axis changed. clear, axis indeed change linear logarithmic, y axis scale not adjust , appears cannot adjusted new settings. i think may problem highcharts. the fiddle demonstrating problem here . note command using change axis : chart.xaxis[0].update({ type: "logarithmic" }); i may need include in command, maybe approach problem linear , need rescale view (that supposed humorous). looks bug in highcharts, reported here . thanks!

regex - HIVE regexp_extract URL strings -

hi i'm trying parse large url's log using hive. there particular value want extract url (strategy=??) values can hyphenated, not always. i built sample query, returns nothing. what doing wrong? select regexp_extract('234=23234&werw=asdf&strategy=retargeting&asdf=fds23', '(strategy=)([-\w*]*)',2) vt; so value i'm expecting retargeting partial url string. 234=23234&werw=asdf&strategy= retargeting &asdf=fds23 any appreciated!!! i believe regex work you: strategy=((\w-?)+) here's regexr link: http://regexr.com?35sbl . after matching, group 1 contains value of strategy . note regex match number of hyphens in value. fails if hyphen first character (though, in opinion, leading hyphen not make value 'hyphenated'). from can tell, method didn't return because of way group 2 set up: have [-\w*] , says "match hyphen , number of alphanumeric characters (including 0)". rewrite [-?\w*]* , s

flex - data suddenly not returning from facebook chat (limits??? changes???) -

i have app integrates facebook chat. has been working year now. of sudden, i'm noticing calls don't return data. after lots of frustration, removed app account , reset token. , started working agin... sorta. @ least receiving presence stanzas. but, roster , vcards still don't respond. after third use of app... not sending presence stanzas again. adding , removing gave me 3 uses , cut. i know code right (or has been right year). challenge / response goes success.. facebook won't send me roster... or vcard anymore. threw ping in measure make sure fb still on other end, , sent me "feature not supported" response. fb online, i'm auth'd fine... doesn't want respond. did facebook change chat somehow? reviewed limited info seems still xmpp has been... nothing unusual. , why few features work few moments after removing , re-adding app stop working again nothing different on end? confused... insider on extremely appreciated. edit: no

Mysql performance sending data -

i've got table looks this: id (int, 9, unique key) --- item (int, 3) --- userid (int, 9) --- position (varchar, 12) now want run folling query: select count( * ) table position 'bag%' , userid = ".userid." the possible positions cases "bag0", "bag1", [...], "bag6" , unique - means there no userid has 2 items in bag2, example. but it's not unique - example 2 rows having "userid: 82378, positon: 'box1'" possible if try in()-clause doesn't change result. the "sending data"-time query 50ms. do have ideas how modify table query works faster? this query: select count( * ) table position 'bag%' , userid = ".userid."; this pretty simple query. way can speed using index. suggest composite index of table(userid, position) . mysql should optimize like because initial prefix constant. but, if want really, sure index gets used, can do: select count

What is the point for git reset accepting paths as an argument when we have git checkout? -

i understand git reset updates index, whereas git checkout updates working copy. don't understand use case requires git reset accept argument reference , path? seems want use git checkout in case? this comes time when folks ask why can't git reset some-ref --hard -- some/path/to/file . real question why git reset accepts git reset some-ref -- some/path/to/file when have git checkout . never thought of till teaching difference between two. typically, if add file index, , realize want remove index, need: a reference (head) reset file index head (since head reference state nothing has been staged yet: commit) a file that is: git reset head -- a/file that "unstage" file. git reset moves head without affecting content (unless git reset --hard : mode working tree affected) git checkout modified working tree (and file content) git reset accepts ref , path because has three modes (soft, mixed , hard). (see " practical uses

How to properly attribute Freebase -

i hope right place ask question. i attempting attribute freebase, website: https://www.freebase.com/policies/attribution does not produce html code or image. my question is: how give proper attribution freebase in mobile app? specifically, ios. or, citation included in api response sufficient? example: citation = { provider = wikipedia; statement = "description licensed under creative commons attribution-sharealike license (http://en.wikipedia.org/wiki/wikipedia:text_of_creative_commons_attribution-sharealike_3.0_unported_license)."; uri = "http://en.wikipedia.org/wiki/georgia_institute_of_technology"; }; edit: i've tried access website via safari, mozilla firefox, , google chrome. of not show html code or image. edit 2: i've found webpage, seems cover types of licensing freebase. although, think of content outdated. http://legal.stefanomazzocchi.user.dev.freebaseapps.com/licensing

javascript - Is there a good touch library for IE10 & other browsers? -

i need simple gesture detection (swipe left/right, etc) poj or jquery. various reasons, must run on ie10 first-class citizen, none of libraries i've seen have support detection. i hoping nice, tested, all-inclusive solution. have missed something, or need start said project? ie10 has built-in utilities detecting high-level browser gestures. if coding ie10, you'll able create best user experience using built-in library, called msgesture . as can infer name, however, msgesture ie-only. if have support other browsers, might try hammer.js .

How to set a minimum random number in REBOL? -

i'm executing code , waiting somewhere between 1 second , 1 minute. i'm using random 0:01:00 /seed need able set floor waiting between 30 seconds , 1 minute. if want 0:0:30 minimum , 0:1:0 maximum, try formula: 0:0:29 + random 0:0:31 this formula yields "discretely distributed (pseudo)random value". if want "continuously distributed (pseudo) random value", can use (just in r3) formula: 0:0:30 + random 30.0 r2 not have native support "continuously distributed (pseudo)random values".

rest - Remove Square Brackets - Json Data - CakePHp RESTful -

i using cakephp create restful api connected via emberjs front end. the following code within cakephp generating json need putting in square brackets emberjs doesn't like. how go getting data without square brackets? cakephp view public function view($id = null) { if($id == null) { $id = $this->request->params['id']; } $this->layout = 'ajax'; $options = array('conditions' => array('content.' . $this->content->primarykey => $id)); $content = $this->content->find('first', $options); $content = set::extract('/content/.', $content); $this->set('content', $content); $this->set('_serialize', $content); ; } view.ctp echo json_encode(compact('content')); it returning this: { "content": [{ "id":"1", "name":"home", "extended":"th

c# - Why does DotNetZip cause OutOfMemory Exception in Images? -

i have tried zipping .png image file zip file using dotnetzip after extract later on , use image.fromfile method gives me outofmemory exception. have tried other images gives me same result. if override image file wasn't zipped don't error. compression code savefiledialog sfd = new savefiledialog(); sfd.filter = system.abriviation + " game|*" + system.extention; sfd.addextension = true; sfd.showdialog(); if (sfd.filename != "") { streamwriter write = new streamwriter(application.startuppath + "\\meta"); write.writeline(txtname.text); write.writeline(new fileinfo(txtgame.text).extension); write.writeline(txtcompany.text); write.close(); file.copy(txtgame.text, application.startuppath + "\\game" + new fileinfo(txtgame.text).extension); file.copy(txtgame.text, application.startuppath + "\\icon.png"); zipfile zip = new zipfile(); zip.addfile(application.startuppath + "\\meta"

datetime - How to calculate the time consumed from start time to end time in php -

i want perfect time consumed or total time start time end time: code: $start_time = $this->input->post('start_time'); $end_time = $this->input->post('end_time'); $t1 = strtotime($start_time); $t2 = strtotime($end_time); $differenceinseconds = $t2 - $t1; $differenceinhours = $differenceinseconds / 3600; if($differenceinhours<0) { $differenceinhours += 24; } in code above if $start_time = 11:00:00 pm , $end_date =11:30:00 gives me output of 0.5 instead of 30minutes . there appropriate way that? if the: $start_time = '01:00:00 pm'; $end_time = '01:25:00 pm'; $total = '25:00'; // 25 minutes or: $start_time = '11:00:00 pm'; $end_time = '11:00:25 pm'; $total = '00:00:25'; // 25seconds regards! try diff function <?php echo date_create('03:00:00 pm')->diff(date_create('03:25:00 pm'))->format('%h:%i:%s

python - Add point in interactive plot Chaco -

i'm using chaco , traits.api interactive plot. can select points in plot, , calculus. need update initial plot, don't know how (i need add points). thanks this code import numpy np enable.component_editor import componenteditor traits.api import hastraits, instance, int, list, str, enum, on_trait_change, any, delegatesto, array traitsui.api import item, view, hsplit, vgroup, enumeditor, hgroup, spring, label enthought.traits.api import hastraits, array, range, float, enum, on_trait_change, property chaco.api import arrayplotdata, plot, plotaxis, \ scatterinspectoroverlay chaco.chaco_plot_editor import chacoplotitem chaco.scales.api import calendarscalesystem chaco.scales_tick_generator import scalestickgenerator chaco.example_support import color_palette chaco.tools.api import pantool, zoomtool, rangeselection, \ rangeselectionoverlay, legendtool, scatterinspector # attributes use plot view. size=(800,800) title="scatter plot selection" bg_color=&qu

javascript - Animating an arrow that points to <li> based on position on the screen -

i not familiar html, css , javascript i using twitter bootstrap, i'd have section indicator in long page shows relative position of current view relative entire ver long scrollable page. the sample of want achieve in: http://global.tommy.com/int/en/collections/start i managed <ul> <li> , however, i'd animate arrow movement 1 <li> next <li> user scroll , down within page. managed scope out code <ul> <li> have no idea how animate movement... me point specific animation part or recommend javascript or css library that? missed twitter-bootstrap elements too, did not find far... thanks! edit: my code in jsfiddler, however, doesn't seem work in jsfiddler: the ul li code what wanted achieve animation on left side of tommy hilfiger's page when scroll , down, arrow keep track of section in adjusting arrow's position pointing specific section on li without more detail can't go specifics, can @ least sugges

c++ - How does this particular struct function like this? (arcsynthesis modern 3D graphics programming) -

i using arcsynthesis' tutorial learn modern 3d graphics programming, , while understanding of have run snag author calls "complex management code" can't understand how code works: struct instance { typedef glm::vec3(*offsetfunc)(float); offsetfunc calcoffset; glm::mat4 constructmatrix(float felapsedtime) { glm::mat4 themat(1.0f); themat[3] = glm::vec4(calcoffset(felapsedtime), 1.0f); return themat; } }; instance g_instancelist[] = { {stationaryoffset}, {ovaloffset}, {bottomcircleoffset}, }; i don't quite how function pointer getting set inside struct in g_instancelist[] don't syntactically how works , how g_instancelist used in next segment here: float felapsedtime = glutget(glut_elapsed_time) / 1000.0f; for(int iloop = 0; iloop < array_count(g_instancelist); iloop++) { instance &currinst = g_instancelist[iloop]; const glm::mat4 &transformmatrix = currins

oop - Difference between State pattern and and Strategy pattern -

looking @ gof patterns find similarities between state , stategy pattern rather striking. both swap out polymorphic classes modify behavior. else found same? what exact differences? the state , strategy patterns similar in sense both of them encapsulate behavior in separate objects , use composition delegate composed object implement behavior , both of them provide flexibility change behavior dynamically changing composed object @ run-time. there key differences : in state pattern, client knows nothing state objects. state changes happen transparently client. client calls methods on context, context oversees own state. because client not aware of state changes, appears client though context instantiated different class each time there change in behavior due state change. object appear change class official definition of pattern states. pattern built around well-defined series of state transitions. changing state key pattern's existence. even though strategy patte

java - How can I search a sentence in a file? -

i trying search program. don't know how search sentence in file. in c# can use linq , in java don't know. java loves difficult in both line-based , token-based scanning. heres example of line based scanning sentence: public static boolean scanfile(string sentence) { scanner linescan = new scanner(new file("filename.txt")); while (linescan.hasnextline()) { if (linescan.nextline().contains(sentence)) { return true; } } return false; } and heres example of token based scanning word: public static boolean scanfile(string word) { scanner linescan = new scanner(new file("filename.txt")); while (linescan.hasnextline()) { scanner tokenscan = new scanner(s.nextline()); while (tokenscan.hasnext()) { if (tokenscan.next().equals(word)) { return true; } } } return false; }