Posts

Showing posts from July, 2011

haskell - Please provide a simple test-framework example that uses QuickCheck2 -

i'm struggling little basic test-framework example work quickcheck2. following error mentioned on above page, due example's use of quickcheck 1. assume using quickcheck2 preferred, how use test-framework? error: no instance (quickcheck-1.2.0.0:test.quickcheck.testable (gen prop)) thanks in advance. if import test.framework.providers.quickcheck2, following error: del-me.hs:41:17: no instance (quickcheck-2.5.1.1:test.quickcheck.property.testable (gen prop)) arising use of `testproperty' possible fix: add instance declaration (quickcheck-2.5.1.1:test.quickcheck.property.testable (gen prop)) in expression: testproperty "sort2" prop_sort2 in second argument of `testgroup', namely `[testproperty "sort1" prop_sort1, testproperty "sort2" prop_sort2, testproperty "sort3" prop_sort3]' in expression: testgroup "sorting group

PHPMailer Body gets truncated -

i'm having strange issues phpmailer. i'm trying send content generate php in html , plain text, body gets truncated. what's stranger happens email generate, if put in there generic content in greater length, gets sent properly. must mention, did echo content of both $content , $nohtmlcontent variables , there should be, when receive email mailbox, it's truncated. my php code creating plain text , html email body: $content="<body bgcolor=\"#ffffff\"><font face=\"verdana\" size=\"2\">"; $content.="hello $name.<br /><br />administrator of <a href=\"http://$url\">$url</a> has created new account you.<br /><br />your new account details:<br />"; $content.=$message."<br /><br />"; $content.="if see wrong, please reply correct details , update account.<br /><br />"; $content.="have nice day,<br />$url

c++ - What is the difference between is_trivially_copyable and is_trivially_copy_constructible? -

when these give different answer, , when difference useful, if @ all? the former tests trivially copyable property, in few words means type memcpy -safe. a trivially copyable class class that: — has no non-trivial copy constructors (12.8), — has no non-trivial move constructors (12.8), — has no non-trivial copy assignment operators (13.5.3, 12.8), — has no non-trivial move assignment operators (13.5.3, 12.8), and — has trivial destructor (12.4). a trivial class class has trivial default constructor (12.1) , trivially copyable. [ note: in particular, trivially copyable or trivial class not have virtual functions or virtual base classes. —end note ] the latter tests presence of trivial copy constructor , incidentally requirement trivially copyable property. implies copy constructor type performs bitwise copy. a copy/move constructor class x trivial if not user-provided , if — class x has no virtual functions

java - Not able to perform String Splitting -

i have string in not able find way out split ever necessary. below scenario. i using java string querystring = "string1=1&string2=2&string3=3&string31=31&string32=32....&string4=4"; i wanted output below string1=1 string2=2 string3=3&string31=31&string32=32.... string4=4 i tried querystring.split("&"); splits string3,strin31,string32...and on well. please me out in this if accept in way snippet it.... but feel not @ recommendable... i'm want remain json ... not suitable requirement. my code here: public static void main(string[] args) { string querystring = "string1=1&string2=2&string3=3&string31=31&string32=32&string4=4"; int count = 1; string queryparam = ""; try{ while(count == 1 || queryparam.length() > 0){ queryparam = querystring.substring(querystring.indexof("string" + count + "="),querystrin

xsd - Why do I get NoneType returned in my python script when an xml tag is missing -

here xml <file> <file_name>test1.fits</file_name> </file> <file> <file_name>test2.fits</file_name> <restricted>1</restricted> </file> here part of xsd <xsd:complextype name="fileinfo"> <xsd:sequence> <xsd:element name="file_name" type="xsd:string" minoccurs="1" maxoccurs="1" /> <xsd:element name="restricted" type="xsd:integer" minoccurs="0" maxoccurs="1" /> </xsd:sequence> </xsd:complextype> and here python code using lxml.etree isrestricted=0 restricted = 0 filename = file.findtext('file_name') restricted = file.findtext('restricted') if restricted not none: isrestricted = int(restricted) the above works looks kludgy. want assign isrestricted either value in xml if there or 0 if it's not there. right i'

How to get the common set of two xpath expressions -

can tell me please how common set of 2 xpath expressions. opposite of union (not |) this well-known kayessian formula (identity) selecting intersection of 2 node-sets $ns1 , $ns2 : $ns1[count(. | $ns2) = count($ns2)] this formula can used in versions of xpath, including 1.0. substitute $ns1 , $ns2 specific xpath expressions select 2 node-sets want intersect.

testing - How to test AngularJS Directive with scrolling -

