Posts

Showing posts from March, 2012

regex - Replacing the contents of a list of items using regular expressions -

given following string: lorem ipsum dolor sit amet, consectetur adipiscing elit. nulla rhoncus ipsum eros tincidunt ultricies... [menu] item 1|http://stackoverflow.com/1 item 2|http://stackoverflow.com/2 item 3|http://stackoverflow.com/3 [/menu] lorem ipsum dolor sit amet, consectetur adipiscing elit. nulla rhoncus ipsum eros tincidunt ultricies... i'm trying generate regular expression returns: lorem ipsum dolor sit amet, consectetur adipiscing elit. nulla rhoncus ipsum eros tincidunt ultricies... <ul> <a href="http://stackoverflow.com/1">item 1</a> <a href="http://stackoverflow.com/2">item 2</a> <a href="http://stackoverflow.com/3">item 3</a> </ul> lorem ipsum dolor sit amet, consectetur adipiscing elit. nulla rhoncus ipsum eros tincidunt ultricies... there 1 or more menu blocks in each string , unknown number of links within each block. i'm able swap whole block, falling on over rep

python - linux-watch command: show time remaining -

i posted thread: run python script everytime computer wakes hibernation i thinking of alternative countdown, show on console time remaining till command ran again. for example script import os os.system("watch -n 50 command") the console shows every 50 seconds run: command know of way show actual state of 50 seconds? i think there no way unless command creates information (e. g. timestamp after execution or similar). reason simple: watch simple enters nanosleep() system call wait 50 seconds. (you can find out using strace .) nanosleep() nothing else wait 50 seconds. not provide information anywhere on how long sleep has been going on or how long still take. information buried deep inside kernel will, eventually, wake process again. so, way making command render information, e. g. letting touch timestamp file (e. g. touch /tmp/command.timestamp ) time can used determine indirectly when next sleep finished.

php - preg_replace to replace string for matching url -

