Posts

Showing posts from January, 2015

parsing - PHP Parse/Syntax Errors; and How to solve them? -

Image
everyone runs syntax errors. experienced programmers make typos. newcomers it's part of learning process. however, it's easy interpret error messages such as: php parse error: syntax error, unexpected '{' in index.php on line 20 the unexpected symbol isn't real culprit. line number gives rough idea start looking. always @ code context . syntax mistake hides in mentioned or in previous code lines . compare code against syntax examples manual. while not every case matches other. yet there general steps solve syntax mistakes . references summarized common pitfalls: unexpected t_string unexpected t_variable unexpected '$varname' (t_variable) unexpected t_constant_encapsed_string unexpected t_encapsed_and_whitespace unexpected $end unexpected t_function … unexpected { unexpected } unexpected ( unexpected ) unexpected [ unexpected ] unexpected t_if unexpected t_foreach unexpected t_for unexpected t_while unexpected t_do

c++ - Double-checking understanding of memory coalescing in CUDA -

suppose define arrays visible gpu: double* doublearr = createcudadouble(fieldlen); float* floatarr = createcudafloat(fieldlen); char* chararr = createcudachar(fieldlen); now, have following cuda thread: void thread(){ int o = getoffset(); // same threads in launch double d = doublearr[threadidx.x + o]; float f = floatarr[threadidx.x + o]; char c = chararr[threadidx.x + o]; } i'm not quite sure whether correctly interpret documentation, , critical design: will memory accesses double, float , char nicely coalesced? (guess: yes, fit sizeof(type) * blocksize.x / (transaction size) transactions, plus maybe 1 transaction @ upper , lower boundary.) yes, cases have shown, , assuming createcudaxxxxx translates kind of ordinary cudamalloc type operation, should nicely coalesce. if have ordinary 1d device arrays allocated via cudamalloc , in general should have coalescing behavior across threads if our load pattern includes array index of form: data_array[

How do I center gadgets, gadget titles, and link lists in the footer section on blogger using HTML5 or CSS code? -

i have searched interwebs hours, including site, answer question , have not found one, i'm sorry if it's been answered before. i trying center gadgets (widgets?), gadget titles, , links. basically, want centered in footer section. have 3 column footer , using watermark template in blogger. managed center sidebar content (or @ least images , gadget titles) using css code found on forum. same code did not apply footer. searches have found info. , code pertains the post footer...but i'm concerned page footer. any pointing me in right direction helpful. you can check out website specific visual of problem, run erotica website , wouldn't want break content rules here. 18+ website/nsfw. if listing web address not okay, need see site visual of problem, please pm me it. if okay list website, let me know, people can me out it. thanks! try css blocks footer { margin :0 auto }

ruby on rails - how to refresh a page after receiving webhook from stripe -

i using stripe creating payments. after payment done user redirected payment status page. payment status page supposed show latest plan user has subscribed for. problem webhook stripe after sometime updates user plan table. user redirected user plan page after payment. how can show updated status after user redirected. there way halt redirect till webhook request complete there should no need on end wait webhook event arrive before updating customer here. stripe api calls synchronous means when create charge either error indicates payment failed or charge object indicates payment succeeded. depending on can update customer without having wait event reach you. the same logic applies new subscription here when create 1 subscription object indicating successful , can update database before redirecting customer. most events should seen way verify information have on end , make sure data date , not validate charge , update customer directly.

javascript - SVG and TweenLite - Select class within parent -

i have script modified tutorial animates svg strokes when containing div comes view (using inview.js). have added tweenlite animation changes svg fill-opacity 0 1. problem addition not care whether containing div in view (i'm using getelementsbyclassname target svg elements). how can target elements class name if containing div in view? guess need use "parentelement" in tweenlite lines i'm not sure how. i have modified function within svglines.js (everything after drawsvgpaths): function replacerectswithpaths(parentelement) { var rects = $(parentelement).find('rect'); $.each(rects, function() { var rectx = $(this).attr('x'); var recty = $(this).attr('y'); var rectx2 = parsefloat(rectx) + parsefloat($(this).attr('width')); var recty2 = parsefloat(recty) + parsefloat($(this).attr('height')); var convertedpath = 'm' + rectx + ',' + recty + ' ' + rectx2 + ',' + recty + &#

css - Make Class Inherit Styling From Another External Class -

this question has answer here: can css class inherit 1 or more other classes? 27 answers is possible make class inherit class (from different css file)? /* make class have .form.control's styling. form.control located in separate standard .css file*/ .token-input-list-facebook { .form-control; } edit further information: html element class 'token-input-list-facebook form-control' dynamically generated third party library. input gets turned input hidden ul auto-suggests things. go , edit 3rd party javascript. styling through stylesheets (css or less) more elegant method class="token-input-list-facebook form-control"

tableview - JavaFX: TableViewCol set editable does not allow editting -

i have editable table , i've cloned code pane , not let me edit it. <tableview fx:id="queuetable" layoutx="5.0" layouty="388.0" prefheight="200.0" prefwidth="406.0"> <columns> <tablecolumn fx:id="materialcol" editable="false" prefwidth="224.0" text="material"> <cellfactory> <textfieldtablecell fx:factory="fortablecolumn" /> </cellfactory> <cellvaluefactory> <propertyvaluefactory property="symbol" /> </cellvaluefactory> </tablecolumn> <tablecolumn fx:id="sourcecol" editable="false" prefwidth="111.0" text="source"> <cellfactory> <textfieldtablecell fx:factory="fortablecolumn" /> </cellfactory>

json - Grabbing Array Index with PHP -

i trying value array in php. the json returned is string(3017)"[{"userid":"1","0":"1","order":"[ { \"image\":\"undefined\",\"song\":\"alwaysnew.mp3\",\"album\":\"oh no!\"},{\"image\":\"undefined\",\"song\":\"always1.mp3\",\"album\":\"fly\"},{\"image\":\"undefined\",\"song\":\"always2.mp3\",\"album\":\"album 2\"},{\"image\":\"undefined\",\"song\":\"always3.mp3\",\"album\":\"album 1\"},{\"image\":\"undefined\",\"song\":\"always.mp3\",\"album\":\"album 4\"},{\"image\":\"undefined\",\"song\":\"alwaysnew2.mp3\",\"album\":\"album title unavailable\"},{\"image\&

asp.net - Change ControlParameter ControlID property from VB -

i have gridview created in asp.net within visual studio. there control parameters in sqldatasource1 identify drop down lists editing within gridview. have "controlid" property hard coded based on name of drop down list saw in viewing source in browser: <updateparameters> <asp:controlparameter name="origin"controlid="gridview1$ctl02$dropdownlist1" propertyname="selectedvalue" /> <asp:controlparameter name="portofload" controlid="gridview1$ctl02$dropdownlist2" propertyname="selectedvalue" /> <asp:controlparameter name="portofdischarge" controlid="gridview1$ctl02$dropdownlist3" propertyname="selectedvalue" /> <asp:controlparameter name="vessel" controlid="gridview1$ctl02$dropdownlist4" propertyname="selectedvalue" /> </updateparameters> currently, works when click "edit" on first row of gridview, other row

gcloud docker pull fails with Untar exit status 2 unexpected fault address -

edit: huge thank @mattmoor helping me debug issue. after had create new docker-machine. there problem docker daemon must've arisen due first machine not being created correctly. i having trouble pulling images computer, both of running osx yosemite. both machines have docker daemon running, , have authenticated desired project pull gcloud auth login on computer able run: gcloud docker pull gcr.io/projectid/image-tag without issues. however when try repeat on machine, large error message begins with: error pulling image (tag-here) gcr.io/projectid/image-tag, endpoint: https://gcr.io/v1/, untar exit status 2 unexpected fault address 0xc208ce5d04 fatal error: faultr downloading dependent layers [signal 0xb code=0x1 addr=0xc208ce5d04 pc=0x94109e] followed goroutine 1 stack trace. the docker version on both machines 1.6.2, client , server api version 1.18, both go versions go1.4.2 the google cloud sdk version on both machines 0.9.67, , both have following compo

variable scope issue in jQuery post method -

this question has answer here: how return response asynchronous call? 25 answers i trying information database , make chart them. unfortunately, variables use store values losing data outside of post . completed , ongoing assigned inside post methods, each other's post methods, not outside of it. when data2 executes, variables become empty again. how can fix issue? var completed; var ongoing; $.post( "/api/educationcompletionrates?status=1&startdate=20150701&enddate=20150705", { data: {} }, function (data) { completed = data; } ); $.post( "/api/educationcompletionrates?status=2&startdate=20150701&enddate=20150705", { data: {} }, function (data) { ongoing = data; } ); var data2 = [ { value: completed, color: "#46bfbd", highlight: &

javascript - using hta with frameset - drop image does not work -

i working framesets in local hta (html-application) in internet explorer 10+. want drop files (images) dropzone (div or body). - hta without frames works - htm , without frames works (all browsers) - hta frames show image in frame index.hta: <frameset cols="40%,60%" > <frame src="start1.htm" name="start1" application="yes" > <frame src="start2.htm" name="start2" application="yes" > </frameset> start1.htm <html> <body ondragstart="return false;"> <div id="dropspot" style="border: 1px dashed #555; height: 200px"> </div> function init() { // set drop-event handlers. var droparea = document.getelementbyid("dropspot"); droparea.addeventlistener("drop", drophandler, false); droparea.addeventlistener("dragover", donothing, false); } function drophandler(event) { // use our donothing() func

java - AbstractMethodError thrown at runtime with Hibernate/JPA -

i absolutely new hibernate , jpa , have following problem trying implement tutorial uses hibernate following jpa specification. i have these classes: 1) helloworldclient class, entry point of application, containing main method: package client; import javax.persistence.entitymanager; import javax.persistence.entitymanagerfactory; import javax.persistence.entitytransaction; import javax.persistence.persistence; import entity.message; public class helloworldclient { public static void main(string[] args) { entitymanagerfactory emf = persistence.createentitymanagerfactory("merging"); entitymanager em = emf.createentitymanager(); entitytransaction txn = em.gettransaction(); txn.begin(); message message = new message("hello"); //transient state em.persist(message); //persistent state txn.commit(); em.close(); message.settext("hi"); //modifying det

how to fix XSS Reflected in java -

i got fortify report shows xss reflected defect below 2nd line. string name = request.getparameter("name"); response.getwriter().write("name: " + name); recommendation given: user input displayed web clients should html encoded , validated. java code , not sure how fix this. a simple way, can use owasp enterprise security api (java edition) : string safe = esapi.encoder().encodeforhtml( request.getparameter( "input" ) ); see link: owasp enterprise security api (java edition) documentation owasp enterprise security api (java edition) code example

javascript - Adding content to react elements -

i new react.js , have heard js library reacts badly modifies it's component structure. there specific procedure add content react elements using jquery. example, if want add content react's div field, can directly use jquery append method insert text div or there other way implement things?. the idea either use traditional approach, or ditch jquery , use react , means using react rendering tree, build tasks, client-side router/spa. you should not modify dom generated react components outside since maintains internal state , virtual dom become out of sync. either use 1 ecosystem or another; 2 different approaches writing website.

c# - Passing date through hyperlink in Rdlc Report -

i want redirect page rdlc report through hyperlink in report.it have 3 parameters id , startdate, enddate. date not casting disable hyperlink column , doesn't work suggestion. casted date in many ways does'nt helpfull. help please

java - servlet route with GET, POST, PUT and DELETE -

i'm new java server-side programming, question starting point using servlets (low level without using spring mvc etc.) , build way there, coming node.js background route definition start function ( app.get(request, response) {} , app.post(request, response) {} etc.), , function receive request , response in parameters 1 of http methods (get, post, put, delete). if can please on starting point of how define methods against route (let's /users ) inside servlet class that'd map http methods while providing request , response in it's parameters. my attempt public class firstservlet extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response) throws servletexception , ioexception { } i believe want servlet mappings . can find a bit more info here but way tell webserver (e.g. tomcat) servlet use answer requests sent given url pattern. map pattern servlet want use serve it. you can find more info on inner w

css - create button with a transparent border that is only on the second part of the button -

Image
want achieve i have header 0.8 transparency , button border of 0.8 in same color. the button need aligned center equal bottom of header. problem when place 0.8 transparency border on header same color , 0.8 transparency going darker. possible solution https://jsfiddle.net/extranion/fnz1ccf0/2/ * { margin:0; padding:0; } body { background-image: url("http://gallery.photo.net/photo/8551440-md.jpg"); } button { background:none; border:none; } header { height:100px; background-color: rgba(41, 52, 61, .8); } .contact { float:right; height:100px; width:200px; position:relative; } .wrap-btn { position:absolute; top:100%; left:50px; height:30px; width:100px; border-radius: 0 0 20px 20px; background-color: rgba(41, 52, 61, .8); } button { position:absolute; bottom:10px; left:10px; width:80px; height:40px; bac

unicode - My Emoji Soft Keyboard is not supporting for Message EditText Field in android -

Image
my emoji soft keyboard not supporting message edittext field in android. other application whatsapp supported. example, in whatsapp , wechat application, textfield support emoji keyboard characters, in mobile messaging textfield shows ? or _ each character type using emoji soft keyboard. want integrate emoji character support in mobile messaging edittext field in android application. if please give me way solve problem, extremely gratitude answer. just try it: int unicode = 0x1f60a; string text = string.valueof(character.tochars(unicode)); //inputconnection.committext(text,mcomposing.length()); mcomposing.append(text); sss.append(text); committyped(getcurrentinputconnection());

r - Why are these numbers not equal? -

the following code wrong. what's problem? i <- 0.1 <- + 0.05 ## [1] 0.15 if(i==0.15) cat("i equals 0.15") else cat("i not equal 0.15") ## not equal 0.15 general (language agnostic) reason since not numbers can represented in ieee floating point arithmetic (the standard computers use represent decimal numbers , math them), not expected. true because values simple, finite decimals (such 0.1 , 0.05) not represented in computer , results of arithmetic on them may not give result identical direct representation of "known" answer. this known limitation of computer arithmetic , discussed in several places: the r faq has question devoted it: r faq 7.31 the r inferno patrick burns devotes first "circle" problem (starting on page 9) david goldberg, "what every computer scientist should know floating-point arithmetic," acm computing surveys 23 , 1 (1991-03), 5-48 doi>10.1145/103162.103163 ( revision availa

How to configure Spring Webflow -

i setting environment. i'm getting error whenever adding xml bean files spring elements: cannot locate beandefinitionparser element [flow:executor] my flow is: <webflow:flow-executor id="flowexecutor" > <webflow:flow-execution-listeners> <webflow:listener ref="jpaflowexecutionlistener" /> <webflow:listener ref="facescontextlistener" /> </webflow:flow-execution-listeners> </webflow:flow-executor> and default configurations are: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config" xmlns:faces="http://www.springframework.org/schema/faces" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/

asp.net - Is using XSP4 from Mono behind Nginx as a reverse proxy production proof? -

when reading mono docs , says xsp not suited production: for getting started, familiar mono , asp.net, xsp ideal solution. keep in mind xsp limited server , useful acquainted asp.net , mono, support http 1.0 , not provide extensibility or configuration. we developing rest api, , thinking of following setup: linux server asp.net mono run in xsp4 nginx reverse proxy (which can handle load balancing, caching, static files, etc.) but i'm wondering whether remarks xsp not suited production apply configuration part, or performance? our performance demands large requests, not processing high number of requests (but if necessary, scale multiple instances of application in xsp4).

performance - Show images or video or text in ListView in Android -

i trying understand best in case have listview , set text content on textview. there can photo type or video, still have textview in row. should best, have "just in case" imageview , videoview , show them when it's case? thinking of performance well. being custom adapter, least of logic faster render. this row xml: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/transparent" android:orientation="vertical" > <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/activity_horizontal_margin" > <com.pubble.moderator.utils.circleimageview android:id="@+id

junit4 - Testing an array of object in Junit, but import can not be resolved -

Image
i trying test if insert function works. eclipse giving me import error. have junit4 in built path. here solution class public class solution { public class interval { int start; int end; interval() { start = 0; end = 0; }; interval(int s, int e) { start = s; end = e; }; } public static arraylist<interval> insert(arraylist<interval> intervals, interval newinterval) { // more code here solutiontest class import solution.interval; // error: import solution can't resolved public class solutiontest { @before public void setup() { arraylist<interval> er = new arraylist<interval>(); //imoprt interval system.out.println("start"); } i suspect problem go away if put code in package other default package. compiler thinks solution package, , cannot find class or interface named interval in solution package. also, if want able create interval without

Open/closing lines in Eclipse IDE -

is there way enable (like in other text editors) vertical (normally doted) lines marks/guides example "if"/method/etc opens , closes? thanks. imho there no such setting/preferences provided eclipse. can try edit box plugin. colors every blocks in code.

c# - How to select an attribute value in an XML and concatenate it with a string and use it as an attribute value in a new XML using XSLT -

i need transform existing xml xml using xslt. the problem facing need use "typename" attribute ecclass , concatenate http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1# the xml working - <ecschema> <ecclass typename="abc"> <baseclass>pqr</baseclass> <baseclass>xyz</baseclass> </ecclass> <ecclass typename="ijk"> <baseclass>mno</baseclass> <baseclass>def</baseclass> </ecclass> <ecschema> for example concatenated result should - http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1#abc first ecclass i need set string attribute value of rdf:about in owl:class tag in new xml structure. the new xml structure - <owl:ontology rdf:about="http://www.semanticweb.org/aman.prasad/ontologies/2015/5/untitled-ontology-1"> <owl:class rdf:about="ht

android - Activity in stack -

ointent.setflags(intent.flag_activity_clear_top | intent.flag_activity_clear_task | intent.flag_activity_new_task|intent.flag_activity_no_user_action); //ointent.setflags(intent.flag_activity_no_history|intent.flag_activity_no_user_action); ointent.putextra("exit", true); startactivity(ointent); finish(); i have use following set of code clear activiites...it works fine...in scenario...the blank activity started...i think because of starting new task in flag...i dont want empty activity/...how solve this? api 21++ activitymanager =(activitymanager) this.getsystemservice(activity_service); list<apptask> ap = am.getapptasks(); ap.get(0).finishandremovetask(); api 21-- from sir @david wasser pointed, use , mantain putextra code , in oncreate of target activity check if has key of exit , call finish() immedi

ios - UIImageView+AFNetworking maxConcurrentOperationCount -

this awesome uiimageview extension has af_sharedimagerequestoperationqueue , max concurrent number set _af_sharedimagerequestoperationqueue.maxconcurrentoperationcount = nsoperationqueuedefaultmaxconcurrentoperationcount; how access private field , set custom value maxconcurrentoperationcount ? (i don't want edit files under cocoapods directly) upd: generatorofone, looks best solution me. however, decided use sdwebimage, because provides cache out of box , allows set maxconcurrentoperationcount in line of code. this private method has static nsoperationqueue. either go , poke code directly not change existing code librarues. suggest create new uiimageview category, expose method , set maxconcurrentoperationcount on it. like, @interface uiimageview(myextension) + (nsoperationqueue *)af_sharedimagerequestoperationqueue; @end @implementation uiimageview(myextension) + (void)load { nsoperationqueue *queue = [self af_sharedimagerequestoperationqueue];

angularjs - use of angular.forEach instead of for -

i new angularjs, please tell how use angular.foreach below code for(i=0;i<$scope.data.tabs.length;i++){ $scope.data.tabs[i]['position']=i+1; } you have remember that... the iterator function invoked iterator(value, key, obj) see https://docs.angularjs.org/api/ng/function/angular.foreach angular.foreach($scope.data.tabs, function(tab, i) { tab.position = + 1; }); so here, tab value of $scope.data.tabs[i] , i index of each tab in array.

opencv - Capture video using FFmpeg in Android -

i've made simple camera app learn how capture video on android device. clip recorded of mediarecorder library. preview shown in videoview before recording starts, , continues show during actual recording. have understood, recording of videos can done creating intent , calling external activity, result in previous activity paused , destroyed (correct?). anyways, project prefer first approach, not leave activity. unfortunately, experience issues mediarecorder library due known bug (which way seems have been around years). have come across ffmpeg , "touchtorecord" (link below) demo project uses ffmpeg recorder javacv capture videos touching screen. awesome! except not want start camera new activity, in example. want remain in same activity , see preview , record in videoview directly. touch videoview record isn't necessary. think it's possible use same library (javacvvideorecorder), creator of demo project have been using, this? or there better way have not yet

asp.net - VS2008 VB Button fires in Firefox & Chrome but not in IE 11 -

my simple webform program has submit button fires uneventfully in current versions of firefox , chrome, not fire in ie 11. other programs in same project have similar buttons fire in 3 browsers. no error messages, running breakpoints shows never hits .click sub. happens when running in local mode on real webserver (sorry, it's behind our firewall, can't demo it). here's button code: <asp:button id="btnsubmit" runat="server" text="submit" /> and in designer: protected withevents btnsubmit global.system.web.ui.webcontrols.button and in .vb: protected sub btnsubmit(byval sender object, byval e eventargs) handles btnsubmit.click --some code-- end sub note in handles code directly above, there breakpoint on protected sub line never touches (and on other programs in project when tested). doesn't matter if there's code in or not, doesn't sub @ all. (suggestions similar incidents found via google) there no validators

bash - RPM: include a set of constants -

so i know how define macros , include these in main spec file. however, want able include set of constants; this: hostnames.spec %define host1 host1 %define host2 host2 ... main.spec %include hostnames.spec ... checkhost %{host1} is there way rpm? perhaps can: according more "rpm argh" or how use %includes , rpm (no version mentioned) allows %include , provided list (and package) included files sources in rpm. blog entry goes on mention complicates include path, making refer ../sources (under rpmbuild directory) rather within build-directory. another ( can rpm spec file “include” other files? ) asserts "sufficiently recent versions of rpmbuild support %include", , reiterates problem include-directories. "sufficiently recent" might not problem, since feature mentioned in 2002 report rpm 3.0.6 ( two issues related %if , %include ).

javascript - Parsing JSON to HTML table using jQuery -

i using below code parse json file, getting undefined in each table column. <!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function () { var json = [{ "rate_upload_date": "07/01/2015 8:17 ct", "groups": [ { "name": "conforming fixed rate mortgage purchase", "product": [ { "descr": "30 year fixed rate", "rate": "4.25", "apr": "4.277", "points": "0", "<payment_stream_url>": "https://publicservices.mortgagewebcenter.com/paymentstream.aspx?cobranderid=1152&criteriaid=113444902&resultid=58" }, {