i have infinite scroll directive trying unit test. have this: describe('infinite scroll', function(){ var $compile, $scope; beforeeach(module('nag.infinitescroll')); beforeeach(inject(function($injector) { $scope = $injector.get('$rootscope'); $compile = $injector.get('$compile'); $scope.scrolled = false; $scope.test = function() { $scope.scrolled = true; }; })); var setupelement = function(scope) { var element = $compile('<div><div id="test" style="height:50px; width: 50px;overflow: auto" nag-infinite-scroll="test()">a<br><br><br>c<br><br><br><br>e<br><br>v<br><br>f<br><br>g<br><br>m<br>f<br><br>y<br></div></div>')(scope); scope.$digest(); return element; } it('should have proper initial structure', function()

c# - Encode a string with accents and money symbols and returns a FileStreamReturn(MemoryStream) MVC -

i have code: stringbuilder output = new stringbuilder(); output.appendline("saldo disposición: 23.15€"); [...] system.text.unicodeencoding en = new unicodeencoding(); byte[] bytearray = en.getbytes(output.tostring()); memorystream stream = new memorystream(bytearray); string filename = guid.newguid().tostring("n").toupper() + ".csv"; stream.flush(); stream.seek(0, seekorigin.begin); return new filestreamresult(stream, "application/vnd.ms-excel") { filedownloadname = filename}; when open document symbol "€" , accent in "disposión" don't appears. seems that: saldo disposici�n: 23.15� does tell me how this? thank you!! the following works me: string filename = guid.newguid().tostring("n").toupper() + ".csv"; memorystream stream = new memorystream(); streamwriter output = new streamwriter(stream, encoding.utf8, 2 << 22); output.writeline("column1,column2&quo

iphone - Alloc class instance -

i have class: @class uiimagepicker; @protocol uiimagepickerdelegate<nsobject> @required - (void)didfinishchooseimage:(uiimagepicker *)picker withimage:(uiimage*)img; @end @interface uiimagepicker : nsobject <uinavigationcontrollerdelegate, uiimagepickercontrollerdelegate> { uiimagepickercontroller *imgpicker; } @property (assign) int type; @property (nonatomic, retain) uiimagepickercontroller *imgpicker; @property (nonatomic,assign) id <uiimagepickerdelegate> delegate; and how alloc imgpicker : -(void)showimagepicker{ imgpicker = [[uiimagepickercontroller alloc] init]; imgpicker.allowsediting = yes; imgpicker.delegate = self; //trigger photo library function if (self.type == 0) { imgpicker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; } else { imgpicker.sourcetype = uiimagepickercontrollersourcetypecamera; } } and how release imgpicker : - (void)dealloc { [imgpicker release],imgpicke

ios - NSManagedObject added to relationship twice -

i have nsmanagedobject a, has many relationship object b. if create object b, , add relationship twice example b = somehow [a addobjectb:b]; [a addobjectb:b]; will graph still consistent or have make sure not duplicate relationship in way? know it's set manages relationship duplicates should not allowed, want make sure. a "to-many" relationship represented nsset , unique. if add object relationship set multiple times appear in relationship once.

.net - LINQ Group By and aggregate fields -

i've struggled grouping in linq, i'd group based on date part of datetime field , aggregate other fields. example table layout mydatefield myintfield1 myintfield2 myintfield3 01/02/2013 5 5 5 01/02/2013 5 5 5 02/02/2013 10 10 10 02/02/2013 10 10 10 i'd return list with mydatefield myintfield1 myintfield2 myintfield3 01/02/2013 10 10 10 02/02/2013 20 20 20 i've managed following using msdn examples can't head around how use it. states should able access new bookedlist group keep getting annonymous type errors , such. dim bestdays = in b a.bookedon < a.eventdaytime , a.cancelled = false group bookdate = a.bookedon.value.date bookedlist = group the syntax into [field_

jsf - Add and delete nodes in primefaces treeTable -

i have this: <p:treetable id="#{treetableid}" value="#{tablebeanroot}" var="element" resizablecolumns="true" selection="#{budgettemplateelementbean.selectednode}" selectionmode="single" widgetvar="#{treetableid}widget"> <f:facet name="header"> </f:facet> <p:column style="width:150px"> ..... </p:column> ..... <f:facet name="footer"> <p:commandbutton value="#{msg.addchildnode}" actionlistener="#{actionbean.addchildnodeaction}" process="@this,#{treetableid}" update="#{treetableid} :growl" /> <p:commandbutton value="#{msg.deletenode}" actionlistener="#{actionbean.deletenodeaction}" process="@this,#{treetableid}" update="#{treetableid} :growl&qu

Laravel 4 blade templates causing FatalErrorException? -

i'm getting unexplained fatalerrorexception when trying implement simple page layout using blade templating. i'm not sure if it's i'm doing wrong or laravel is. i'm following tutorial on l4's documentation templating , code seems follow it. here's code. app/routes.php: <?php route::get('/', 'homecontroller@showwelcome'); app/views/home/welcome.blade.php: @extends('layouts.default') @section('content') <h1>hello world!</h1> @stop app/views/layouts/default.blade.php: <!doctype html> <html> <head> <title>the big bad barn (2013)</title> </head> <body> <div> @yield('content') </div> </body> </html> app/controllers/homecontroller.php: <?php class homecontroller extends basecontroller { protected $layout = 'layouts.default'; public function showwelcome() { $this->layout->c

google maps - ContextMenu in GMap primefaces component -

does know how create primefaces contextmenu launched on right click on gmap? normally code should this: <p:gmap id="gmapelement" widgetvar="gmtls" center="41.381542, 2.122893" zoom="15" type="hybrid" styleclass="mapclass"/> <p:contextmenu for="gmapelement" > <p:menuitem value="method a" onclick="method1()" /> <p:menuitem value="method b" onclick="method2()" /> </p:contextmenu> however, google api overrides right click event. think best way handle additional listener in google map. cannot find information how show context menu programatically: var mapcomponent = gmtls.getmap(); google.maps.event.addlistener(mapcomponent, 'rightclick', function(mouseevent) { //show context menu @ coordinates: mouseevent.latlng }); can tell me should put in listener body? so here answer looking for. during initialisat

iphone - UIPageViewController: display error when user aborts pangesture -

here problem: i've implemented calendar in week mode, navigation between weeks done using uipageviewcontroller in pagecurl mode (quite similar standard calendar of ipad). works except when user aborts page navigation. if calendar showing current week , user pan finger show next week aborts gesture , doesn't turn page, datasource still display next week instead of staying @ current week. i tried using method - (void)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller didfinishanimating:(bool)finished previousviewcontrollers:(nsarray*)previousviewcontrollers transitioncompleted:(bool)completed and detecting when pangesture aborted , manually reset previous viewcontroller result not @ all. here code datasource , delegate methods - (uiviewcontroller *)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller viewcontrollerbeforeviewcontroller:(uiviewcontroller *)viewcontroller { if (_pagei

uibezierpath - Rounded bottom edge of UIView -

in app have subclassed uinavigationbar , titleview i'm setting(in view controller) custom uiview [self.playbutton setbackgroundcolor:[uicolor yellowcolor]]; [self.navigationitem settitleview:self.playbutton]; the bottom edge of view (playbutton) should curved. not corners, bot whole bottom edge.to achieve effect i'm using code: cashapelayer *masklayer = [cashapelayer layer]; uibezierpath *path = [[uibezierpath alloc] init]; [path addcurvetopoint:cgpointmake(self.playbutton.frame.size.width, self.playbutton.frame.size.height) controlpoint1:cgpointmake(0, self.playbutton.frame.size.height) controlpoint2:cgpointmake(self.playbutton.frame.size.width, 60)]; masklayer.path = path.cgpath; self.playbutton.layer.mask = masklayer; but after code uiview (playbutton) dissapeared! proper way apply curved bottom edge of uiview? it should looks this: http://i.imgur.com/51uiqse.png solution: -(void)roundcorners:(uirectcorner)corner radius:(float)radius { _corn

algorithm - Finding recursive sum in SQL statement -

i've 2 tables , b like: a (id, dep_id) , b (id, amount) the data in tables this a b id dep_id id amount --- ------- ---- -------- 1 2 1 100 2 3 2 200 3 null 3 300 4 null 4 400 the id column in table holds id table b. given id in table a, there might dep_id holds id of table b. the requirement calculate sum of amount of entry in b , of dependent entries. has done in 1 single sql query. can't use pl/sql block that. idea how that. example: sum(id=1) = 100(id=1,dep_id=2) + 200(id=2,dep_id=3) + 300(id=3) = 600 you can use connect root build link of dependency ( hierarchical query ), aggregate: sql> select id, sum(amount) 2 (select connect_by_root(a.id) id, b.amount 3 4 join b on a.id = b.id 5 start a.id = 1 6 connect prior a.dep_id = a.id) 7 group id; id sum(amount) ---------- --

iphone - Get access for native camera, photoes, calendar and voice recording with IBM Worklight -

i have build cross platform application(for iphone , android only) , want use ibm worklight this. i'd know possible access native camera, photoes, calendar , voice recording iphone , android. in advance. yes. since ibm worklight utilizes apache cordova (also known "phonegap"), allows access have requested using javascript apis provided cordova. see complete api cordova v2.3 (the version worklight 5.0.6.1 supports) list of supported features. to see how works in conjunction worklight, have @ ibm worklight getting started training material , , more specifically: adding native functionality hybrid apps apache cordova .

user controls - Silverlight usercontrol pain -

i have usercontrol in lib mycompany.silverlight.dll namespace same - mycompany.silverlight works, can drag-drop control toolbar navigation pane. now removed control pane, changed namespace of control mycompany. compiled. when tried drag-drop navigation pane got message - enumerator not valid because collection changed. i didnt change except of namespace. what problem ? thx looks bug in vs. guess async project structure data update occurred while designer populating toolbox. try restarting vs , rebuilding solution.

javascript - Draw image with x,y relating to the center point for the image? -

i'm trying draw image @ co-ordinate points x,y x , y being in center of image. i have code found earlier rotating image: function drawimagerot(img,x,y,width,height,deg) { //convert degrees radian var rad = deg * math.pi / 180; //set origin center of image context.translate(x + width / 2, y + height / 2); //rotate canvas around origin context.rotate(rad); //draw image context.drawimage(img, width / 2 * (-1), height / 2 * (-1), width, height); //reset canvas context.rotate(rad * ( -1 ) ); context.translate((x + width / 2) * (-1), (y + height / 2) * (-1)); } however seems draw image below , right? i.e. x,y co-ordinates relate top left corner of image? at beginning of method translates context top-left center. if want pass in center of image. can skip step, resulting in following code. function drawimagerot(img,x,y,width,height,deg) { //convert degrees radian var rad = deg * math.pi / 180; //set origin center of image context.tra

fadein - CSS transition fade in only for element -

is there way fade in element using css transition property? never had need before haven't looked it, , can't seem find method of doing without resorting js. possible set transition have immediate return state? there couple ways this, depending on when want fade in occur: jsfiddle /***** fade in on page load *****/ .fadeinload { border: 1px solid #48484a; font-size: 40px; animation: fadeinload 5s; } @keyframes fadeinload { { opacity:0; } { opacity:1; } } /***** fade in child when parent hovered *****/ .fadein { border: 1px solid #48484a; font-size: 18px; opacity:0; -webkit-transition : 2s ease-out; -moz-transition : 2s ease-out; -o-transition : 2s ease-out; transition : 2s ease-out; } .thistext:hover .fadein { opacity: 1; } note: fade in on page load need simple keyframe animation, not transition.

sql server - How to loop through a select statement? -

this question exact duplicate of: how loop through stored procedure recordset? 2 answers i have select statement declare @t table (percentage float) declare @acc int set @acc = 1 declare @max int select @max = max(hireid) newhire while (@acc <= @max) begin if (@acc in (select hireid newhire)) begin try insert @t select cast((select count(*) hire_response hireid = @acc , (hireresponse = 0 or hireresponse = 1)) float) / cast((select count(*) hire_response hireid = @acc) float) end try begin catch insert @t select 0.0 end catch set @acc = @acc + 1 end select * @t in code, looping through newhire records id, 1 highest one. realized not want anymore. have stored procedure called sp_sele

ios - SKStoreProductViewController showing up with delay -

i use in app skstoreproductviewcontroller . shows correctly, few seconds of delay, slows down user experience. is there wrong in code ? or should inform user vc loading ? because right 1 can believe nothing happening after pressing button (which triggers following code) : -(void)launchapp:(id)sender { // recall on main thread if necessary if (![nsthread ismainthread]) { [self performselectoronmainthread:@selector(launchapp:) withobject:sender waituntildone:no]; return; } // initialize product view controller skstoreproductviewcontroller *storeproductviewcontroller = [[skstoreproductviewcontroller alloc] init]; // configure view controller [storeproductviewcontroller setdelegate:self]; [storeproductviewcontroller loadproductwithparameters:@{skstoreproductparameteritunesitemidentifier : @"*********"} completionblock:^(bo

azureservicebus - Use Hybrid API in Azure Service Bus Queues -

is possible use messaging api send message queue , receive using wcf integration (netmessagingbtinding) , if how ? service contract ? offir here guide on how that.

c# - Visual Studio: Debugging a referenced DLL, I have source in another SLN -

i trying debug project has reference dll added, dll stored in external directory , added reference. of course can debug project line calls method on other dll can't step it, i.e. f12. one way able add project (dll) existing project solution , replace referenced dll use attached project rather file on disk. but mess, sure there cleaner way? i seem remember if copy pdb files or can't remember. , need open 2 copies of visual studio, 1 main project , 1 referenced dll?? rebuild second solution in debug mode on own machine (so file paths in pdb specific machine). copy both .dll , .pdb files references folder. visual studio pick .pdb file automatically , use file paths show source. you can use symbol server , source server achieve when referenced assembly built elsewhere: http://msdn.microsoft.com/en-us/library/vstudio/ms241613.aspx

javascript - Hiding a DIV in a JQuery Overlay Window -

taking code found here: http://jquerytools.org/demos/overlay/external.html i got popup window work , wanted prevent header displaying in overlay popup window. i've added $('#header').hide(); script below not working. sorry im not familiar javascript. great! $(function () { // if function argument given overlay, // assumed onbeforeload event listener $("a[rel]").overlay({ mask: 'grey', effect: 'apple', onbeforeload: function () { // grab wrapper element inside content var wrap = this.getoverlay().find(".contentwrap"); // load page specified in trigger wrap.load(this.gettrigger().attr("href")); $('#header').hide(); } }); }); i did quick test, , think issue you're trying hide header before renders on page. overlay configuration has event called onload, better place ensure loading of external

ruby - Why don't my regex scans work? -

i have script scans text file , puts csv file. grabs debtor information, puts creditor information following it. the problem is, gets each debtor puts same creditor information each debtor , it's not getting new information below debtor : fastercsv.open('data.csv', 'a') |csv| debtor_info = results.scan(/^(\d{2}\-\d{5})(\s+)(.*)(\s+)(total:)(\s+)(\$(\d+\,? \.?)+)/) debtor_info.each |line| case_number = line.at(0) debtor = line.at(2).strip total_amount = line.at(6) csv << [case_number, debtor, total_amount] creditor_info = results.scan(/((\d{1,2})\/(\d{1,2})\/(\d{1,4}))\s+(\$(\d+\,?\.?)+)\s+(\d{1,5}bk)\s+(.*)/) creditor_info.each |info| date = info.at(0) amount = info.at(4) fund_number = info.at(6) creditor = info.at(7) empty = " " csv << [empty, date, amount, fund_number, creditor] end end end this sample input: 00-000## company inc

php - Replacing a plaintext user table with a view -

we inherit things, worse others. recently inherited user table has plaintext passwords. isn't big deal table connected many webapps -- of can't expect find without them breaking , people complaining first. i'd encrypt password column without needing modify connection strings or hardcoded sql of these mystery apps. thinking possible authenticate 2 ways replacing table mysql view uses 'or' clause. idea encrypted_sql_check or plaintext_sql_check, plaintext sql check looks md5(plaintextpw, salt) or somesuch, running plaintext submission through crypter salt used , checking match. i'm not dba though, codemonkey spitballing ideas. feasable? run issues insert/update/etc queries? in other words... can tell me why won't work? database table serve drupal users table, if there's reason throw kink things know. thanks! a view in database read-only, yes, run problems when trying update or insert values through such view. working on original table

clojure - Improve performance of a ClojureScript program -

i have clojurescript program performs math calculations on collections. developed in idiomatic, host-independent clojure, it's easy benchmark it. surprise (and contrary answers suggest which faster, clojure or clojurescript (and why)? ), same code in clojurescript runs 5-10 times slower clojure equivalent. here did. opened lein repl , browser repl @ http://clojurescript.net/ . tried these snippets in both repls. (time (dotimes [x 1000000] (+ 2 8))) (let [coll (list 1 2 3)] (time (dotimes [x 1000000] (first coll)))) then opened javascript console @ browser repl , wrote minimalist benchmark function, function benchmark(count, fun) { var t0 = new date(); (i = 0; < count; i++) { fun(); } var t1 = new date(); return t1.gettime() - t0.gettime(); } back browser repl: (defn multiply [] (* 42 1.2)) then try both native javascript multiplication, , clojurescript variant in javascript console, benchmark(1000000, cljs.user.multiply); ben

java - Difference between SKIP_SIBLINGS and SKIP_SUBTREE -

is aware of difference between these 2 filevisitresult ? directly this oracle tutorial: skip_subtree – when previsitdirectory returns value, specified directory , subdirectories skipped. branch "pruned out" of tree. skip_siblings – when previsitdirectory returns value, specified directory not visited, postvisitdirectory not invoked, , no further unvisited siblings visited. if returned postvisitdirectory method, no further siblings visited. essentially, nothing further happens in specified directory. it seems answered own question if explanation on oracle's tutorial didn't clear doubts, javadoc says: skip_subtree continue without visiting entries in directory. result meaningful when returned previsitdirectory method; otherwise result type same returning continue. skip_siblings continue without visiting siblings of file or directory. if returned previsitdirectory method entries in directory skipped , postvisitdire

How do I declare the type of a variable inside a function in Haskell? -

this reframe of question asked @ defining variables inside function haskell i have function beginning of looks this: recursivels :: filepath -> io [filepath] recursivels dir = folderexists <- doesdirectoryexist dir if folderexists ... the question is, how can explicitly declare type of folderexists before assign in action? well, let's try want in ghci : > (a :: integer) <- return 10 <interactive>:2:7: illegal type signature: `integer' perhaps intended use -xscopedtypevariables in pattern type-signature so, should enable pragma. > :set -xscopedtypevariables and try again > (a :: integer) <- return 10 :: integer now have a equal 10 , integer : > 10 :: integer also, believe you've forgot = in recursivels function, there should recursivels dir = ...

sbt - How to overcome "there were 1 feature warning(s); re-run with -features for details" -

i new scala, scala-ide, , play 2.1 , working way through tutorials. today noted eclipse project emitted "todolist" tutorial shows in scala-ide warning don't understand , see go away. this answer how more information 'feature' flag warning? suggests need add... scalacoptions ++= seq(... "-feature") ...to sbt build definition file which, thought, project/build.scala play 2.1 project. trying put in there, however... import sbt._ import keys._ import play.project._ object applicationbuild extends build { val appname = "todolist" val appversion = "1.0-snapshot" val appdependencies = seq( // add project dependencies here, jdbc, anorm ) val main = play.project(appname, appversion, appdependencies).settings( // add own project settings here scalacoptions ++= seq(... "-feature") ) } ..., results in compile error... [info] loading project definition /users/bobk/work/

c - How can I make a "binary process tree"? -

i have number of process create. every son has create 2 sons. used recursive solution, works number of process created aren't want. this tried: void generate_kid(int g, int res){ pid_t kid1, kid2; int status1, status2; if( res > 0 ){ if( kid1 = fork() ){ if( res > 0){ if( kid2 = fork() ){ } else { printf("i %d, father %d\n",getpid(),getppid()); generate_kid(g,res/2-1); } } } else { printf("i %d, father %d\n",getpid(),getppid()); generate_kid(g,res/2-1); } } waitpid(kid1,&status1,0); waitpid(kid2,&status2,0); } try this: void generate_kid(int res){ pid_t kid1, kid2; int status1, status2; if( res > 0 ){ if ((kid1 = fork()) == 0) { // child printf("i %d, father %d\n",getpid(),getppid()); // generate half remaining rounded odd processes generate_kid((res-1)/2); } else if (kid

sql - jQuery - changing XML & passing it (changed) to a function -

i have following jquery code in function. var msgxml = "<xmlinput><source></source><messagetext></messagetext><sendtime></sendtime><destination></destination><notused></notused></xmlinput>", msgxmldoc = $.parsexml(msgxml), $msgxml = $( msgxmldoc ), $msgsource = $msgxml.find("source"), $msgtext = $msgxml.find("messagetext"), $msgstime = $msgxml.find("sendtime"), $msgdest = $msgxml.find("destination"); in function, need make changes each of nodes in xml, , when complete, pass changed xml ajax call that take xml input sql stored procedure. in code below, can append xml values $msgxml.children(0).append($msgsource.text(mysource)); $msgxml.children(0).append($msgtext.text(mymsg)); $msgxml.children(0).append($msgstime.text(currtimestring)); $msgxml.children(0).append($msgdest.text(mydest)); but changes xml structure (i not set field <notused></notu

In Eclipse, what plugin/class provides the style formatting on Java code? -

Image
as type java code in eclipse, viewer colors, emboldens, italicizes, fades, , provides styles java code type it, seen in picture: what implementing these effects? is eclipse plugin? can identify (and tell me how identified it)? furthermore can narrow down class? select "peferences" eclipse menu. go java -> code style -> formatter preferences can set @ project level. incase planning on writing own formatting code, take @ "workspace mechanics" plugin.

Goals not working Google Analytics -

i have following url: http:// domain.com/subdirectory/ website. have set goals in 3 different ways , none seems work. 1- /subdirectory/goal.php 2- /goal.php 3- goal.php notice settings in traffic info website not full url domain.com have shared hosting web want track under http:// domain.com/subdirectory/ google did job explaining exact problem here: https://support.google.com/analytics/answer/1033158?hl=en most "the goal page not tagged tracking code".

find and edit a txt file with a batch program -

i want edit txt file batch script. have looked online , tried adjust examples suit needs. have no programing skills , have not been able program work. here problem. have txt file contains @ point in file: subcase mode buckling eigenvalue 321043 1 2.124238e+00 321043 2 2.169874e+00 321043 3 2.628187e+00 321043 4 2.832127e+00 321043 5 2.968359e+00 321043 6 3.131774e+00 i want change this: r e l e g e n v l u e s subcase mode buckling eigenvalue 321043 1 2.630623e-01 321043 2 2.676471e-01 321043 3 2.982211e-01 so add "r e l e g e n v l u e s" 2 lines before "subcase mode buckling eigenvalue", without deleting whats in lines before. i.e add 2 new lines in. i have tried following, printed out first 8 lines new text file @echo off /f "tokens=* delims=" %%a in (le_panel_7_cut down_i.out) call :change "%%a" exit /b :change set

Java Event Listeners -

i'm trying separate components of java desktop app different classes. example, have menubar class, called mainclass, creates jmenubar. normally, implement actionlistener in menubar class , override actionperformed() keep organized. if that, how can let mainclass know clicked? i tried implementing own actionlistener, couldn't come solution capable of dispatching events other classes. mainclass.java public class mainclass extends jframe { private static void createandshowgui() { jframe.setdefaultlookandfeeldecorated(false); jframe frame = new jframe("main window"); frame.setdefaultcloseoperation(jframe.exit_on_close); menubar menubar = new menubar(); jmenubar mb = menubar.createmenu(); frame.setjmenubar(mb); frame.setsize(400,400); frame.setvisible(true); } public static void main(string[] args) { swingutilities.invokelater(new runnable() { public void run

python - NLTK pos_tag ImportError from mtrand import * -

when run code error (below): import nltk sentence = """at 8 o'clock on thursday morning""" tokens = nltk.word_tokenize(sentence) nltk.pos_tag(tokens) the traceback is: traceback (most recent call last): file "<pyshell#5>", line 1, in <module> nltk.pos_tag(tokens) file "c:\python27\lib\site-packages\nltk\tag\__init__.py", line 99, in pos_tag tagger = load(_pos_tagger) file "c:\python27\lib\site-packages\nltk\data.py", line 605, in load resource_val = pickle.load(_open(resource_url)) file "c:\python27\lib\site-packages\numpy\__init__.py", line 171, in <module> import random file "c:\python27\lib\site-packages\numpy\random\__init__.py", line 99, in <module> mtrand import * importerror: dll load failed: application has failed start because side-by- side configuration incorrect. please see application event log or use command-line sxstrace.ex

Python Program to Match Lines in File -

i trying write program in python reads through .txt file , checks if line[i] == line [i+12]: print line[i] so far, have: f=open('file.txt', "r") count=0 line in f: while count < 1000: print(count) if line(count) == line(count+12): print (line(count)) count+=1 my output 1000 zeros. any appreciated. if you're trying print lines character same 1 12 characters later: for line in f: i, c in enumerate(line[:-12]): if c == line[i+12]: print(line) break if you're trying print lines same 1 12 lines later, it's simpler in need 1 loop, more complicated in have iterator of lines, not list, can't randomly access this. one simple fix that, if file small enough, make list: lines = list(f) i, line in enumerate(lines[:-12]): if line == lines[i+12]: print(line) a better fix use itertools create shifted copy of iterator (which work eithe

javascript - Moving an array element from [1] to [0] -

you'd think it'd easiest thing in world, can't find solutions don't involve complications don't need or use approaches don't understand. i have array of objects in unity, 3 positions in array. each time script run, among other things, cube in question set [1], new cube created in front of cube , set [2], , previous cube, if there one, set [0]. result of this, array should updating cubes activated player shifting down array. works fine in respects except [0] keeps returning null on debug. since cube before 1 in question set [1], first step in code change [0]/ i've been trying with; objectlist[0] = objectlist[1]; // demotes current object[1] [0]. i understand many people have been writing own functions , using splice method avoid running out of array space, don't need kind of complexity. need set object in position [1] position [0]. hope i'm not missing simple keyword in api or anything. i think you're trying remove front-mos

jquery - Added data (size undefined) does not match known number of columns (9) -

okay, 1 driving me nuts. i'm trying create jquery datatable , keep getting error: datatables warning (table id = 'properties'): added data (size undefined) not match known number of columns (9) i have table set 9 columns (i.e. 9 <th> blocks in html) the javascript appears alright (though if verify sure): $tableproperties = $('#properties').datatable({ sdom: '<"datatables_header"<"datatables_toolbar">rl>t<"datatables_footer"ip>', olanguage: { slengthmenu: "show _menu_ lines", sinfo: "showing _start_ _end_ of _total_ lines" }, idisplaylength: <%: shusterconnect.configurationsettings.mgtpropertiesperpage %>, alengthmenu: [[10, 20, 50, -1], [10, 20, 50, "all"]], bpaginate: true, spaginationtype: "listbox", blengthchange: true, bfilter: false, binfo: true, bautowidth: true, bprocessing: true, bserverside

Android Intent for Capturing both Images and Videos? -

Image
is there intent starting camera options capture both pictures , videos on android? i've used both mediastore.action_video_capture , mediastore.action_image_capture capture either audio or video, can't find intent option switching between both of them, in example app: thanks! i capture both image , video using below code. intent intent = new intent(mediastore.intent_action_still_image_camera);

iphone - Restkit 0.20 objects are not mapped after getting json response -

i'm using restkit 0.20. i'm trying download json response local rails application , save core-data. tried follow https://github.com/restkit/rkgist/blob/master/tutorial.md , worked fine. wanted use many times made base class(listcontroller) , subclassed sessionlistcontroller , eventlistcontroller. mapping provided in appdelegate.m. the app has first viewcontroller root controller maps responses , works fine. change viewcontroller response , operation stops. does't if mapping has started. i'm not sure have missed. here i'm initialising restkit appdelegate.m #import "appdelegate.h" #import <uikit/uikit.h> @implementation appdelegate rkentitymapping *evententitymapping,*sessionentitiymapping; - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { nserror *error = nil; nsurl *modelurl = [nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"event" oftype:@"

Merge conflict when running 'git rebase' -

i on developer branch, , try execute git rebase remote/a_remote_branch see: first, rewinding head replay work on top of it... applying: change #1 failed merge in changes. patch failed @ 0001 change #1 my question why git rebase trying apply 'change #1'? this because when git log , see 'change #1' in local branch, why git trying apply 'change #1' again when rebase? the difference between merge , rebase rebase trying make based branch on newer version of parent branch. removes of branch commits, fast-forwards the latest parent commit, , tries re-apply changes. hence re- basing . if merge makes new commit pulls in of parent changes on top of work. conflicts (if any) in merge commit rather in existing branch work.

c# - how to open new window in new tab with dynamic url -

i have page drop down list , have open new window selected iteam's edit form protected void dropdownlist1_selectedindexchanged(object sender, eventargs e) { this.entitygrid.columns.clear(); entityname.text = dropdownlist1.selecteditem.text; newentity.visible = true; newentity.text = dropdownlist1.selecteditem.text; ... } the following works protected void newentity_click(object sender, eventargs e) { var entity = newentity.text; response.redirect(entity + "edit.aspx"); ... } but how can open in separate tab not new window. open separate window client feature, need "inject" javascript tells browser this. response.write( string.format( "<script>window.open('{0}','_blank');</script>", entity + "edit.aspx")); the parameter _blank tells windows.open function open new window

php - Page Does Not Recognize SESSION -

i have come along not solve long. have created script in php unsets 1 single session variable, page stats session here code page : <?php session_start(); require_once("../header.php"); if($_session['user']) { unset($_session['user']); echo "you succesfully logged out."; header("refresh:5; url=http://www.webmasteroutlet.com"); } else { echo "you not logged in right now."; } require_once("../footer.php"); ?> that whole code on page. , prints out "you not logged in right now." $_session['user'] assigned true in login.php page , have session_start(); @ beginning of page right after <?php opening. session variable recognized @ other files php extension , single file not working on. tried <?php session_start(); echo $_session['user']; ?> and not print anything. skips line , nothing. doing wrong ? thank help. head

asp.net mvc - How to connect to Restful Service using mvc -

i have created basic rest service using mvc web api. trying connect service using mvc 4 right struggling, best way. know of tutorial show how connect restful service using mvc 4? you use webclient , restsharp , servicestack , etc. you have many ways it... have decide 1 better specific app. hope helps.

loops - looping not working javascript -

how can loop imm(imacros) script javascript can me ? macro += "url goto=http://test.com/" + "\n"; macro += "set !errorignore yes" + "\n"; macro += "set !timeout_page 10" + "\n"; macro += "set !extract null " + "\n"; macro += "wait seconds=1" + "\n"; macro += "tag pos={{i}} type=a attr=id:like-*" + "\n"; macro += "wait seconds=0.5" + "\n"; macro += "wait seconds=360" + "\n"; for(i=1;i<10;i++) { ret=iimset("i",i); ret=iimplay(macro); } var macro; macro = "code:"; macro += "url goto=http://test.com/" + "\n"; macro += "set !errorignore yes" + "\n"; macro += "set !timeout_page 10" + "\n"; macro += "set !extract null " + "\n"; macro += "wait seconds=1" + &q

eclipse - How do I resolve this " No such property [target] in org.apache.log4j.FileAppender" and "No output stream or file set for the appender named" error? -

Image
i managed log4j consoleappender work in eclipse, when change appender fileappender these red error messages coming out(even though altered properties file directed tutorial ) : log4j:warn no such property [target] in org.apache.log4j.fileappender. log4j:warn file option not set appender [file]. log4j:warn using fileappender instead of consoleappender? log4j:error no output stream or file set appender named [file]. here pic thank much as error trying tell you, fileappender has file option, not target option.

Facebook Login using Javascript SDK does not give extended access token -

so, facebook's documentation regarding access tokens says: apps using facebook sdks javascript, android , ios, desktop apps or apps using server-side login flow automatically generate long-lived user access tokens. but i'm using facebook javascript sdk, , i'm using regular old fb.login , access tokens have 1 hour expiration times. does know deal this? bug on facebook's side? documentation wrong? there magic way call fb.login causes grant extended access token?

optimization - Handling optional/empty data in MongoDB -

i remember reading somewhere mongo engine more confortable when entire structure of document in place in case of update, here question. when dealing "empty" data, example when inserting empty string, should default null , "" or not insert @ ? { _id: objectid("5192b6072fda974610000005"), description: "" } or { _id: objectid("5192b6072fda974610000005"), description: null } or { _id: objectid("5192b6072fda974610000005") } you have remember description field may or may not filled in every document (based on user input). introduction if document doesn't have value, db considers value null . suppose database following documents: { "_id" : objectid("5192d23b1698aa96f0690d96"), "a" : 1, "desc" : "" } { "_id" : objectid("5192d23f1698aa96f0690d97"), "a" : 1, "desc" : null } { "_id"