function makelinksinthecontent($html) { $html= preg_replace("/(^|[\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2<a href=\"$3\" rel=\"nofollow\" >$3</a>", $html); $html= preg_replace("/(^|[\n ])([\w]*?)((www|ftp)\.[^ \,\"\t\n\r<]*)/is", "$1$2<a href=\"http://$3\" rel=\"nofollow\" >$3</a>", $html); $html= preg_replace("/(^|[\n ])([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "$1<a href=\"mailto:$2@$3\" rel=\"nofollow\">$2@$3</a>", $html); return($html); } this code. my need autolinking url. using preg_replace find url , set link url. for example: "a page contains www.google.com." if pass content makelinksinthecontent($html), return "a page contains www.google.com ." but following url format not getting linked. ( http://www.google.com ) www.test.

batch file - If number is at certain range, do (command here) -

i ask question. i creating simple program scans numbers (people's grades) , checks if @ range (say, 75% 90%) , if @ range, following command; here's code. (more text below code) @echo off color title happy factor decoder echo hello! set /p eg="exam grade (raw): " set /p teg="total raw exam grade (the highest score): " echo calculating set /a m=%teg% - %eg% echo had %m% mistakes echo breaking down... timeout /t 1 >nul set /a bdf1=%eg% / 4 echo %bdf1% set /a bdf2=%teg% / 4 echo %bdf2% set /a bdf3=%m% / 4 echo %bdf3% echo broke down yeah :d if %eg% == 4 goto happy if %eg% == 3 goto kindahappy if %eg% == 2 goto kindasad if %eg% == 1 goto sad :happy echo father happy pause :kindahappy echo father kinda happy pause :kindasad echo father kinda sad pause :sad echo father sad pause you see, want (in pseudocode) if bdf1 @ range (80-90) goto happy any ideas? i don't know units of calculations, can check range lowest high: @echo off

javascript - Toggle visibility of a table element HTML through a button -

Image
i writing xsl file transforms piece of xml html , contains snippet of javascript code use toggle visibility of table element html click on button. don't need use style @ moment. here xml: <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type='text/xsl' href='myxsl.xsl'?> <lists> <scr>repository</scr> <dependency><artifactid>maven</artifactid> <groupid>no</groupid> <!--two tags details appear if 'groupid' node value 'no'--> <detail1> here text detail 1 </detail1> <detail2> here text detail 2 </detail2> </dependency> <dependency> <artifactid>eclipse</artifactid> <groupid>yes</groupid></dependency> </lists> my xsl is: <xsl:template match = "/"> <html> <head> <script type="text/javascript">

c++ - Is there a way to figure out the version of a compiler in code? -

is possible version of compiler in code? example using compiler directives? trying find version of compiler , lets if version of gcc or visual c++ c++11 compliant compile bit of code , if not compile thats snippet instead in gcc , clang, use __version__ macro.

How to handle Audio continously with Landscape and portrait in Android? -

i have created audio in 1 activity media player. have run start, pause, resume when rotate screen landscape or portrait mode song playing twice. here code: public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.audio); init(); prefs = preferencemanager.getdefaultsharedpreferences(this); final sharedpreferences.editor prefsedit = prefs.edit(); mp = mediaplayer.create(audio_activity.this, r.raw.subhanallah); log.e("song playing", "in mediya player "); mp.setlooping(false); mp.start(); system.out.println("media plyer start !!!"); prefsedit.putboolean("mediaplaying", true); prefsedit.commit(); btnchapter.setenabled(false); system.out.println("b4 button click!!!!"); } @override public void onconfigurationchanged(configuration newconfig) { su

Sharepoint list item count -

i have list having items greater 5000, have requirement show number of items in list on web page.can me on getting total items count . normal list view threshold set 5000. need count. thanks you need sp admins increase size of return query greater 5000 rows in central admin. if using sp object model in visual studio, loop through list in increments of limit until run out total rows. there's total rows/items property in splist object.

try catch - Python eval() exception handling in one line -

i programming irc bot in python. code in 1 line. know not how python programs should written, experimental. want execute oneliner scripts irc, don't know how handle exceptions. is possible evaluate python expression , handle possible exceptions in 1 line? afaik try-except not work in 1 line. here current code: http://pastebin.com/f34brq91 . not easy read that, not necessary understand answer question. :) no, there no way put exception handler in 1 line. can put simple statements on 1 line, , try - except compound statement. there no functions that'll swallow exception you. the way you'd able pull off in 1 line, create new code object raw bytes define bytecodes blanket try - except: pass construct. using bytecode go on create function swallows exceptions. however, not going write 1 you. sorry.

android - How to distribute apk to limited users. And they cannot re-distribute to others? -

how distribute apk limited users. , cannot re-distribute others? one way device imei number , post server check valid user or not. trying limit in android code avoid server communication. also not publish app on google play,i not able add google play licence verification library. hard code list of imei or device ids in app. on launch check device id against white list , either launch or kill app depending on result.

php - Chrome web apps - server side support -

does google chrome web store support server sided technologies such php or python? making productive web application have implemented in python wish give nice little web application interface , harness power of php... does chrome support python or php; or chrome support server sided scripting? i learning how develop chrome apps here ... if member aware of better tutorials please inform me... or have build normal web applications , add logo , manifest , zip , publish it? thankyou... the platform supports server-side technologies same way c++ or java application support them: through http (probably restful) interfaces server side of app (if any) exposes. example, app might make request http://example.com/api/foo/bar/baz?param1=123&param2=456 , , might json response app parse. doesn't matter server-side technology you're using, because api looks same app's perspective. if you're asking php, ruby, python, go, node.js, etc., running on user's

properties - Passing a property as argument like a delegate in VB.net -

i know it's possible pass function or sub using addressof pass delegate , in threadstart definition. dim othstart new system.threading.thread.threadstart(addressof mysub) now have program in same processing on , over, on differents properties of same object. part of code have. show 2 iterations, there 9 in total , there other processing didn't include yet bigger. if _oinforefbase.infostr1column = "" _oinforefbase.infostr1column = ocolumn.columnname getheader(colinfostr1, _oinfotable.nomtable, ocolumn.columnname) _oinforefbase.infostr1numeric = boolisnumeric _oinforefbase.infostr1float = boolisfloat _oinforefbase.infodefaultstr1 = getdefault(colinfostr1, _oinfotable.nomtable, ocolumn.columnname) elseif _oinforefbase.infostr2column = "" _oinforefbase.infostr2column = ocolumn.columnname getheader(colinfostr2, _oinfotable.nomtable, ocolumn.columnname) _oinforefbase.infostr2numeric = boolisnumeric _oinforefbase.i

opencv - Image classification using SIFT and SVM with Java -

i have images of flowers have extracted sift features , clustered features using k-means(k=3). create "histogram of cluster membership identifiers" feed svm classifier described in accepted answer question below. large scale image classifier my question is, how create histogram in java? i'm using opencv, there method have missed? i have mat of centres each row cluster centre , have mat of labels each element in column cluster index (0...2) each key point in image.

c# - can messageDialogs contents be customized -

i using message dialog , want customize contents increasing titles fontsize , changing fontweight. want use multi lines. i want message dialog these title(bigger , bolder) 1- nnnnnnnnnnnnnnnnnnnnn 2- kkkkkkkkkkkkkkkkkkkkk 3- lllllllllllllllllllll 4- hhhhhhhhhhhhhhhhhhhhh ok how can customize body , title? there's not lot can do, possibly better off creating own. can insert linbreaks via environment.newline e.g. messagebox.show("some text" + environment.newline + "some more text");

backbone.js - Underscore/Backbone template events -

in underscore.js templates, there way data of template click event? example: geocoder.geocode({ 'address' : $(this.el).find("input[name=locationsearchtext]").val() }, function(results, status) { if (results && status && status == 'ok') { this.results = results; var list =_.template("<ul><% _.each(results, function(result){ %><li><%= result.formatted_address %></li><% })%></ul>"); $el.find("#search-results").html(list); }else{ alert("something went wrong!"); } }); and in backbone on view: events: { 'click #search-results li': function(data){ 'the data of `result` passed template in each'} }, in past i've done stick data want in data- attribute of element

haskell - Parsec parser failed on many1 and manyTill combinators -

i have faced unclear behavior of parsec parsers, want parsre strings same > <cdid> 1 > <mol weight> 270.2369 > <formula> c15h10o5 > <log_er_rba> -0.36 > <activity> 1 i wrote parser parseproperties = skipmany1 newline char '>' >> spaces >> char '<' propname <- many1 (noneof ">") char '>' newline propvalue <- many1 (noneof "\n") return (propname,propvalue) this parser excellently parse 1 item, , able parse several: parsetest (count 5 parseproperties) "\n> <cdid>\n1\n\n> <mol weight>\n270.2369\n\n> <formula>\nc15h10o5\n\n> <log_er_rba>\n-0.36\n\n> <activity>\n1\n\n" results [("cdid","1"),("mol weight","270.2369"),("formula","c15h10o5"),("log_er_rba",&qu

multithreading - Random Neo4j database location for Embedded Jersey Tests -

i'm using com.sun.jersey.test.framework.jerseytest create junit tests jersey application. application uses neo4j spring data load data , return via rest api. the test starts embedded grizzly server jersey neo4j spring data webapp. after i'm able invoke rest requests , create nodes in neo4j database. unfortunately test fixed single neo4j database location since configured within applicationcontext.xml so: <neo4j:config storedirectory="/tmp/myapp/neo4jdb" /> my test fail if excute similar test @ same time because same directory used , 1 neo4j can obtain lock. i know springjunit4classrunner can't use because have neo4j instance running within embedded server. @contextconfiguration(locations = "classpath:/spring/applicationcontext.xml") @runwith(springjunit4classrunner.class) @transactional the test should create neo4j database in random directory. questions: is there way change storedirectory , clear neo4j database. changing

tkinter - Python: is there a way to have default for Entry field? -

is there way have text box in gui have default text display? i want text box have " please set path of file want... " however, when run - blank... my code follows: path=stringvar() textentry=entry(master,textvariable=path,text='please set path of file want...') textentry.pack() this should demonstrate how want: import tkinter tk root = tk.tk() entry = tk.entry(root, width=40) entry.pack() # put text in entrybox insert method. # 0 means "at begining". entry.insert(0, 'please set path of file want...') text = tk.text(root, width=45, height=5) text.pack() # textboxes have insert. # however, since have height , width, need # put 0.0 spcify beginning. same # x=0, y=0. text.insert(0.0, 'please set path of file want...') root.mainloop()

amazon web services - Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together) -

we adapting our applications cloudformation template make use of vpc. within template need programmatically generate cidr blocks used our vpc subnets, in order ensure not conflict between cloudformation stacks. my initial plan had been generate cidrs concatenating strings together, example: "proxyloadbalancersubneta" : { "type" : "aws::ec2::subnet", "properties" : { "vpcid" : { "ref" : "vpc" }, "availabilityzone" : "eu-west-1a", "cidrblock" : { "fn::join" : [ ".", [ { "ref" : "vpccidrprefix" }, "0.0/24" ] ] } } }, upon further consideration however, need use single vpc rather having vpc each of our stacks. aws restrict vpcs using maximum of /16 cidr block (we have asked limit raised, apparently not possible). means no longer possible use concatenation method each of our stacks require subnets span more 255

How to store 2 digit integer value and float values in char array in C -

following c code print values of char getting unexpected results. code #include<stdio.h> main() { char sendbuffer[1000]; float count; int i; for(count=1.5;count<=2.5;) { for(i=0;i<=15;) { sendbuffer[0]=count+48; sendbuffer[1]='a'; sendbuffer[2]='b'; sendbuffer[3]='c'; sendbuffer[4]=i+48; sendbuffer[5]='\0'; printf("%s\n",sendbuffer); i=i+5; } count=count+0.5; } } the results getting are: 1abc0 1abc5 1abc: 1abc? 2abc0 2abc5 2abc: 2abc? 2abc0 2abc5 2abc: 2abc? whereas, expecting 1.5abc0 1.5abc5 1.5abc10 1.5abc15 and on. can tell me how store integer , float values in char array in c? this can work: snprintf(sendbuf, sizeof(sendbuf), "%.1fabc%d", count, i);

php - Long polling in Laravel (sleep() function make application freeze) -

i'm trying program long polling functionality in laravel, when use sleep() function, whole application freezes/blocks until sleep() function done. know how solve problem? my javascript looks this: function startrefresh() { longpending = $.ajax({ type: 'post', url: '/getnewwords', data: { wordid: ""+$('.lastwordid').attr('class').split(' ')[1]+"" }, async: true, cache: false }).done(function(data) { $("#words").prepend(data); startrefresh(); }); } and php: public function longpolling() { $time = time(); $wordid = input::get('wordid'); session_write_close(); //set_time_limit(0); while((time() - $time) < 15) { $words = word::take(100)->where('id', '>', $wordid) ->orderby('created_at', 'desc')->get(); if (!$words->isempty()) { $theview = view::make('words.i

mod wsgi - Are apache's worker configuration and mod_wsgi's daemon mode related? -

so don't relation between these 2 things. for e.g. please explain happens when set startservers in worker configuration 5 , processes=2 in wsgidaemonprocess directive? when specify threads in wsgidaemonprocess , when specify threadsperchild in worker configuration.. doing? how many threads running eventually? i confused because have specify number of threads , processes in 2 places. please explain significance of each. for start, go watch following talks partial explanation. http://lanyrd.com/2013/pycon/scdyzk/ http://lanyrd.com/2012/pycon/spcdg/ in short, apache worker processes proxy requests mod_wsgi daemon mode processes if daemon mode configured , wsgi application delated run in it.

iphone - UIImagePickerController Camera Reappears after Being Dismissed - Memory -

after setting uiimagepickercontroller camera try dismiss following code : - (void)donebuttonclick: (id)sender { [self dismissviewcontrolleranimated : no completion no]; } however view reloads , view appear called again. think app receiving memory warning , pulling down non-visible views. i want reload previous view solution. previous view storyboard, trying following : - (void)donebuttonclick:(id)sender { //[self dismissviewcontrolleranimated:no completion:no]; uistoryboard * storyboard = [uistoryboard storyboardwithname:@"mainstoryboard" bundle:nil]; bsproomdefaultviewcontroller * myvc = (bsproomdefaultviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"default"]; [self presentviewcontroller:myvc animated:yes completion:no]; } however getting error "attempt present on view not in window hierarchy !" can suggest how can reload previous view ? instead of using [self dismissviewcontrolleranimated : no completion n

Android: Unwanted left/right margins on Nexus 10 in landscape mode -

Image
i'm having issue seemingly inexplicable margins appear on left , right sides of layouts when using nexus 10 device in landscape mode. i'm sure it's embarrassingly straightforward, can't find mention of when searching around. i'm pretty sure it's not related code, because default hello world project created eclipse exhibits phenomenon. following screenshot excerpts taken brand new project , change have made make textview textsize bit bigger clarity: you can see default margins layout xml file (shown below) applied correctly in portrait mode, there considerable additional margin applied in landscape mode - indicated red bar underneath screenshot. <!-- default screen margins, per android design guidelines. --> <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> has else seen or have idea how can rid of them? don't know start, because seems spe

bash - find+xargs: for all files in a dir find pair in other nested dir and move there -

i have directory "images" nested structure, , there .png files somewhere in it. have plain directory "svg" bunch of .svg files in it. need move each .svg file same dir lies .png file same name. this command single given .svg file works: find /images -name 'sample.png' | grep -v thumb | xargs -i{} dirname {}|xargs -0 -i {} mv /svg/sample.svg {} grep -v thumb applied because each .png file there thumbnail file same name in other subdir named "thumb". i tried write command files: find /svg/ -name "*.svg" -exec basename {} '.svg' \; | xargs -o -i {} "find /images/ -name {}" but recieve , error: `basename' terminated signal 13 moreover, if second command works, next step combine first command, here problem: how can send given filename final command "mv" (see {???} in code)? find /svg/ -name "*.svg" -exec basename {} '.svg' \; | xargs -o -i {} "find /images/ -name {}&

oauth - iOS Linked in how to get full profile and connection at same request? -

can full profile details , user connections @ same time through linked in. oauth api i getting user profile details , user connections details in separate request. nsurl *url = [nsurl urlwithstring:@"http://api.linkedin.com/v1/people/~/connections"]; nsurl *url = [nsurl urlwithstring:@"http://api.linkedin.com/v1/people/~:(first-name,last-name,headline,picture-url,email-address,location,id)"]; but when connections details not provide users profile info, vise versa. request parameter used below code oarequestparameter *nameparam = [[oarequestparameter alloc] initwithname:@"scope" value:@"r_fullprofile+r_emailaddress+r_network"]; nsarray *params = [nsarray arraywithobjects:nameparam, nil]; [request setparameters:params]; oarequestparameter * scopeparameter=[oarequestparameter requestparameter:@"scope" value:@"r_fullprofile r_emailaddress r_network"]; [request setparameters:[nsarray arraywithobject:scopepara

c# - Matlab builder NE / MCR on Windows 8 -

i have compiled matlab functions using matlab r2012a .net dll files. , working should. using wpf/c# .net 4.5 on windows 7 64bit , program works ok. however transferring , testing our program on windows 8 pro. have problem in runtime - using of course mcr r2012a in order run .dll files. can't load classes or functions in win8 , our program crashes. have came across problem? if compile functions using matlab r2013a? the solution matlab problem windows 8 add [assembly: mathworks.matlab.net.utility.mwmcroption("-nojit")] in assembly file. i not know why works. nojit- means no in time compiler creates binary file. however when have added this. worked on windows 8 x64 well. same mcr

F# Compilation Error on Windows 8.1 Pro VS 2012 -

i new f# , f# on visual studio. created f# application , created class, when try f# interactive window works fine, when build application gives fallowing 3 errors fsharp.core.sigdata not found alongside fsharp.core fsc error opening binary file 'c:\windows\microsoft.net\assembly\gac_msil\fsharp.core\v4.0_4.3.0.0__b03f5f7f11d50a3a\fsharp.core.dll': fsharp.core.sigdata not found alongside fsharp.core problem reading assembly 'fsharp.core, version=4.3.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a': error opening binary file 'c:\windows\microsoft.net\assembly\gac_msil\fsharp.core\v4.0_4.3.0.0__b03f5f7f11d50a3a\fsharp.core.dll': fsharp.core.sigdata not found alongside fsharp.core please advice me how can sorted. for visual studio 2012 work in windows 8.1 have install vs2012 update 3 after upgrading windows 8.1.

Verilog: use time delay in for loop -

i creating multiple calls module module using generate in loop. need make calls module after few delay rather instantly. unable add using #<time delay> . throwing compilation error like: error: c:\altera\13.0\test.v(53): near "#": syntax error, unexpected '#' could please me out? below code snippet: generate genvar i; (i=0; i<12; i=i+1) begin #10 custom i_custom(clock, reset, in , out); end endgenerate

ruby - Error installing nokogiri 1.6.0 on mac (libxml2) -

update: fixed i found answer in thread. workaround used tell nokogiri use system libraries instead: nokogiri_use_system_libraries=1 bundle install ==== trying install nokogiri 1.6.0 on mac. previous versions, had no problems. 1.6.0 refuses install. error: building native extensions. take while... error: error installing nokogiri: error: failed build gem native extension. /users/josenriq/.rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb extracting libxml2-2.8.0.tar.gz tmp/i686-apple-darwin11/ports/libxml2/2.8.0... error tar: not tar archive tar: skipping next header tar: archive contains obsolescent base-64 headers tar: read 3 bytes /users/josenriq/.rvm/gems/ruby-1.9.3-head@wdi/gems/nokogiri-1.6.0/ports/archives/libxml2-2.8.0.tar.gz tar: error exit delayed previous errors *** extconf.rb failed *** not create makefile due reason, lack of necessary libraries and/or headers. check mkmf.log file more details. may need configuration options. provided configurati

sql - Same queries giving error -

can please explain why first query gives error , second query doesn't? select * employee empdate < '20.06.2013 09:11:00 ' select * employee empdate < '11.04.2013 14:40:00 ' the first query causes error the conversion of varchar data type datetime data type resulted in out-of-range value. really hard understand when passing same date format both queries. column data type empdate datetime . wrong here? i using sql server 2012 in case looks can use: select convert(datetime,'20.06.2013 09:11:00',103) to convert date format proper datetime comparison: select * employee empdate < convert(datetime,'20.06.2013 09:11:00',103) the third parameter of convert() function defining 'style', can see list of formats here: cast , convert - date , time styles

objective c - Method calling itself with identical params -

i have several "proxy" classes, inherit "base proxy". these classes connect server , pass data delegates. in event of 0 status code, want handle these different requests in same way. for 0 status codes, want retry method in 5 seconds, hoping user's internet connection has improved. somethingproxy.m - (void)fetchsomething { nsstring *fullpath = [nsstring stringwithformat:@"%@/route/index.json",my_base_url]; nsurl *url = [nsurl urlwithstring:fullpath]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; afjsonrequestoperation *operation = [[afjsonrequestoperation alloc] initwithrequest:request]; [operation setcompletionblockwithsuccess:^(afhttprequestoperation *operation, id responseobject) { nsdictionary *d = (nsdictionary *)responseobject; [self.delegate fetchedpolicy:d[@"keypath"]]; } failure:^(afhttprequestoperation *operation, nserror *error) { [self handleoperationfailed:o

sql - PHP What is wrong | query sprintf -

$melding1 = "gratulerer, du kom på 1 plass! du vant %s kr og 300 rankpoeng."; $melding2 = "gratulerer, du kom på 2 plass! du vant %s kr og 150 rankpoeng."; $melding3 = "gratulerer, du kom på 3 plass! du vant %s kr og 75 rankpoeng."; $sql->query("insert `innboks` set `til`='".$div->getnickbyid($results[0]['bruker'])."', `fra`='$fra', `emne`='$emne', `dato`='$dato', `innhold`='".sprintf($melding1, number_format($firstprice))."', `lest`='nei', `slettet`='nei'"); $sql->query("insert `innboks` set `til`='".$div->getnickbyid($results[1]['bruker'])."', `fra`='$fra', `emne`='$emne', `dato`='$dato', `innhold`='".sprintf($melding2, number_format($secondprice))."', `lest`='nei', `slettet`='nei'"); $sql->query("insert `innboks` set `ti

Using bash grep -Po regex fails if string has an underscore -

i have searched , gasp read man pages , still can't figure out whats , how fix it... admit being regex newb, no shame! (ubuntu 12.04, bash 4.2.25, gnu grep 2.10) as part of script bunch of other interesting things (which seem work) i'm attempting extract data file names... there expected patterns exist.. example file names have date: date in format "yyyy-mm-dd" handily can grep out whole thing , break down later grepping '\b[0-9]{4}.{1}[0-9]{2}.{1}[0-9]{2}\b' (in fact can safely target year directly '\b[0-9]{4}\b' ) works fine if input string looks either of these: something 1989-07-23 something.jpg" or "foo-2013-01-10-bar.csv but if looks wordsidon'tcareabout_2004-09-14_otherthings.tif or foofoobarbar_2010-07-16.gif grep finds no matches. what gives underscores? why cause regex fail? , there better way go may ignorant of? have ultra-minimal perl , java skills, know way around bash pretty well... or thought did... i sup

jquery - Can't get user id from facebook signedRequest in PHP . -

on index page initialize javascript sdk , go through login/authorization flow. use ajax pass signed request php page parsed. code parsing signed request copied directly documentation, haven't changed anything. @ end of code try user info returned in same object signed request, when try log of variables in ajax success callback, come 'undefined'. //html function oncheckloginstatus (response) { if (response.status != "connected") { //redirect login page; } else { //connected, signed request response object , pass php page via ajax $.ajax({ url : "http://xxxxxxx/bn/signedrequest.php", type : 'post', data: {signed_request: response.authresponse.signedrequest}, success : function (result) { console.log("success"); //this coming undefined console.log(result.uid); }, error : function () {

eclipse - Android - Singly dependencies -

i'm trying integrate android application singly, getting noclassdeffounderror stringutils , used singlyclient. pretty sure issue way configured build path or set sdks facebook , singly. here setup: directory structure: parent-dir/ myapp/ mytestapp/ facebook-android-sdk/ singly-android-sdk/ facebook-android-sdk directory facebook-android-sdk/facebook github repo , , singly-android-sdk directory singly-android/sdk github repo . of these have been imported workspace in eclipse, though not copied. per instructions here , facebook sdk imported via android -> existing code... , singly sdk imported via general -> existing projects... facebook sdk configuration android: ✓ library java build path: source: facebooksdk/gen facebooksdk/src libraries/android private libraries: android-support-v4.jar singly sdk configuration android: ✓ library +-------------------------+-------------+ | reference

Linq xml recursive select -

<nodes> <node> <id>1</id> <tids> <tid>2</tid> <tid>3</tid> </tids> </node> <node> <id>2</id> <tids> <tid>4</tid> </tids> </node> <node> <id>3</id> <tids> <tid>7</tid> </tids> </node> <node> <id>4</id> <tids> <tid>7</tid> </tids> </node> <node> <id>5</id> <tids> <tid>7</tid> </tids> </node> <node> <id>6</id> <tids> <tid>7</tid> </tids> </node> <node> <id>7</id> </node> </nodes> i want write query fselect tid , again query xml select it's tid suppose condition id equal 1 want out put 2,3,4,7 in conditio

javascript - Frame reload not working in Firefox and Chrome -

a frame not reloading in firefox , chrome, works in ie. parent.toolbar.location.reload() my function executes in "builder" frame. have used method before , has worked in browsers...but not anymore, works in i.e. here frame layout <frameset id="frameset" rows="95,*" cols="*"> <frame noresize="" id="toolbar" name="toolbar" src="application/toolbar/<?=$id ?>"> <frameset cols="81%,*"> <frame id="preview" name="preview" src="<?=$preview_url ?>" onload="builder.setpreviewevents()" > <frameset id="tcolor" rows="60,*" cols="*"> <frame id="colorfr" name="colorfr" scrolling="no" src="<?=$colorfr_url ?>" > <frame id="builder" name="builder" src="<?=$builder_url ?>" > <

x86 64 - Where can I find a list of x86_64 assembly instructions? -

here link complete (i think) list of nasm instructions, presume covers x64 bit instruction set intel processors. however, hoping there complete list of instructions somewhere, , that, without verbosity of explanation each one. does such thing exist? useful have learning commands (you can guess of meanings , google ones cant guess), bumping memory when cant remember 1 , scanning appropriate command fill requirement have. here list of instructions: http://ref.x86asm.net as x86(_64) cisc processor, has big instruction set, compilers, unless optimizing, use "small" subset of it. can check disassembling binaries objdump or preferred disassembler.

html - Using JQuery .click and .toggle to contract and expand a concentric circle -

i'm trying expand , contract circle on circle following code: $(document).ready(function(){ $("#inner-circle").click(function(){ $("#inner-circle").toggle( function(){ $(this).transition({ "height":'1.0em', "width":'1.0em', "margin-top":'3.2em', "margin-left":'3.2em' }, 1000); }, function(){ $(this).transition({ "height":'1.875em', "width":'1.875em', "margin-top":'3.75em', "margin-left":'3.75em' }, 1000); } )}); }); $(document).ready(function(){ $("#data1").hover(function(){ $("#data1").toggle( function(){

javascript - Can you have a doubly nested object literal? -

can have doubly nested object literal value of "ingredients" below (is syntax correct)? recipes = [ {name: 'zucchini muffins', url: 'pdfs/recipes/zucchini muffins.pdf', ingredients: [{name: 'carrot', amount: 13, unit: 'oz' }, {name: 'zucchini', amount: 3, unit: 'sticks'}] } ]; and if so, how access "unit" value of "ingredients" objects? could this? psuedocode for each recipes recipe print "this recipe requires" each recipe.ingredients ingredients ingredients.amount + " " + ingredients.unit; (i'm thinking of using javascript) this how can infos need array( here jsfiddle ): function printrecipes(recipelist) { for(var = 0; < recipelist.length; i++) { //loop through recipes var recipe = recipelist[0], //get current recipe ingred

Usage limits for services when used with Google Maps Javascript API v3 -

i'm trying clarify usage limits google maps services (e.g. places, directions, etc) when used google maps javascript api. according official documentation the javascript maps api v3 free service, available web site free consumers and for-profit web sites permitted generate 25 000 map loads per day using google maps javascript api v3. now each google maps service api has own usage limits: places api allows 1,000 or 100,000 (if you're verified) requests per 24 hours. directions api allows 2,500 requests per day in web app i'm using places library , direction service via javascript api. usage limits each service apply when used javascript api? documentation doesn't make clear. yes. usage limit google maps apis affects when your site gets more traffic . each api has own usage limitation. google geocoding service: 2,500 requests per day google maps javascript api : 25,000 map loads per day each service. this includes:

php - Should uploaded files be renamed? -

i've been reading on php file upload security , few articles have recommended renaming files. example, owasp article unrestricted file upload says: it recommended use algorithm determine filenames. instance, filename can md5 hash of name of file plus date of day. if user uploads file named cake recipe.doc there reason rename 45706365b7d5b1f35 ? if answer yes, whatever reason, how keep track of original file name , extension? to primary question, practice rename files, answer definite yes, if creating form of file repository users upload files (and filenames) of choosing, several reason: security - if have poorly written application allows download of files name or through direct access (it's horrid, happens), it's harder user, whether maliciously or on purpose, "guess" names of files. uniqueness -- likelihood of 2 different people uploading file of same name high (ie. avatar.gif, readme.txt, video.avi, etc). use of unique identifie

python - Pop value from if less than x -

i have array of dictionaries for row in array: if row['val'] < 11: array.pop(array.index(row)) in trying remove dictionary array if 1 of values below threshold. works, 1 of items in array my solution right run statement twice, removes value. how should go this? you shouldn't modify collection you're iterating over . instead, use list comprehension : array = [row row in array if row['val'] >= 11] also, let's clear 1 other thing. python doesn't have native arrays . has lists.

ios - Setting UITableViewCell height and the cell's text label based on the text height -

i have followed instructions have been able find on stackoverflow fix following none have worked. below code: - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"doccell"; doccell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[doccell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } // configure cell... cgsize constraintsize = cgsizemake(cell.infolabel.frame.size.width, maxfloat); cgsize labelsize = [_content[[indexpath row] * 2] sizewithfont:[uifont fontwithname:@"helveticaneue-light" size:12.0f] constrainedtosize:constraintsize linebreakmode:nslinebreakbywordwrapping]; cgrect frame = cgrectmake (cell.infolabel.frame.origin.x, cell.infolabel.frame.origin.y, labelsize.width, labelsize.heigh

javascript - What is byte fixed size length? -

i have connect , send message server. needs message length , manual states: message length: fixed size (4 bytes) how fixed length size in javascript/node.js? suppose message is: "hello, hand shake." use buffer: var buffer = new buffer(4, 'hex'); buffer.write('aabbaaaa'); // 10101010 10111011 10101010 10101010 docs: http://nodejs.org/api/buffer.html#buffer_buffer useful nodejitsu article: http://docs.nodejitsu.com/articles/advanced/buffers/how-to-use-buffers

xamarin.ios - Servicestack assembly failing on Xamarin IOS after update -

i've upgraded latest xamarin build , although libraries referenced keep getting these errors: error cs0012: type servicestack.servicehost.ireturn 1' defined in assembly not referenced. consider adding reference assembly `servicestack.interfaces, version=3.9.55.0, culture=neutral, publickeytoken=null' (cs0012) (place.logic) error cs0012: type servicestack.servicehost.ireturn' defined in assembly not referenced. consider adding reference assembly servicestack.interfaces, version=3.9.55.0, culture=neutral, publickeytoken=null' (cs0012) (place.logic) (the monotouch dlls have incorrect version numbers on release builds think) ****update from comments , links , one: xamarin studio ios assembly error it appears dlls need recompiled source if not using particular command line toold. unfortunately, source files on servicestack monotouch source files incomplete , keeps saying: servicestack.text.monotouch (load failed). has managed recompile these , put them

view - Rendering a heterogeneous list of objects in rails that includes arrays -

i have collection of attachments, notes, , array of attachments. example @heterocollection = [attachment, note, note, [attachment, attachment, attachment]] in view attempt render collection <%= render :partial => @heterocollection %> but rails chokes saying array of attachments needs implement :to_partial_path [attachment, ..., attachment] not activemodel-compatible object. must implement :to_partial_path if remove array rendering works great calling _attachment.html.erb , _note.html.erb respective records. is there way implement :to_partial_path on array without monkey patching? or there better solution? you can create class attachmentarray, extend array , add to_partial_path method it. push attachments new instance of class..

What are some scenario where printf() would affect a variable in c? -

i stuck program because of stated problem. when put printf statement before or after assigning computed value array, correct answer. otherwise, it's strange number. number pretty consistent though. printf not have contain relevant array. check answer , did not out of it. below part of code: int xcorr(imdata, kernel, sizeim, sizekernel, result_im) unsigned short** imdata; unsigned short** kernel; long sizeim[2], sizekernel[2]; float** result_im; { register float imstd, imavg, kernelstd, kernelavg, combine_avg, outtmp, area; register int bufysize, bufxsize; int i,j,r,c; register unsigned short *imdataptr, *kernelptr; register float *result; register float val1, val2; // kernel average , standard deviation constant throughout function area = sizekernel[0]*sizekernel[1]; outtmp = kernelavg = 0; // using one-pass standard variance algorithm for(i=0;i<sizekernel[0];i++){ kernelptr = kernel[i]; for(j=0;j<sizekernel[1];j++){ val1 = kernelptr[j];

javascript - acceptable promise pattern for 'LOUD' errors? -

i'm using rsvp library distributed inside ember.js , i'm trying figure out correct pattern reporting fatal errors inside promise -- particularly want inform of that's result of programming error due api misuse , want in loud way. i'm new promises , javascript in general, question makes sense here's simple example (in coffeescript): doasync = (arg, callback) -> throw new error('you gave me way bad arg, fail you!') promisereturningapi = (data) -> return new ember.rsvp.promise (resolve, reject) -> callback = (err, resp) -> if err reject(err) else resolve(resp) doasync(data, callback) now lets i've identified error there's no possible way recover occurred inside doasync -- want make sure error gets reported if caller neglected attach error handler because resulted because caller invoked api function in incorrect way i came across idea of using settimeout within rejection handler ensure error gets raised s

c++ - Poco NetSSL Exception -

i have built poco netssl, first example doesn't work. following snippet throws exception , debugger.h gets opened in ide (visual studio 2012). #include <poco/net/httpsclientsession.h> int main() { poco::net::httpsclientsession clientsession; } this output: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% null pointer: _pinstance [in file "c:\users\domenic\desktop\poco-1.4.6p1-all\util\include\poco\util\application.h", line 446] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% the following code works perfectly... #include <poco/net/httpclientsession.h> int main() { poco::net::httpclientsession clientsession; } i suppose has openssl. can me, want start project. :( if you're using default constructor of poco::net::httpsclientsession (or other constructor not take poco::net::context::ptr), you'll need have instance of poco::util::application, configuration file containing ssl/tls configuration in order create default context object , in