Posts

Showing posts from February, 2014

How to create Java REPL with Java.exe and Javascript? -

Image
i want create java repl web application need know techniques , ideas it so need help, can see images c# intractive shell (i need java like) http://csharppad.com/ seems created jqueryui & c# compiler !!! how can have intelisense ? (javascript autocomplete ???) how can fetch keywords types (method,class,interface,...) intellisense ? (current , new libraries) how can have realtime error checking ? how can have documentation in intelisense ? (current , new libraries) 4.1. can fetch them javadocs ? how can method overloads ? 5.1. can fetch them javadocs ? can me develop ? i need ideas because don't know how start , libraries must have ? i think have created here: https://github.com/lorenzoongithub/nudge4j using browser web console can write nashorn/javascript manipulate java objects in running jvm.

java - nested EJB not rolling back -

simple application service throws exception: @stateless public class appservice { @inject private repository repo; @inject private appservice2 service2; public void createfoo(string name) { foo foo = new foo(repo.nextidentity(), name); repo.save(foo); // service2.createbar(name); throw new runtimeexception("asdf"); } } repository @stateless , appservice2 similiar appservice . when throw exception above foo rolled - ok. when call service (the commented), bar not persisted db foo persisted. why foo not rolled after calling service? edit i found appservice2 making checking query db before saving bar public void createbar(string name) { if (repo.find(name) != null) ... bar bar = new bar(repo.nextidentity(), name); repo.save(bar); } and query interrupting transaction. when set @transactionattribute on method @transactionattribute(transactionattributetype.not_supported) public

php - Problems with my wordpress template made with bootstrap -

i have been developing site prelaunching campaign of our product on kickstarter. had coded site in bootstrap , ported wordpress. the thing installed wordpress prelaunchr plugin. when try add shortcode [prelaunchr] , update page, appears nothing new on it. any kind of hint appreciated. i have checked plugin other wordpress themes , there no problem root of problem bootstrap ported template. (here site, thing left input email thing prelaunchr generates) www.pysmile.com

Upgrade MySQL 5.6 to 5.7 -

i'm quite new mysql , learning fast. installed wamp on system , have been using month or so. i'm looking upgrade mysql 5.7 in need of new gis features can't find easy follow step step on need do. i have been reading on @ mysql on how done find either confusing or incomplete, not sure which. have been reading last 6 hours , still no closer knowing how done. i have backed databases, i'm not concerned @ point still in development , learning state , rebuilt anyways. how upgrade 5.6 5.7 full instructions? download zip version of mysql want run ( not msi installer, because dont know may or assume when installs ) suggested source [www.mysql.com] from wamp manager, stop services. go c:\wamp\bin\mysql\ , create new folder named appropriately i.e mysql5.5.28 unzip mysql , copy contents of mysql folder newly created folder. make sure directory levels same existing mysql folder. copy contents of previous mysql\mysql5.5.10\data folder new data folder under ne

angularjs - angular input[date] ng-model format -

when use input[date] in angular, input format dd/mm/yyyy value of ng-model in format yyyy-mm-dd. is possible change format of value dd/mm/yyyy? <input type="date" ng-model="date" class="dateinput"/> you can use angular-ui-mask change format [dd/mm/yyyy] ui-mask='99/99/9999' .

Using ColdFusion variable with line breaks in JavaScript -

i have text area accepts line breaks. content of text area saved in coldfusion variable (lets call #fieldval# ). so, variable contents textline 1 textline 2 later on, use variable in javascript document.all.fieldname.value = "#fieldval#"; however, when javascript hits page, looks this: document.all.fieldname.value = "textline 1 textline 2"; and script breaks because first line doesn't end in semicolon. i tried setting javascript variable coldfusion text doing replace() , still hit same issue line not ending correctly. i think i'm missing obvious not seeing it. can tell me i'm missing here? use jsstringformat() function. designed escape meta characters in javascript escapes special javascript characters, such single-quotation mark, double-quotation mark, , newline. https://wikidocs.adobe.com/wiki/display/coldfusionen/jsstringformat document.all.fieldname.value = "#jsstringformat( fieldval )#"; if you&#

amazon web services - Get aws lambda response as an HTML page -

how can aws lambda response html page. please provide step wise procedure solve this. store html markup in variable , return avoid text being wrapped in quotes. first store html markup in variable in lambda function return it. example in node.js: context.succeed({ variablehtml: mycontenthtml }) here example of mapping template: #set($inputroot = $input.path('$')) $inputroot.variablehtml . here variablehtml contains html markup passed lambda function. after needed create response model http status, accessible through method response. here set response model content-type text/html. you'll html page without quotes , browser recognizes html.

Importing Data from CSV file into MySQL, Scientific Notation -

i using load data infile read csv , insert mysql table. problem 1 column in csv in scientific notation , when read , loaded table won't go column of type double, float, or real. there solution this? 114,2015-05-11 00:00:00.000,0,100,14,2.576927e+10,1.730594e+10,1.904524e+10,1.788426e+10,69.40149 in 1 row of csv scientific notation values when loaded via load data infile become 100000

c# - The function 'CreateTime' is not supported by SQL Server Compact -

i wanted change code-first project sql server compact 4.0. but have problem following linq expression db.test.orderby(t => t.name) .thenby(t => t.dayofweek) .thenby(t => dbfunctions.createtime(t.timefrom.hour, t.timefrom.minute, t.timefrom.second)) it throws following error the function 'createtime' not supported sql server compact is there way write expression without using createtime method? i'm using code-first sql server compact. in model have property called timestamp of type datetime. @ do: db.test.orderby(t => t.name) .thenby(t => t.timestamp.dayofweek) .thenby(t => t.timestamp.hour) .thenby(t => t.timestamp.minute) .thenby(t => t.timestamp.second) .thenby(t => t.timestamp.millisecond); or db.test.orderby(t => t.name) .thenby(t => t.timestamp.ticks);

How to re-insert record with counter column after delete it in Cassandra? -

i create table counter column in cassandra, : create table test_count( pk int, count counter, primary key (pk) ); and after update record like: update test_count set count = count + 1 pk = 1; then want reset count 0, there's no reset command in cql, delete record: delete test_count pk = 1; and re-execute update cql, when select * test_count , there's no record pk = 1 , bug of cassandra? when delete record counter column, disappears forever? how can reset count column 0? how can re-insert record counter column? you can first query counter current value , issue update subtract amount. you can delete counter, , start new counter using different row key. no longer try use original counter. approach might want partition counters day or week, when new day started, you'd start fresh set of zeroed out counters.

excel - Comparing two adjacent cells -

**a1 b1 comparison** a,b,c a,b,c equal b,c,d d,e,f not equal b,a,c a,b,c equal e,f,g e,f,g equal how this? if letters(separated comma) in cell not in proper order, show equal if bolth adjacent cells have same letters. if first 3 values in cell a1 , 1 comparison in cell b1 . paste following formula cell c1 : =and(iferror(find(mid(a1,1,1),b1)>0,false),iferror(find(mid(a1,3,1),b1)>0,false),iferror(find(mid(a1,5,1),b1)>0,false)) that work well.

c# - GridView - Dynamic Button Control Click Event Not Firing - Sometimes -

i have 2 gridviews on single page, each gridview modified in code-behind group using rowdatabound , within rowdatabound adding textbox , button each grouping. button added click event. also, each gridview in updatepanel. in order around postback issue rowdatabound items , dynamic controls have added simple response.redirect same page. code works buttons stop firing click event half way down gridview list. after half way mark click acts initiating postback instead of firing click event, gives same results problem of rowdatabound information being stripped out. from can tell, click event not being called. code have. protected void gridviewrowdatabound(object sender, gridviewroweventargs e) { nonpaidclb.visible = true; if (e.row.rowtype == datacontrolrowtype.datarow) { datarowview drv = (datarowview)e.row.dataitem; if (tmpcategoryname != drv["num"].tostring()) { string usetable = "";

.net - Why Microsoft does not use Entity Framework on their products? -

i wondering why microsoft doesn't use entity framework on products service bus, workflow manager, , biztalk , on? since pushing.net communities use it, why don't start initiative , show best practice on how can, .net stack developer, implement enterprise project using ef best practice? is related performance issue people talk since release of ef? ef has come long way since versions of orm. have used in large projects , haven't had significant performance issues. said, products have mentioned have been there before ef came existence may have form of orm have been build , maintained internally. if looking pattern , practices please checkout articles written julie lerman .

c# - How to get intellisense to autocomplete generic class angle brackets -

i'm working visual studio 2013. more of annoyance else, when make, say, list, contains generic class, how intellisense spit out angle brackets , series of class stand-ins? for example, if type new lis the intellisense dropdown highlight list<> however, when press enter / tab / space /etc, get new list when rather have new list<t> where t highlighted , ready replaced. is option somewhere in visual studio? i don't think there setting such things. but, there tool called resharper need. instead of replacing t empty <|> cursor ready write type . new list<|> note: there may other tools same.

Setting MySQL Query As Multiple Variables In Shell -

i'm sorry if question overly succinct, attempting run mysql query via shell script, , hoping query several different "columns" in result. working well, struggling, figure out how set each of these "columns" unique variables in shell script. here have; #!/bin/sh results=$(mysql --host=localhost --user=root --password=root database --skip-column-names -e 'select cost1, cost2, cost3 customers';) somemath () { total=$1+$2+$3 echo $total } cost in $results; somemath $cost1 $cost2 $cost3 done exit 0 where struggle figure out how feasibly set of "cost1" in query results $cost1, of "cost2" in query $cost2, , of "cost3" in query $cost3. plan feed these variables function perform other tasks. i know may rudimentary, despite searching, can't figure out! thank you! if understand correctly, need each row, each column , pass them other functions separately. here's example wrote: #!/bin/bash somelist

python datetime fromtimestamp yielding valueerror year out of range -

this question has answer here: javascript timestamp python datetime conversion 3 answers when attempting convert float formatted timestamp e.g 1437506779950.0 datetime object, i'm getting valueerror "year out of range". this code used, working not 3 months ago. revisiting now, strangely throwing error yet nothing in code base has changed, data being passed it, , data has changed there timestamp. >>> f = 1437506779950.0 >>> datetime.datetime.fromtimestamp(float(f)) traceback (most recent call last): file "<stdin>", line 1, in <module> valueerror: year out of range i can't understand have changed make break? as noted in answer this question , looks unit conversion issue. have divide timestamp 1000 convert milliseconds seconds.

Upload file with curl php by custom header -

headers sends programs adress: --55ae49448a20c content-disposition: form-data; name="chat_id" content-length: 9 108432389 --55ae49448a20c content-disposition: form-data; name="photo"; filename="untitled.png" content-length: 16252 content-type: image/png png i want post 2 varibles (chat_id) , (photo) following code. attempted code: <?php $params = "content-disposition: form-data; name=\"chat_id\"\r\n" . "content-length: 9\r\n\r\n" . "\r\n" . "content-disposition: form-data; name=\"photo\"; filename=\"untitled.png\"\r\n" . "content-length: ".filesize("untitled.png")."\r\n" . "content-type: image/png\r\n\r\n" . file_get_contents("untitled.png"); $request_headers = array(); $request_headers[] = 'content-length: ' . strlen($params); $url = 'http://example.com'; $ch = curl_i

VBA code to update worksheet, referring to an external excel workbook -

hi there vba code me update column referring external workbook (primary source). external workbook name changed every month being downloaded @ end of each month file name changed time. there code use refer external workbook file me automate update secondary excel file? look workbook.changelink method lets change source workbook/worksheet of formulas @ source. this ms page

asterisk - Use of Digium 24-port FXO analog cards for FreePBX system -

does have experience installation of digium 1aex2400 series cards in freepbx distro control 24 pots lines ? researching new phone system , want see if has used hardware before, , if there installation trouble should know about. installed in dell r310 1u rack server . for many years have used three zaptel 8-port fxo cards asterisk 1.4 , , freepbx set our company phone system, voip phones. but can't find reviews or information on 24-port digium cards perfect upgrade, using 1 pci-e slot , instead of current 3, requiring old unsupported dell 2u takes rack space. this question should setting own pbx phone server handle 24 pots (plain old telephone service) lines send , receive calls, more stable audio quality common voip trunks see being used in freepbx/asterisk setups ). any information helpful. any digium card have supported modern dahdi/zaptel drivers so can use in freepbx. if not see card, likly need configure or update drivers.

php - Get categories for a single post in a custom post type -

i'm trying unformatted list (preferably list of slugs) of categories single post in custom post type loop. list serve class div ( $categoryslugswilleventuallygohere ). i've found few different methods of getting list of of categories custom post type, not ones specific single one. here's have far: <?php $projects_loop = new wp_query( array( 'post_type' => 'projects', 'orderby' => 'menu_order' ) ); ?> <?php while ( $projects_loop->have_posts() ) : $projects_loop->the_post(); ?> <div class="box <?php $categoryslugswilleventuallygohere; ?>"> <div class="port-item-home"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'portfolio-home' ); ?></a> <p>

boost - Working with multiarch shared libraries on Debian -

i try link program libboost_thread-mt on debian machine. worked on debian 7 (wheezy) fails on debian 8 (jessie). on wheezy library version 1.49, , on jessie 1.55. package using multi-arch scheme, means used under /usr/lib , under /usr/lib/i386-linux-gnu . need in order link without using -l ?

c# - Task causing strange behavior in form_load event -

i have task runs in form_load event of usercontrol in winforms: private void ucdeviceinsert_load(object sender, eventargs e) { system.threading.tasks.task gettbox = system.threading.tasks.task.run(async () => { await averylongrunningproccess(); }); pbimage.image = properties.resources.remove; gettbox.wait(); pbimage.image = properties.resources.insert; btnnext.visible = true; tmrdeviceinsert.enabled = true; tmrdeviceinsert.start(); } private void tmrdeviceinsert_tick(object sender, eventargs e) { next(); } i change image of picture box inform user progress of long running process. part works fine, button doesn't show, , timer never starts. i've stepped through code, , can confirm running without problems, makes more baffling. ideas causing issue? task.run pushing cpu-intensive work off ui thread. since you're calling asynchronous method,

c# - Visual Studio 2015 break on unhandled exceptions not working -

Image
visual studio used have specific checkbox "break on un-handled exception". in 2015 has been removed (or moved somewhere cannot find it). converted projects no longer break if fail provide user-level exception handler. don't want break on "thrown exceptions" because handle specific ones. fail provide specific handler. right code exits current procedure , continues execution @ next call stack location, not good. anyone know how in visual studio 2015? upgraded community edition yesterday. there's new window called "exception settings" appears in lower right pane default when begin debugging. has of options expect. you can bring ctrl + alt + e this allows cherry-pick exceptions cause break in debugger. the key, though, can set whether these exceptions break, or break when it's unhandled exception -- setting not intuitive. you need first check "enable code" under tools > options > debugging. this allo

java - Apache Client 4.x close a HttpRequestBase -

i trying create method called close() when called release connection httprequestbase have called httpmethod. issue code below have worked fine in client 3.x doesn't work android api 21 uses version of client 4.x question how close connection public void close() { executorservice es =(executorservice) callablesingleton.getexecutor(); es.shutdown(); if (null != httpmethod) { httpmethod.releaseconnection(); //postmethod.abort(); } httpmethod = null; } i guess this: try{ closeablehttpresponse response = httpclient.execute(target, http_req, localcontext); response.getentity().writeto(system.out); // read entire stream end in order reuse connection entityutils.consume(response.getentity()); }finally{ response.close(); } when http client no longer need can execute httpclient.close(); terminates open connections. client 4.x quite different client 3.x, guess need more refactoring.

linq - Are there performance implication when using one-to-many bi-directional relationships in Entity Framework? -

Image
we have been implementing our erd in ef. code first project public class project { [key] [databasegenerated(databasegeneratedoption.identity)] public int projectid { get; set; } [index("ix_projectguid", isunique = true)] [required] public guid guid { get; set; } [maxlength(256), index("ix_projectname", isunique = true)] [required] public string name { get; set; } public virtual icollection<userattribute> userattributes { get; set; } } code first userattributes public class userattribute { [key] [databasegenerated(databasegeneratedoption.identity)] public int userattributeid { get; set; } [index("ix_project_atttribute_name", 1, isunique = true)] public int projectid { get; set; } [foreignkey("projectid")] public virtual project project{ get; set; } [index("ix_project_atttribute_name", 2, isunique = true)] public int attributetypeid { get;

javascript - My Windows App built with Cordova in VS 2015 is not working in bing map function page ( maybe there is no internet access ) -

i developing windows app using cordova project template in visual studio 2015. i've succeeded other versions ios, android, windows phone 8. but have problems in windows version. ui working correctly when build windows app. seems network not working correctly. app has page using bing map. when visit page, can't load map @ all. timed out. pc available connect internet. i've tested app in local machine. all network functions messed windows version. anybody experienced before? can advice me major problem? best.

javascript - Body of page not shrinking at all, CSS, HTML -

right have body width of 90%, , left , right margin of 5%, , border of 1px. here's i'm trying do. i'm trying make when zoom out way using ctr-, it'll shrink until it's pin-prick in middle of page, right body's width isn't shrinking @ when zoom out way. it's staying same size. not sure did wrong. please take @ code. body { width: 90%; margin-left: 5%; margin-right: 5%; border: 1px solid black; } p.s: if you're not understanding i'm talking about, please either hit ctr-, or ctr , scroll thing on mouse until page's size around 25%. see how stackoverflow pin-prick smack-dab in middle? see width of entire site being shrunk down size? well, when that, body of site doesn't shrink @ all. stays same size. change % px body { width: 1000px; margin-left: 5%; margin-right: 5%; border: 1px solid black; margin:auto; }

python - Get string between two sub strings with limitation -

i need finding substring using regex, starting example: given following string: test_str = "start: 1111 kill 22:22 start: 3333 end" i extract string between start , end doesn't involve kill: wanted_result = (start: 3333 end) note: need matches of start blablab end don't have kill between them several tries failed, latest one: pattern = re.compile(r'start:(.+?)(([^kill])end)',flags = re.dotall) results = pattern.findall(test_str) which results in different result: result = (' 1111 kill 22:22 start: 3333', ' end', ' end') you need use negative lookahead based regex. pattern = re.compile(r'start:(?:(?!kill).)*?end',flags = re.dotall) (?:(?!kill).)*? checking before match character. checks character going matched must not start of substring kill . example: >>> import re >>> test_str = "start: 1111 kill 22:22 start: 3333 end" >>> pattern = re.compile(r's

java - Android recreate when opening app from minimized -

first of beginner @ both java , android development i need call recreate() when app opened minimized state. how can achieve this? when java application opened first time, oncreate() method called. when activity "paused", onresume() method called resume activity. additionally, when application "stopped", onstart() method called resume activity. it's important understand difference between 2 when declaring want each method perform. keep in mind onresume() , onstart() methods generic , may not re-initialize components lost when user closed activity. want this... @override public void onresume() { super.onresume(); // initialize components here } @override public void onstart() { super.onstart(); // initialize components here }

html - CSS multi-column for tables -

i have slender long table row each day in month. it's long people have scroll on screen resolutions see bottom. since there enough space on right of table, i'd split table automatically multiple columns; each column taking of table rows. css multi columns seem ideal solution task, column-width not work tables: applies to: non-replaced block-level elements ( except table elements ), table cells, , inline-block elements what can use instead? (i not care ie) as mentioned can use css multi columns, wrap table class "treecolumn" , use csses on class example table have 3 columns : .treecolumn{ -webkit-column-count: 3; /* chrome, safari, opera */ -moz-column-count: 3; /* firefox */ column-count: 3; } note internet explorer 9, , earlier versions, not support column-count property. here plunker update : if want have headers in columns, don't know if safe way or not, can have table, in wrapper same class,and repeat headers as column coun

amazon web services - eu-west-1 AWS 'Could not fetch tags: An internal error has occurred' -

eu-west-1 (irland) aws 'could not fetch tags: internal error has occurred' warning 3-4 hour ago. in frankfurt (eu-central-1) working... do have same issue? my scripts (ansible) depends on tags, wonder how happens , when fixed... just noticed well, contacted aws, they're on it. https://forums.aws.amazon.com/thread.jspa?messageid=652141&tstart=0 mentions well. there's tiny note on http://status.aws.amazon.com @ "amazon elastic compute cloud (ireland)" (tab europe). i've never had problem , use aws daily, it's nothing worry (until starts happen more ;))

testing - Storm test case backtype.storm.multilang failed with backtype.storm.multilang.NoOutputException exception -

i clone latest version (master) of storm source code https://github.com/apache/storm.git . using ubuntu 14.02. but when run "mvn test" command, test process fails , terminates @ backtype.storm.multilang-test. here context of backtype.storm.multilang-test.xml file: 171293 [thread-1212-1] error b.s.util - async loop died! java.lang.runtimeexception: backtype.storm.multilang.nooutputexception: pipe subprocess seems broken! no output read. serializer exception: @ backtype.storm.utils.shellprocess.launch(shellprocess.java:91) ~[classes/:?] @ backtype.storm.spout.shellspout.open(shellspout.java:84) ~[classes/:?] @ backtype.storm.daemon.executor$fn__4594$fn__4609.invoke(executor.clj:559) ~[classes/:?] @ backtype.storm.util$async_loop$fn__643.invoke(util.clj:473) [classes/:?] @ clojure.lang.afn.run(afn.java:22) [clojure-1.6.0.jar:?] @ java.lang.thread.run(thread.java:745) [?:1.7.0_79] 171294 [thread-1212-1] error b.s.d.executor - java.lang.runtime

sql - how to avoid updation of id column -

i don't want update id column because auto incremented . when run code face java.sql.sqlexception: no value specified parameter 1. so question how avoid / bypass update. string sql=""; sql = "insert registration(first_name,last_name,gender,email_id,dob," + "father_name,mother_name,contact,mobile,address,city,country,graduation," + "graduation_marks,graduation_year,inter,inter_marks,inter_year,high_school," + "high_marks,high_year,role,salary,resume,photo,pre_comp) value(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; // int i=0; preparedstatement p = con.preparestatement(sql); p.setstring(2,registration.first_name); p.setstring(3,registration.last_name); p.setstring(4,registration.gender);

vba - Alternative to Excel INDIRECT that works on closed files, and links to workbook based on cell value? -

i've seen many questions on forum linking excel files based on cell values , indirect pops answer, , function , fill sheet way want, need find way work source file being closed. problem when comes linking, file path pull data not known until part of file name entered cell. for example, in 'print summary' workbook, sheet1 cell a2 file name entered number 12345 (and gets auto-formatted place 'wip' in front) represents wip12345.xls. wip12345.xls form holds information needs populate columns across row 2. wip12345.xls order form , completed days ahead. once has been approved, summary workbook updated wip#. i did concatenate wip12345 , .xls create file name wip12345.xls on sheet2, , have macro copies , pastes special value turn result text. but, can't find way create formula take value , lookup file pull information from. need pull , fill information different cells 10 columns down 43 rows (each row representing different wip#####.xls file). i'm guessi

jquery - adjusting div according to content length -

i trying develop allows users post thoughts. showing posts in left , right div of parent container. need align left , right divs properly. if right side div contain more content left side, next post should displayed in left side div , vise versa. am stuck this. how can implement this..?? please me. thanks in advance. sure, can adjust both div of same length less or more content using css "display" property. keep "display: table" main div css property , "display:table-cell" child divs css property. thanks

ios - Upgrading to Xcode 7 creates "Missing current version declaration" warning on CoreData model -

Image
figured i'd post complete question/answer here known bug: when upgrading xcode 7 (stable/beta) previous release, build gives new warning: "missing current version declaration" coredata model file. worst of all, double-clicking warning goes nowhere, & there no obvious hints within xcode resolution. how resolve issue? while in xcode’s core data model editor, in menu bar select editor -> add model version. then in version name free specify like, can type in model name. (verified on xcode 7 beta 4) (this result in creation .xccurrentversion in data model bundle)

java - Transform hardware cursor in LWJGL -

i using lwjgl's mouse.setnativecursor() change cursor in game i'm making. however, rest of game scaled while cursor retains 1:1 pixel ratio, cursor looks out of place. is there efficient way transform cursor on fly? if not, software cursor (drawing image @ mouse co-ordinates) considered alternative? have been avoiding using 1 until because i have heard ties mouse movement frame rate of game can introduce latency. i don't know, option might scale cursor's texture. or, hide cursor , draw in opengl. draw 2d quad above screen , of it's contents. let resize it, might confuse users , make mouse more inaccurate. if you're looking dynamic scaling without latency, hiding , drawing quad might best way go.

java - Trying to find the difference in days with JodaTime -

simply, i'm storing 'initial date' data string variable in text file e.g. 02-02-2015, , need know if 3 days has passed initial date. i've been recommended use jodatime kept on recieving errors i'm presuming because i'm comparing string , int variables. is possible, if how? in advance? edit: apologies didn't post code. public void startdelay() { datetime dt = new datetime(); datetimeformatter fmt = datetimeformat.forpattern("dd-mm-yyyy"); delaypin = fmt.print(dt); } public int delayended() { datetime dt = new datetime(); datetimeformatter fmt = datetimeformat.forpattern("dd-mm-yyyy"); string today = fmt.print(dt); delayprogress = days.daysbetween(new datetime(delaypin), new datetime(today)).getdays(); return delayprogress; } delaypin being stored in text file. repeated method todays date within second delayended method. something this? string storeddatestring = "02-02-201

python - How to create and compare datetimes in custom class? -

i'm writing __init__ , __eq__ functions class photo , involving datetime module. however, i'm unsure of __init__ function body i've written , how test __eq__ . this have __init__ function: class photo: 'fields: size, pdate' # purpose: constructor class photo # __init__: int int int int -> photo # note: function definition needs self parameter , not require return statement def __init__(self, size, year, month, day): self.size = size self.pdate = year + month + day i think self.pdate wrong i'm not sure i'm supposed write instead. perhaps following? self.pdate = year self.date = month self.date = day from documentation of datetime module , can create datetime.date objects using following: from datetime import date some_random_date = date(2013, 7, 28) not_so_random = date.today() for use case, kind of objects want affect self.pdate attribute: from datetime import date class photo: &

javascript - What happens when a number has a leading zero? -

i've been trying debug problem today , found out problem is. reason, when number has leading 0 javascript weird. example: alert(132); alert(0132); var test = 0132; alert(test); jsfiddle: http://jsfiddle.net/u8sfu/3/ the first popup says "132," second "90," , third says "90." my question is, why number 0132 become number 90? baffling me! a number leading 0 parsed octal literal , in base 8.

php-curl doesn't connect to remote host and header appear to be empty -

i configured 1 of server accept files via post, convert them , send them response. php server uses functionality via curl. the important part in php script looks this $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_port, $port); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_postfields, array('file_contents' => '@' . $filename)); curl_setopt($ch, curlopt_connecttimeout, 5); curl_setopt($ch, curlinfo_header_out, true); file_put_contents($filename . '.png', curl_exec($ch)); print_r(curl_getinfo($ch)); echo curl_errno($ch); curl_close($ch); however appears if curl doesn't connect other server , curl_getinfo returns array ( [url] => (redacted) [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_ti

python - analyze text file in parallel with mpi4py -

i have input tab separated text file: 0 .4 1 .9 2 .2 3 .12 4 .55 5 .98 i analyze in plain python as: lines = open("songs.tsv").readlines() def extract_hotness(line): return float(line.split()[1]) songs_hotness =map(extract_hotness, lines) max_hotness = max(songs_hotness) how perform same operation in parallel using mpi4py ? started implementing scatter , won't work straight away because scatter needs list elements same length number of nodes. processing text file in parallel difficult. split file? reading parallel file system? might consider mpi-io if have large enough input file. if go route, these answers, provided in c context, describe challenges still hold in mpi4py: https://stackoverflow.com/a/31726730/1024740 , https://stackoverflow.com/a/12942718/1024740 another approach not scatter data read in on rank 0 , broadcast else. approach requires enough memory stage input data @ once, or master-worker scheme data rea

How does github choose an user's popular repositories? -

github has "popular repositories" list on each user's profile. know how math list. number of views counts? number of commits? number of clones, forks,...? the list seems random-ish me there cases popular repositories chosen out of list of repos same stats. example, relatively new user has 10 repos 0 stars , forks have 5 repos chosen feature "popular repositories" list. criteria? from github pages : this section displays repositories watchers. for further detail on ordering of popular repos, see this answer

xcode - IOS Swift Unwrapping NSData is Crashing -

ios swift problem while unwrapping, crashing. getting data nsdata , when printing in string or var dict : anyobject = nsjsonserialization.jsonobjectwithdata(returndata!, options: nsjsonreadingoptions(0), error: &resperror) anyobject! doing returning dict nil , or var datastring : nsstring = nsstring(data:returndata!, encoding:nsutf8stringencoding)[this image liknk] as! string datastring causing fatal error: unexpectedly found nil while unwrapping optional value. you unwrapping values forcefully (forced unwrapping), if object contains nil generate runtime error. trying use ! access non-existent optional value triggers runtime error. make sure optional contains non-nil value before using ! force-unwrap value.

R glmer warnings: model fails to converge / model is nearly unidentifiable -

i have seen questions on forum, , have asked myself in previous post still haven't been able solve problem. therefore trying again, formulating question can time, detailed information possible. my data set has binomial dependent variable, 3 categorical fixed effects , 2 categorical random effects (item , subject). using mixed effects model using glmer. here entered in r: modelall<- glmer(moodr ~ group*context*condition + (1|subject) + ``(1|item), data=rprodhsns, family="binomial")` i 2 warnings: warning messages: 1: in checkconv(attr(opt, "derivs"), opt$par, ctrl = control$checkconv, : model failed converge max|grad| = 0.02081 (tol = 0.001, component 11) 2: in checkconv(attr(opt, "derivs"), opt$par, ctrl = control$checkconv, : model unidentifiable: large eigenvalue ratio - rescale variables?` my summary looks this: generalized linear mixed model fit maximum likelihood (laplace approximation) ['glmermod'] family: binomia

Convert a String to an array of characters swift 2.0 -

i need convert string array of characters. work in swift 1.2 , lower doesn't since swift 2.0 var mystring = "hello" array(mystring) // ["h", "e", "l", "l", "o"] var mystring = "hello" let characters = [character](mystring.characters) // ["h","e","l","l","o"] hope helps

excel - How to Count/Merge identical rows of data and add them in a column -

Image
lets have 10,000 rows of data, sample shown below, h1 = header1 . i'm trying merge identical columns , reflect in last column (header6), ie i'm trying add them up, collapsing repeated rows. however, difficulty i'm facing these (including header6) text not numbers. preferably using excel vba (data must in excel) h1 h2 h3 h4 h5 h6 aa bb ee hh kk 1* aa cc ee gg kk 1* aa cc ee gg kk 1* aa cc ee gg kk 1* aa dd ff hh kk 1* aa dd ff hh kk 1* the criteria fields, header1 header5 must identical, , add in header6 . result of scenario should follows: h1 h2 h3 h4 h5 h6 aa bb ee hh kk 1* aa cc ee gg kk 3* aa dd ff hh kk 2* i tried many ways no avail. appreciate assistance.

perl - Lines not executed in the good order while dying in foreach loop -

i have strange behavior understand. here perl script, check if folders present : #!/usr/bin/env perl use warnings; $root = "c:\\data\\tests"; @check = ("folder1", "folder2", "folder3"); foreach $check (@check){ print $check; print -d "$root\\$check" ? " ok\n" : die " nok : not accessible"; } now, assume folder3 missing, should have output: folder1 ok folder2 ok folder3 nok : not accessible @ c:\data\tests\strange.pl line 8. instead have : folder1 ok folder2 ok nok : not accessible @ c:\data\tests\strange.pl line 8. folder3 so looks in last loop, second line executed before first.. someone knows why ? so looks in last loop, second line executed before first.. someone knows why ? die ".." unlike print goes stderr furthermore output buffered might want disable in order wanted output, stdout->autoflush(); stderr->autoflush();

string - SPSS REPEAT: How do i use the stand-in-variable as part of variable name? -

i'm using spss 20. in dataset list of string variables want recoded numeric. wanted them recoded themselves. realize not possible spss runs through dataset casewise , 1 variable can have 1 type @ time. want them recoded new variables suffix _rec . do repeat var = var_1 var_2 ... var_n. recode var (convert) var_rec. end repeat. but creates 1 new variable var_rec not several new ones. i tried programme workaround: compute job_2 string job(a20) repeat var = var_1 var_2 ... var_n. compute var = job. recode job (convert) job_2. delete variables var. compute var = job_2. end repeat. but doesn't work because delete variables can not used within do repeat loop. so i'm @ original question. you (string variables) can't recoded can using alter type alter type var_1 var_2 var_3 (f8.2). where f8.2 numeric variable of width 8 , 2 decimal points. you can use do repeat multiple stand-in list of variables, following: do repeat old = va

r - Building own print class method - ggplot2 -

i'm trying build own print method, based on class "facet". want make specific ggplot when calling print , throws me error message error: ggplot2 doesn't know how deal data of class facetindicator code print.facet <- function(x) { print("hello") # print statement gets outputted fine ggplot(data = x, aes( x = published, y = sma90)) + geom_line() } running ggplot manually same object without class attribute works fine. i've must have missed trivial, can be? you remove facet class when pass object ggplot, or, perhaps more elegantly, via fortify method, fortify.facet <- function(x) {class(x) <- class(x)[-1]; x} print.facet <- function(x) { ggplot(data = x, aes( x = published, y = sma90)) + geom_line() } d <- data.frame(published=1:10, sma90=1:10) class(d) <- c("facet", class(d)) print(d) you consider defining as.data.frame.facet and/or autoplot methods, may feel more natural.

security - Authentication between trusted application and an API -

the application set up application : third party, windows desktop application. application users required log in to. logins managed/authenticated locally application b : our application, windows system tray application. integrates application a. extracts information , sends application c. application c : our api, application b calls in send data. currently users required create account in application c using gui , enter user details in application b proceed. users questioning process fail differentiate ownership between application , b since tightly coupled. given can trust if user logged in application a, genuine, want come solution not require create login. based on trust between application b, c, , ability detect if user logged in application a. end result be, if user logged in application a, application b detects , sends user details, application c. given there trust between b,c user not require thing authentication between b , c. c use user logged in authorization.

ios - Grab current stock price for iPhone app -

how able have user enter stock ticker , using real time data, display current stock price ticker on iphone app? check out free yahoo! finance csv api: https://code.google.com/p/yahoo-finance-managed/wiki/yahoofinanceapis this question: how download csv file server in objective-c and little tool: https://github.com/davedelong/chcsvparser you grab current stock prices lots of stocks in 1 api request , deliver them app parsing csv.

ruby on rails - What REST urls should be used for accessing data from a many-2-many table -

what should syntax of rest calls manipulating (e.g. insert/update/delete) many-2-many table mentioned below rails app. create table foos (id integer(11), name varchar(255)) create table bars (id integer(11), name varchar(255)) create table foo_bars (foo_id integer(11), bar_id integer(11) foo_id fk foos(id) bar_id fk bars(id) should use like? post /foo/:fooid/bar (to create fooid, barid) put /foo/:fooid/bar/:barid (to update fooid, barid) delete /foo/:fooid/bar/:barid (to delete foo_id, bar_id combination) i consider using third endpoint, maybe named checkouts , represent book checked out user, foo-bars table. think it's advisable because relationship has other information associated besides user , book ids. instance, when book due back? can use endpoint track historical information historical activity of book or user. i'm using boolean example purposes, date more appropriate. // check out books library post /checkouts { "userid":25, "bookids&

c++ - How to Build H3DAPI with Xcode? -

i want build h3d , communication x3dom , try use cmake bug situation: h3dutil not found . can me please? h3d 2.3 source code: http://www.h3dapi.org/modules/pddownloads/viewcat.php?cid=14 i have find solution: make sure h3dapi, hapi, , h3dutil source trees have same parent directory. solution source tree same: just download these packages , arrange them in same directory/folder. h3dutil not found: make sure have set h3dutil_library/h3dutil_debug_library , h3dutil_include_dir correct file paths , directory paths in cmake. libs should direct h3dutil_vc9.lib h3dutil_vc9_d.lib , point includes h3dutil/include directory.

for loop - java.lang.ArrayIndexOutOfBoundsException looping? -

this loop inside other loops, s[] char array. moving char step step.what should correcting it for(k=j; s[k]!='\0' ;k++) { s[k]=s[k+1]; } you should realize arrays in java have length, null terminated check wrong. since access k+1 'th element inside loop, k must not go beyond s.length - 2 . for(k=j; k < s.length - 1 ;k++) { s[k]=s[k+1]; }

python 3.x - How to store a row from CSV file? -

in csv file have 5 lines describing file. need store third line ignoring rest. i've managed write code ignores description headers how can store 1 line? wrote code ignore description headers for row in range(6): csvfile.readline() you can use itertools.islice 8th line 3rd line after 5 header lines i.e 8th line or index 7: from itertools import islice line = next(islice(csvfile, 7, 8)) # start=index 7, end= index 8 1 line you can use linecache.getline single line file not efficient. if had large file itertools consume recipe might useful skip n lines: def consume(iterator, n): "advance iterator n-steps ahead. if n none, consume entirely." # use functions consume iterators @ c speed. if n none: # feed entire iterator zero-length deque collections.deque(iterator, maxlen=0) else: # advance empty slice starting @ position n next(islice(iterator, n, n), none)

c# - Can't create Facebook AdSet -

i can't create new ad set, got message. (facebookapiexception - #100) invalid parameter my code : dynamic parameters = new expandoobject(); parameters.name = title; parameters.billing_event = "impressions"; parameters.optimization_goal = "post_engagement"; parameters.daily_budget = "2000"; parameters.campaign_group_id = groupis; parameters.targeting = (dynamic)(new expandoobject()); parameters.targeting.age_max = 65; parameters.targeting.age_min = 25; parameters.targeting.geo_locations = (dynamic)(new expandoobject()); parameters.targeting.geo_locations.countries = new list<string>(); parameters.targeting.geo_locations.countries.add("us"); dynamic res = fb.post("/v2.4/act_" + adsid + "/adcampaigns", parameters); you have add access_token , this: var fb = new facebookclient(); dynamic parameters = new expandoobject(); parameters.access_to

Display php code with fwrite inside a php file -

hello using code bellow write following line inside .php file. $stringdatar = "<!doctype html public '-//w3c//dtd xhtml+rdfa 1.0//en'\n"; fwrite($handler, $stringdatar); i trying same write inside php file following code doesn't wite php code. $stringdatar = "'.<?php $_get['p']\n.'"; fwrite($handler, $stringdatar); any ideas? variables expanded inside double quotes, it's putting value of $_get['p'] file. need escape dollar sign written literally. $stringdatar = "'.<?php \$_get['p']\n.'";

plsql - PL/SQL: procedure to process a comparison between two tables -

this example need : table 1 : id champ1 champ2 champ3 1 s q 2 d k 3 d s table 2: id champ1 champ2 champ3 1 s q 2 q 3 k a procedure feeds table3 result of comparison between table 1 , table 2 table 3: id_exc name_champ noted_val except_val 2 champ1 d q 3 champ1 d 2 champ2 k 3 champ3 s k please, need if had same challenge :) thanks in advanced data setup: create table table1 (id int, champ1 varchar2(1), champ2 varchar2(1), champ3 varchar2(1)) ; insert table1 (id, champ1, champ2, champ3) values (1, 'a', 's', 'q') table1 (id, champ1, champ2, champ3) values (2, 'd', 'k', 'a') table1 (id, champ1, champ2, champ3) values (3, 'd', 'a', 's') select * dual ;

java - DateFormat conversion in Android -

let suppose have date show as. 2015-08-03 12:00:00 how convert day's name tuesday ? don't want things 03 tue etc. full days name. looked around bit confused on that. first, parse date java.util.date object. dateformat formatter = new simpledateformat("yyyy-mm-dd hh:mm:ss"); date yourdate = formatter.parse("2015-08-03 12:00:00"); then, populate calendar date: calendar c = calendar.getinstance(); c.settime(yourdate); int dayofweek = c.get(calendar.day_of_week); now have day of week dayofweek (1 being sunday, example).

iphone - Google iOS API thumbnailURL: is not working iOS -

i'm using google api ios app, , have code [sharebuilder seturltoshare:[nsurl urlwithstring:@"https://facebook.com/uncollectible"]]; that works , embeds url post on google+ expected. but method deep-link set doesn't: [sharebuilder settitle:@"uncollectible" description:@"stay cool. stay debtless." thumbnailurl:[nsurl urlwithstring:@"http://facebook.com/uncollectible"]]; my code same google example id<gppnativesharebuilder> sharebuilder = [[gppshare sharedinstance] nativesharedialog]; // line manually fill out title, description, , thumbnail of // item you're sharing. [sharebuilder settitle:@"new 5k record!" description:@"i ran 5000 meters in 26:16! that's new record!" thumbnailurl:[nsurl urlwithstring:@"https://mozorg.cdn.mozilla.net/media/img/contribute/person-faye.1bfdab1ab5c0.jpg"]]; [sharebuilder setcontentdeeplinki