Posts

Showing posts from July, 2011

jquery - 24 hour Countdown timer using Javascript and PHP -

i need 24 hour countdown timer image in link. need implement timer wordpress site. timer should reset every night @ midnight est. this current js code restarts each time refresh page. can somehow integrate est? <script type = "text/javascript"> var timeinsecs; var ticker; function starttimer(secs) { timeinsecs = parseint(secs); ticker = setinterval("tick()", 1000); } function tick( ) { var secs = timeinsecs; if (secs > 0) { timeinsecs--; } else { clearinterval(ticker); starttimer(172800); // start again } var hours= math.floor(secs/3600); secs %= 3600; var mins = math.floor(secs/60); secs %= 60; var pretty = ( (hours < 10 ) ? "0" : "" ) + hours + ":" + ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs; document.getelementbyid("countdown").innerhtml = pretty; } starttimer(86400); // 24 hours in seconds </script

r - Aggregating duplicate rows by taking sum -

following on questions: 1. identifying whether set of variables uniquely identifies each row of data or not; 2. tagging rows duplicates in terms of given set of variables, aggregate/consolidate duplicate rows in terms of given set of variables, taking sum. solution 1: there guidance on how here , when there large number of levels of variables form index, ddply method recommended there slow, in case trying tag duplicates given set of variables. # values of (f1, f2, f3, f4) uniquely identify observations dfunique = expand.grid(f1 = factor(1:16), f2 = factor(1:41), f3 = factor(1:2), f4 = factor(1:104)) # sample rows , rbind them dfdup = rbind(dfunique, dfunique[sample(1:nrow(dfunique), 100), ]) # dummy data dfdup$data = rnorm(nrow(dfdup)) # aggregate duplicate rows taking sum dfdupagg = ddply(dfdup, .(f1, f2, f3, f4), summarise, data = sum(data)) solution 2: the second solution use data.table , , fo

Writing welcome message with username PHP -

hi quick question, wandering how can output string alongside username generated using sessions i want code : "welcome, (username)" this code far outputs username of person logged in, want add "welcome" in front of username. <?php if (isset($_session['username'])){ echo '<div id="welcome_msg">' .$_session['username']. '</div>'; } ?> you can add non-php content within quotes in echo statement like: echo '<div id="welcome_msg">welcome ' .$_session['username']. '</div>';

jquery - MVC return a value from a jqueryui dialog modal -

Image
i have simple dialog box opens on page ready, here code this code on view $(document).ready( //dialog $("#dialog").dialog({ title: "dialog box", height: 300, modal: true, open: function(event, ui) { $(this).load("@url.action("testdialogview", "card")"); } }) ); now opens dialog modal fine view contents of testdialogview. draw table in dialog (i can view), want try , is, when user clicks 1 of items in table, id of item posted view on, , id passed model. example steps step 1: users loads cardtypes page step 2: dialog box shows list of items step 3: when clicking "view" link in table row step 4: id of item posted dialog step 5: dialog closes step 6: variable selectedid on cardtypes view model populated id posted dialog. cheers ---update--- here screen shot of dialog, and here view renders it

jquery - Manipulate serialize ajax data to php -

i'm struggling reading post data ajax post in php code. i'm neither expert php nor jquery, learn few weeks ago. sorry if dont use yet terminology. serialize data ajax because have more field in form. here sake of clarity, show 1 field. i'm trying read each variable, example comment in case, try print_r($_post) , got error. cannot see how do, converting or syntax error. appreciate insights php file public function ajaxsave($post_id) { print_r($_post); } jquery script $('body').on('click','#savecomment',function(e) { $("#comment-form").submit(function(e) { var postdata = $(this).serialize(); alert(postdata); $.ajax( { url : "ajaxsave.php", type: "post", data : postdata, datatype:"json", success:function(dat

thrift - How can I trace the failure ot TSaslTransport (hive related) -

i've been debugging jdbc connection error in hive, similar asked here: hive jdbc getconnection not return . by turning on log4j properly, got down seeing , before getconnection() hangs. thrift waiting ? if related using wrong thrift apis, how can determine versioning differences between client/server? i have tried copying libraries hive server onto client app test if kind of minor thrift class versioning error, didnt solve problem, jdbc connection still hangs. 0 [main] debug org.apache.thrift.transport.tsasltransport - opening transport org.apache.thrift.transport.tsaslclienttransport@219ba640 0 [main] debug org.apache.thrift.transport.tsasltransport - opening transport org.apache.thrift.transport.tsaslclienttransport@219ba640 3 [main] debug org.apache.thrift.transport.tsaslclienttransport - sending mechanism name plain , initial response of length 14 3 [main] debug org.apache.thrift.transport.tsaslclienttransport - sending mechanism name plain , initial re

html - Html5 Canvases Have Max Size - What about Images? -

html canvases have max sizes depending on device/browser. eg mobiles have 1000x1000 canvas max. images stored in memory? can these ram of phone/pc? can 'drawimage' large images these 1000x1000 canvases auto-cropping? (i don't have phone test specific device.) the max size of image object browser or memory dependent. more question... the image object draw canvas can larger canvas. this causes canvas become "viewport" image. for example: your canvas 1000x1000. your image 1500x1500. if image pixels cropped @ x>1000 , y>1000. // canvas shows image pixels x=0-999 , y=0-999 drawimage(yourimage,0,0) if image pixels cropped @ x<200 & x>1200 , y<200 , y>1200. // canvas shows image pixels x=200-1999 , y=200-1999 drawimage(yourimage,-200,-200) a mental exercise see how works imagine piece of paper rectangle "viewport" cut it. move larger-than-viewport image behind paper. part of image visible through v

Expected an identifier and instead saw 'else'. Missing semicolon in JavaScript -

this code have atm. "expected identifier , instead saw 'else'. missing semicolon." "else" in - if(fight === "fight"); { alert("you fought pikachu , won!"); } else { alert("you ran pikachu , got away saftey"); } should obvious error message, if statement not end semicolon. replace if(fight === "fight"); // <- syntax error { alert("you fought pikachu , won!"); } else with if(fight === "fight") { alert("you fought pikachu , won!"); } else as shortening, start removing uneccessary switch / case -> http://jsfiddle.net/adeneo/nank9/

javascript - Create a JSON Array from dynamic values in jquery -

i need create array {"groupslist":{"groupname":["user1","user2","user3"],"groupname2":["user1","user2","user3"],"groupname3":["user1","user2","user3"]}} values different ajax call server, in first ajax call grouplists groupname, groupname2 etc , in success function make ajax call each groupname , user particular groupname , create array , push main grouplist, output getting not correct think have use callbacks make correct, please me , tell me ` $.ajax({ url: 'get_group_list', type: 'post', success: function (data) { groupnamess=data.replace("[","").replace(/"/g, "").replace("]","").split(','); console.log("groupnameeeee",groupnamess); for(var in groupnamess) { grup[i]=groupnamess[i]; userss.push({ label:g

web services - apt vs wsgen vs wsimport .Confusion on what to use when and why not to use the other -

i have been trying write web service (jax-ws) , have gone through number of tutorials ranging 2006 2013 ones. of them respect ide. talk manual creation/deployment of web service ant scripts. till here fine. the moment check ant scripts, confusion starts. old tutorials use apt task compile sei , wsgen used generate artifacts. newer ones use wsgen (although apt defined taskdef in ant scripts). , have been reading java 7 documentation, says dont need use wsgen javac compilations , artifacts req. ws generated @ runtime dynamically. i tried use javac command on sei , deployed on tomcat didnt work. can please clarify in commands need use in java se 7 edition deploy web service. also, want know each command generate , when use commands. according knowledge wsimport not needed development , deployment , need build ws-client. correct? if not please provide me pointers clear understanding. thanks in advance also if repeat self sorry new stackoverflow , not familiar this. :)

osx - Not sure if correct httpd-vhosts.conf file is being read in OS X -

i'm trying apache server comes os x work local website. no matter change file httpd-vhosts.conf to, when run httpd -s in terminal says virtual host syntax ok. typed in bunch of random characters file, restarted apache, , still says configuration ok. first edited /private/etc/hosts , added line underneath 127.0.0.1 localhost : 127.0.0.1 mysite then edited /private/etc/apache2/httpd.conf . uncommented line: # virtual hosts include /private/etc/apache2/extra/httpd-vhosts.conf i uncommented php5 line enable php. next edited /private/etc/apache2/extra/httpd-vhosts.conf , set virtual hosts. after restarting apache, virtual hosts not working , running httpd -s said virtual hosts syntax ok. no erros in apache error log. httpd-vhosts.conf file contained: namevirtualhost *:80 <virtualhost *:80> documentroot "/users/gavin/web" servername localhost </virtualhost> <virtualhost *:80> documentroot "/users/gavin/web/mysite/pu

google app engine - Write Cron Job in Java on GAE to Run BigQuery -

i want run cron job on gae internally calls bigquery. i able run bigquery need log in credentials. run cron job bigquery without login. any highly appreciated. i know it's not java you're expecting. secret use appassertioncredentials. here python sample: from apiclient.discovery import build oauth2client.appengine import appassertioncredentials import httplib2 google.appengine.api import memcache scope = 'https://www.googleapis.com/auth/bigquery' credentials = appassertioncredentials(scope=scope) http = credentials.authorize(httplib2.http(memcache)) return build("bigquery", "v2", http=http)

regex - jquery - replace matched character -

i want replace comma followed < br > used regex et replace method that: var str = "<a class=added> ,,, ,, blbl;test, </a><br>, <a class=added>" str = str.replace(/br>(,\s)/g, " "); alert(str); in result noticed 'br>' removed , not exected result. there wrong regex? "<a class=added> ,,, ,, blbl;test, </a>< <a class=added>" you doing regex match correctly not replacing correctly. should replace string: "br> " as follows: >>> str = str.replace(/br>(,\s)/g, "br> "); "<a class=added> ,,, ,, blbl;test, </a><br> <a class=added>"

java - Repaint JPanel from different class -

i'm having problems repainting class after have added object it. public class window extends jframe { /** * */ private static final long serialversionuid = 1l; private mediahandler mymediahandler = new mediahandler(this); class menuactionlistener implements actionlistener { @override public void actionperformed(actionevent e) { string buttontext = e.getactioncommand(); switch(buttontext) { case "add movie": addmoviewindow addmoviegui = new addmoviewindow(mymediahandler); addmoviegui.setvisible(true); break; case "add tv-show": addtvshowwindow addtvshowgui = new addtvshowwindow(mymediahandler); addtvshowgui.setvisible(true); break; } } } public window() { // mymediahandler.addmovie("nineteen eighty-four", 113.00, 1984, "michael radford", "mediapath", "https://dl.dropboxusercontent.com/u/16670

java - How to invoke shutdown hooks of a program running in another thread -

i writing automated tests swing application using jemmy framework. my test suite run application invoking main method of main class in new thread. i have written lot of gui-related tests have got more complex task. i need check if tested application clean of folders when being closed. action executed shutdown hook. somehow possible invoke shutdown hooks of application without calling system.exit(0) ? when command called both threads terminated. want thread tests continue running after tested application closed can check if folders still exist or not. somehow possible invoke shutdown hooks without changing architecture of test suite? i found this, didn't test it: applicationshutdownhooks.hook().run(); // jre 6 applicationshutdownhooks.runhooks(); // jre 7 as can see, names of methods changed on time, means shouldn't this. however, think should job, class private. using reflection, force execution of it. // jre 7 try { class cl = class.forname(&qu

subprocess - create background process with Python's Popen -

i'm new bie python. recently, face problem python popen, , hope can me. :d a.py #!/usr/bin/env python import b b.run() while true: pass b.py #!/usr/bin/env python import subprocess def run(): subprocess.popen(['ping www.google.com > /dev/null &'], shell=true) run() when run b.py , grep process status $ ps aux | grep test 35806 0.0 0.0 2451284 592 s010 sl 10:11 0:00.00 ping www.google.com the ping process runs in background state sl. and try run a.py $ ps aux | grep test 36088 0.0 0.0 2444116 604 s010 sl+ 10:15 0:00.00 ping www.google.com ping process state changes sl+, , if stop a.py ctrl + c , ping process terminated. is there way make ping process run in backgroud, , not affected when stop a.py? , why ping process state changes sl sl+? after resea

c++ - OpenCL get_global_id probably return -

i have suspiciton of multiple calls of opencl kernel same get_global_id(0) return value. calling host: err = commandqueue.enqueuendrangekernel(my_kernel, cl::nullrange, cl::ndrange(1024), cl::ndrange(256), null, null); and kernel: typedef struct { float x, y; } point3; __kernel void update_position ( __global point3* pts, __global point3* speed, const unsigned int count, const float t) { unsigned long = get_global_id(0); if (i < count) { pts[i].x += speed[i].x * t; pts[i].y += speed[i].y * t; } } what want update every item of 1024 pts once , once. problem running program multiple times various non-valid results. guess get_global_id(0) not return unique number between 0 , 1023 (inclusive) body of kernel executed more once. unfortunatelly official web api of khronos being down , haven't found suitable answer/solution. should use other function determine core/thread code runs on? or ndrange s called wrong? thank

Filling dynamic array of structs in C -

i allocate array of struct in function, cannot fill structures values in same function. #include<sys/sem.h> void setsemaphores(int n, struct sembuf **wait){ *wait = malloc(n * sizeof(struct sembuf)); wait[3]->sem_op = 99; //causes error: segmentation fault (core dumped) } int main(int argc, char *argv[]) { int n = 4; struct sembuf *wait; setsemaphores(n, &wait); wait[3].sem_op = 99; //works fine return 0; } in setsemaphores() : wait pointer 1 variable of type struct sembuf , not array of them. thus, wait[3] ub. wanted (*wait)[3].sem_op . another tip: change *wait = malloc(n * sizeof(struct sembuf)); *wait = malloc(n * sizeof **wait); . that avoids using wrong type in sizeof.

javascript - pick specific checkbox value -

i have checkboxs same name each has unique value. want on click on specific checkbox unique value of cpecific clicked checkbox. @foreach (var itert in model.collec) { @html.checkbox("chkresend", new { @value = html.encode(itert.eventnumber), @class = "myclass" }) }; the jquery is: $(document).ready(function () { $(".myclass").click(function () { alert($(".myclass").attr("value")); }); }); all time value of first checkbox... use this keyword $(document).ready(function () { $(".myclass").click(function () { alert(this.value); //this refers current element clicked // or alert($(this).attr("value")); // or alert($(this).val()); }); });

java - Xuggler - Getting snapshots from RTMP stream -

i'm using last xuggler lib on java 7 (macos maverix). need png snapshot live rtmp stream served wowza. for i'm using default com.xuggle.xuggler.demos.decodeandcaptureframes. there problems: reader.readpacket() has delay of ~5 minutes (it seems xuggler tries buffer or guess format, difficult explain) after delay, external process starts (i guess it's ffmpeg) , cpu usage 100%. in parallel high cpu load, see png files created correctly, after 2-3 minutes following exception 14:40:35.785 [main] error org.ffmpeg - writen, rtmp send error 32 (14 bytes) 14:40:35.790 [main] error org.ffmpeg - writen, rtmp send error 32 (42 bytes) any idea? i found solution: had manually set probesize property on icontainer 2048 , works.

asp.net - multiple domains on windows azure virtual machine -

i have created windows azure virtual machine , opened port 80 default website myapp.cloudapp.net have pointed custom domain www.mycustomdomain.com myapp.cloudapp.net working fine. have created website in iis port 81 have checked working on vm add custom domain website on 81 , don't understand how because ip , dns same , how give custom domain 2nd website? domains should set in iis. need define host headers each website hosted on server. means don't have define non-standard ports. configuring host headers

c++ - I don't understand the working of the following Macro -

what mathematical equivalent equation of following macro #define sq(a) (a*a ) int answer sq(2 + 3 ); output 11 case , int answer sq(2 + 4); is 14 can't figure out equation outputs. the macro defined lacks brackets keep arithmetic working want. remember preprocessor macros doing text replacement solely. you'll calling shown expands int answer (2 + 4 * 2 + 4); and according operator precedence result 14 . write macro #define sq(a) ((a)*(a)) to result expected.

CSS put html entity as content -

this question has answer here: adding html entities using css content 8 answers using css content property, trying make put html entity after element. here html : <table id="tic" cellpadding="0" cellspacing="0" border="5" bordercolor="black" bordercolorlight="gray" bgcolor="white"> <tr> <td width="55" height="55" class="x"></td> <td width="55" height="55" class="o"></td> <td width="55" height="55" class="x"></td> </tr> <tr> <td width="55" height="55" class="o"></td> <td width="55" height="55" class="x"></td>

jquery - Ajax request in Phonegap not working -

i have been facing issue, ajax request sent application not seem work. phonegapp android, trying run sample in android emulator eclipse. 1) failure callback getting called every time. 2) status code 0 , responsetext null. i have gone through many links , questions none of them helped. phonegap jquery ajax request not work . i have change config.xml origin="*" temporarily. config.xml under resources origin=".*" here sample code snippet using. $.ajax({ url: "http://192.168.0.189/gcm/register.php", type: 'post', data: data, beforesend: function() { }, success: function(data, textstatus, xhr) { console.log("ajax success : " + textstatus); }, error: function(xhr, textstatus, errorthrown) { console.log(xhr.responsetext + " status : " + xhr.status); } }); response text comes null status 0 seems awkwar

c++ - CPU instruction reordering -

our processors allowed reorder instruction in order gain performance benefits, may cause strange behaviour. i'm trying reproduce 1 of issues on base of this article . this code: int a,b; int r1,r2; mutex m1,m2; void th1() { for(;;) { m1.lock(); a=1; asm volatile("" ::: "memory"); r1=b; m1.unlock(); } } void th2() { for(;;) { m2.lock(); b=1; asm volatile("" ::: "memory"); r2=a; m2.unlock(); } } int main() { int cnt{0}; thread thread1{th1}; thread thread2{th2}; thread1.detach(); thread2.detach(); for(int i=0;i<10000;i++) { m1.lock(); m2.lock(); a=b=0; m1.unlock(); m2.unlock(); if(r1==0&&r2==0) { ++cnt; } } cout<<cnt<<" cpu reorders happened!\n"; } i use mutexes sure 'main' thre

Foursquare API and Google maps using Python -

i want plot foursquare users check ins listed longitudes , latitudes on map .. tried plot them using venus functions not displayed. why? , if want connect google maps, how ?? 1) check-ins foursquare you can latitude/longitude coordinates user checkins endpoint: https://developer.foursquare.com/docs/users/checkins from response you'll need iterate through venues get: response.checkins.items[i].venue.location.lat response.checkins.items[i].venue.location.long 2) plot points on map if you're making in google apps, can populate spreadsheet using coordinates (and else) got, , produce map. there's example instructions here: http://gmaps-samples.googlecode.com/svn/trunk/spreadsheetsmapwizard/makecustommap.htm

javascript - What has the best cross-browser support, JQuery dialogs or HTML5 modal dialogs? -

i trying create online app needs have multiple items of content open @ 1 time. have looked @ jquery dialogs , html5 modal dialogs. of these should choose best cross-browser support? there different implementation work better? sounds maybe jquery ui's dialogs you're looking for? set aside html in container (such div) , render dialog box. link: https://jqueryui.com/dialog/ to "create" dialog, you'll need create dialog container whenever need visible. such as: <script type="text/javascript"> $('#mypopup').dialog(); </script> that page has example of how started. more detail can them (such adding buttons), check out full api page: link: http://api.jqueryui.com/dialog/ even better - can use custom themes or variety of premade themes jquery ui. check out themeroller ( http://jqueryui.com/themeroller/ ) started. finally, you'll need have both jquery ( https://jquery.com ) , jquery ui ( https://jqueryui.com/

java - multiple Jpanel with same functionality buttons -

i want create jframe multiple panel each panel displaying information database (say product_id , description ) , each frame have button(add cart) add information panel cart table in database how implement this? i try things using jtable display such data, each column displaying database field. i'd add column, boolean column displays check box, , assess state of column when needing decide add cart. edit ask: how know how quantity of product selected, then add quantity field well, perhaps 1 uses jspinner editor. and thinking add image of product can in jtables absolutely. knows how display imageicons instance. please have @ my answer question example.

osx - libpng version incompatibility in fresh installation of IPython -

i used this guide install "scientific stack" python (osx 10.9.2, brewed python 2.7.6, ipython 2.0, matplotlib 1.3.1, libpng 1.6.10). looking good. however, trying run simple plot in ipython's notebook environment --pylab=inline gives me error: /usr/local/cellar/python/2.7.6/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/ipython/core/formatters.py:239: formatterwarning: exception in image/png formatter: not create write struct formatterwarning, and in terminal says: libpng warning: application built libpng-1.5.17 running 1.6.10 i have no other libpng installed far can tell. tried deleting files beginning libpng /usr/local/ , reinstalling everything, no avail. output building matplotlib ( pip install matplotlib ) contains: building matplotlib matplotlib: yes [1.3.1] python: yes [2.7.6 (default, mar 16 2014, 15:04:47) [gcc 4.2.1 compatible apple llvm 5.1 (clang-503.0.38)]]

c++ - Poco SecureServerSocket without SSLManager -

i want use poco secureserversocket construktor context, got exception: ssl exception: error:140c5042:ssl routines:ssl_undefined_function:called function should not call i don't want use sslmanager. code: socketaddress sendsockadr2("127.0.0.1", 8080); poco::net::initializessl(); context::ptr pcontext = new poco::net::context( poco::net::context::client_use, "", "", "cacert.pem", poco::net::context::verify_relaxed, 9, true, "all:!adh:!low:!exp:!md5:@strength"); secureserversocket sendsecsrv2(sendsockadr2,64,pcontext); i have bad flag in context...i had client_use instead of server_use...now works socketaddress sendsockadr2("127.0.0.1", 8080); poco::net::initializessl(); context::ptr pcontext = new poco::net::context( poco::net::context::server_use, "", "", "

Octave does not plot -

when try plot graph on gnu octave, , try use plot, gives me following output set terminal aqua enhanced title "figure 1" size 560 420 font "*,6" dashlength 1 ^ line 0: unknown or ambiguous terminal type; type 'set terminal' list i using mac os x 10.9.2. have tried using octave:79> setenv("gnuterm","x11") but still same error. setenv("gnuterm","qt") solves problem.

apache - Sailsjs behind Apache2 proxy logging socket errors -

i following log lines each connection: info: handshake authorized bqumvcf9ktcmvuoxcxg5 warn: websocket connection invalid info: transport end (undefined) and apache2 error log shows @ same time: [sun apr 06 15:09:16 2014] [error] [client 24.84.162.51] (20014)internal error: proxy: error reading status line remote server localhost:7000 [sun apr 06 15:09:16 2014] [error] [client 24.84.162.51] proxy: error reading remote server returned /socket.io/1/websocket/bqumvcf9ktcmvuoxcxg5 is there can in sails adjust socket.io behaviour? mean, pages loading, , things appear connecting up, unhappy, , i'm nervous when log files aren't silent. aren't you? if you're not using socket.io wont notice issues other socket.io complaining can't connect. however, proxying websocket can tricky. haven't ever done apache nginx 1.3 added support websockets. if it's helpful or others here nginx config proxy websocket server { listen 80; server_

php - Creating unique GUID -

i have php code generating guid mt_srand((double)microtime()*10000);//optional php 4.2.0 , up. $charid = md5(uniqid(rand(), true)); $hyphen = chr(45);// "-" $uuid = //chr(123)// "{" substr($charid, 0, 8).$hyphen .substr($charid, 8, 4).$hyphen .substr($charid,12, 4).$hyphen .substr($charid,16, 4).$hyphen .substr($charid,20,12); //.chr(125);// "}" return $uuid; and storing in db,i wanted unique guids not present in db.should check guid each time when create db?please me generate unique guids not generate duplicate 1 chance

c# - Auto Dispose Sql Connections properly -

my application using 3 layers: dal / service / ul. my typical dal class looks this: public class ordersrepository : iordersrepository, idisposable { private idbconnection _db; public ordersrepository(idbconnection db) // constructor { _db = db; } public void dispose() { _db.dispose(); } } my service calls dal class (injecting database connection): public class ordersservice : idisposable { iordersrepository _orders; public ordersservice() : this(new ordersrepository(new ajx.dal.dapperconnection().getconnection())) { } public ordersservice(ordersrepository ordersrepo) { _orders = ordersrepo; } public void dispose() { _orders.dispose(); } } and within ui layer, how access service layer: public class orderscontroller : controller, idisposable { // // get: /orders/ private ordersservice _orderservice; public orderscontroller():this(new ordersservice())

ember.js - How to get currentPath and dynamic segment in Controller -

is there 'ember' way current dynamic segment? available in route via params, how access them arraycontrollers ? any solution this.get('controllers.application.currentpath') ? of course window.location.hash there, ember way more efficient. [update] basically doing (its photo gallery). there 1 model (photo). 1 sample: { id: 1, name: 'brad-pitt', date_added: 'sat apr 05 2014 23:04:35 gmt+0530 (ist)', link: 'example.com', image: 'http://www.somewebsite.com/image.jpg', rank: 20 } routes : app.router.map(function(){ this.route('index', {path: '/'}); this.route('photos', {path: ':name'}); }) / shows models, sorted rank. /brad-pitt again, shows all models, filters ones have name = 'brad-pitt' /brad-pitt?p=1 shows all models, filters name = "brad-pitt" , highlights 1 id 1 (masonry m2 specific). controller : app.photoscontroller = ember.arra

generics - Why using weak typing array for Vector, ArrayList and the whole Java collection framework -

i wondering why didn't vector api (as others) choose use strong typing underlying array code below ? why using week typing object ? isn't better strong typing type safety resolved in compile time ? public class vector<e> { private static final initialcapacity = 2; protected e[] elementdata; private vector(class<e> c) { @suppresswarnings("unchecked") final e[] elementdata = (e[]) array.newinstance(c, initialcapacity); } } vector , arraylist , , whole collections framework written before generics thing in first place. didn't have alternative @ point, , had left way backwards compatibility.

php - How to serve a file for download on WordPress -

this question has answer here: how fix “headers sent” error in php 11 answers i'm trying allow users download csv of database query on wordpress site. it's not download of static file, query based off of user logged in , page viewing, lot of download management plugins no allow specific file download. file not generated until user something. i've made web service able correctly format , generate file, can't figure out how serve download. right now, download button goes web service's page. php error says, "cannot modify header information. headers sent (long path location of web service)" dagon's answer correct, though found out "output" single blank space before opening php tag.

android - How to draw a top border on a bottom navbar -

Image
i'm trying draw margin @ top of bottom navbar on android app. here it's have now: what i'm trying achieve black top border on bottom bar. created using split action bar. xml: <?xml version="1.0" encoding="utf-8"?> <resources> <!-- theme applied application or activity --> <style name="customactionbartheme" parent="@android:style/theme.holo.light"> <item name="android:actionbarstyle">@style/myactionbar</item> <item name="android:actionbarsplitstyle">@style/mybottombar</item> </style> <!-- actionbar styles --> <style name="myactionbar" parent="@android:style/widget.holo.light.actionbar.solid.inverse"> <item name="@android:background">@color/white</item> <item name="@android:textcolor">@color/black</item> &l

java - ORMLite: Foreign collection class does not contain a foreign field of class exception -

i'm trying understand little bit orm tools android persistence sqllite, decided write little test application. however, can't seem figure out. seem have done in account, orders example ormlite docs. however, keep getting same error: foreign collection class com.example.dataobjects.locationobject field 'locations' column-name not contain foreign field of class com.example.dataobjects.tripobject i'm trying make one-to-many relationship between locationobject , tripobject (one tripobject has many locationobjects) locationobject: @databasetable public class locationobject { private static final string trip_id_field_name = "trip_id"; @databasefield(generatedid = true) private int id; @databasefield private double latitude; @databasefield private double longitude; @databasefield(foreign = true, foreignautorefresh = true, columnname = trip_id_field_name) private tripobject trip; public locationobject() { } public locationobject(tripobject

gradle - Android App Installation Failed With Error: [INSTALL_FAILED_DEXOPT] -

to preface question, have looked @ similar questions can find on stackoverflow , around web no success. have been developing using real device months no issue. yesterday updated android studio, had been working with, version 0.5.4. update required upgrade gradle version 0.9 apparently build system has major changes. since upgrading ide, when try run project on device, following output in run console: run console output waiting device. target device: samsung-sch_i605-42f7bff119a3bf69 uploading file local path: c:\users\student\android studioprojects\drunkmodeandroid\drunkmode\build\apk\drunkmode-debug-unaligned.apk remote path: /data/local/tmp/com.launchfuture.drunk_mode installing com.launchfuture.drunk_mode device shell command: pm install -r "/data/local/tmp/com.launchfuture.drunk_mode" pkg: /data/local/tmp/com.launchfuture.drunk_mode // line red failure [install_failed_dexopt] // line red logcat output 04-06 14:44:00.066 80

Creating a mysql php link for the user to create a post in the forum -

i'm trying create forum, following tutorial https://www.youtube.com/watch?v=kebwxi1bw88 . i've followed succesfully untill point reason link user go , create forum post within topic not working. can see problems code or spot reason why isnt working. cant see wrong code , have followed tutorial letter. the link within first if statement. the link should appear on page , file create_topic.php hasnt been created yet. <?php session_start();?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>forum</title> <link href="styles.css" rel="stylesheet" type="text/css"> <script>var __adobewebfontsappname__="dreamweaver"</script> <script src="http://use.edgefonts.net/source-sans-pro:n6:default.js" type="text/javascript"></script> </head> <body> <div id="wrapper"> <header id="top">

parsing - Split text in list of lists depending on delimiter, in one pass -

i've large ascii delimited text file looks this: 10000\x1f4959\x1f\4567\x1f\x1f\x1e20000\x1f456\x1f456\x1f\x1f\x1e... the desired result list of lists like: [[10000,4959,4567],[20000,456,456],...] i can in 2 passes, first using text.split('\x1e') , using loop split each sublist on '\x1f' . but there way achieve same result in 1 pass? assumptions "...[i]s there way achieve same result in 1 pass?" i assume mean iterating on contents of "large ascii delimited text file" once. i further assume posted snippet representative sample of data. overview you have 3 things here in nested structure: the strings (the records) the sublists (lists of strings delimited record separator) the outer list (the list of sublists given large file) based on sample data, both strings , sublists short, should able relatively expensive operations on them without performance loss. it's outer list want optimize for, , want make

Using MD5 in MySQL -

i want use hash verify email existence. i've tried code , somehow doesn't work. there mistake or should elsewhere? the code: select id users md5(email+'*salt*')='*some value*' , checked='0' you don't use + concatenate strings. use concat : select id users md5(concat(email,'*salt*'))='*some value*' , checked='0'

objective c - How to use Core-Data best in complex Apps -

i mac app dev , have questions how use core-data correctly. i have multiple tableviews , playing around same data (which want save persistently core-data). know central part of core-data have work - nsmanagedobjectcontext , know how create nsmanagedobjects , save/edit/delete these in persistent store. i'm wondering how organize multiple viewcontrollers,views,tables,.. efficiently and without merge conflicts. i've read approaches that: 1 passing context down delegate through every layer of code. else suggests create singleton-class, let's call databasemanager , holds nsmanagedobjectcontext instance , go , ask there. (i approach, don't know why.) or ask delegate every time [[nsapplication sharedapplication] delegate] , have disadvantages? okay, lot of questions here how . want know recommendations of where should interaction managedobjectscontext . (to in compliance mvc , don't mess code , make more complicated has be..) should save stuff core-data in

How to put socail share button in wordpress post under the post excerpt? -

Image
please tell me there plugin put social share button under wordpress post excerpt? please see image understand want. you can use wordpress plugin called share buttons achieve this. once installed, activated , chosen icons want added. add following page(s) excerpt (just after calling excerpt). <?php if ( function_exists( 'addtoany_share_save_kit' ) ) { addtoany_share_save_kit(); } ?> the code like: <?php the_excerpt(); ?> <?php if ( function_exists( 'addtoany_share_save_kit' ) ) { addtoany_share_save_kit(); } ?> it might different depending on how have done excerpt.

Python pandas - yahoo finance isn't providing GOOG's historical prices? -

can please elaborate on why yahoo stopped giving goog's historical prices? goog's historicla prices page isn't helpful either. code used check: (aapl works, goog doesn't) import pandas.io.data web import datetime print web.get_data_yahoo('aapl', datetime.datetime(2010,1,1), datetime.datetime(2013,12,31))['adj close'] print web.get_data_yahoo('goog', datetime.datetime(2010,1,1), datetime.datetime(2013,12,31))['adj close']

Check whether a string contains a None Type value python -

i writing csv file in python. when try open , read get: typeerror: expected string or unicode object, nonetype found my question is, how can check before write whether string contains none type value. thanks you can use is not (which is recommended compare singletons none ): if some_string not none: # write

Java substring difficulty -

i know how use substring() why isn't working, user inputs equation "5t + 1" space before , after "+". want tvariable hold integer before it, in case 5 , constant should hold constant integer in case 1 , out of range error. import java.util.*; import javax.swing.joptionpane; public class project3030 { public static void main(string[] args) { string l1x, tvariable, constant; l1x = joptionpane.showinputdialog("this format (x=5t + 1)"); int endindex = l1x.indexof("t"); tvariable = l1x.substring(0, endindex); int beginindex = l1x.lastindexof(" "); int endindex2 = l1x.indexof(""); constant = l1x.substring(beginindex, endindex2); system.out.println(tvariable + constant); } } you need change more like constant = l1x.substring(l1x.lastindexof(" ")).trim(); then when add numbers, have parse them before add

php - Wordpress Jquery Load() is loading wrong url due to permalink -

i made template in wordpress theme , have problem jquery load function load html div using load.php file exists in same directory template.php file problem jquery seeing permalink of page instead of seeing correct url/path load.php file. e.g jquery seeing mywebsite.com/permalinkhere/load?variable11=23&variable3=43 gives 404 not found what jquery should see mywebsite.com/wp-content/themes/mytheme/load?variable11=23&variable3=43 how can solve problem? edit: load.php echo html; , working fine outside wordpress. here part of template.php code: <script> $("#first-choice").load("load.php?variable1=load", function() { $("#first-choice").prop("disabled", false); }); </script> yes. java scripts called in html files relative file include java scripts (if use relative path). you can use wp_localize_script set load.php file url. wp_localize_script( 'jquery', 'ajaxload', array( 'ajaxu