Posts

Showing posts from May, 2010

jquery - Export in CSV from JSON in IE through javascript -

how download table rows in csv format in internet explorer client side? @ present using below uri method download in other browser. seems internet explorer not support below mechanism. want support ie version 8 till latest. ie appreciated. var filename = "result"; var uri = 'data:text/csv;charset=utf-8,' + escape(csv); var link = document.createelement("a"); link.href = uri; link.style = "visibility:hidden"; link.download = filename + ".csv"; document.body.appendchild(link); link.click(); document.body.removechild(link); i got solution supporting ie 8+ me. need specify separator shown below. if (navigator.appname == "microsoft internet explorer") { var owin = window.open(); owin.document.write('sep=,\r\n' + csv); owin.document.close(); owin.document.execcommand('saveas', true, filename + ".csv"); owin.close(); } you can go ...

scala - Extract string of "length x breadth" into different arrays -

i have string with multiple length , breadth in format length x breadth separated commas like 300x250, 720x220, 560x80 i convert 2 separate arrays 1 containing length , breadth. expected output length = array(300,720, 560) breadth = array(250, 220, 80) any novel way achieve it? using unzip on tupled values, follows, val dims = "300x250, 720x220, 560x80" dims.split("\\w+").map { s => val array(a,b,_*) = s.split("x") (a.toint,b.toint) }.unzip note first split fetches words without need trimming additional blank characters. in second split extract first , second elements of resulting array .

Where the headers come from when just calling echo in PHP? -

i see come code php manual $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "get / http/1.1\r\n"; $out .= "host: www.example.com\r\n"; $out .= "connection: close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } writing header echo, going work? when calling simple code this: echo 'hello'; where http headers from? what you're doing in code is: open socket connection remote http server (www.example.com on port 80). establishes tcp connection port. you send (via fwrite ) http request on connection. http protocol on top of tcp, , you're manually formulating http protocol headers here. you're reading (via fgets ) (http) response of remote server. i'm guessing want know why see http headers in remote response, though you're do...

java - Multiple editable rows in JTable header -

Image
i need have multiple editable rows in jtable header, same header column contain both jtextfield , jbutton. i have found how implement editable header cells , how split header cells. turned out these approaches different , need fuse them one. is there multiple editable jtable header rows solutions developed , wouldn't need reinvent bicycle? what have found far: editable header row code taken from: http://www.java2s.com/code/java/swing-components/editableheadertableexample2.htm code: import java.awt.component; import java.awt.point; import java.awt.rectangle; import java.awt.event.mouseevent; import java.awt.event.windowadapter; import java.awt.event.windowevent; import java.util.eventobject; import javax.swing.defaultcelleditor; import javax.swing.jcombobox; import javax.swing.jcomponent; import javax.swing.jframe; import javax.swing.jscrollpane; import javax.swing.jtable import javax.swing.jtextfield; import javax.swing.swingutilities; import javax.swing.uim...

parse.com: fetching only 100 results -

i'm struggling knowing how data my code $headers = array( "x-parse-application-id: $app_id" , "x-parse-rest-api-key: $rest_id" , "x-parse-master-key : $master_id ", "content-type: application/json", ); $ch = curl_init($url); curl_setopt($ch,curlopt_url,$url); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch,curlopt_returntransfer, true); $response = curl_exec($ch); $parse_data=json_decode($response,true); print_r($parse_data); but want data @ once or more hundred data how can ? the default limit rest-api calls 100 objects can set limit request (anything between 1 , 1000). from docs: "you can use limit , skip parameters pagination, limit defaults 100, 1 1000 valid limit." [1] https://parse.com/docs/rest#queries-constraints

python - ARGV in Processing -

i have application written in processing using python mode , didn't find in place in processing documentation using argv arguments. need variable value passed parameter determine application behaviour. let things clearly, i'm doing rpm simulator has little circle translation move around big circle. current source is: rpm = 27 def setup(): size(600, 600) rectmode(center) ellipsemode(radius) nofill() stroke(33, 33, 33) smooth() def draw(): background(2, 135, 208) fill(100, 100, 100) ellipse(width / 2, height / 2, 280, 280) translate(width / 2, height / 2) angle = framecount * parameter_table(rpm) x = cos(angle) * 280 y = sin(angle) * 280 fill(23, 187, 176) stroke(10) smooth() ellipse(x, y, 20, 20) def parameter_table(rpm): return 10.0 * 0.01 / (60.0 / rpm) how can dynamically set rpm via command line, calling /home/my_application 27 ?

php - How to get facebook post(keyword search) using API -

i trying facebook public post through keyword search. tried https://graph.facebook.com/oauth/access_token?client_id=your_app_id&client_secret=your_app_secret&grant_type=client_credentials shows error { "error": { "message": "missing redirect_uri parameter.", "type": "oauthexception", "code": 191 } } is possible post. appreciated public post search deprecated, there no way search posts (and keywords) anymore: https://developers.facebook.com/docs/apps/changelog

c# - .NET architecture design issue -

im starting work on particular piece of development. we have .net wcf application, mysql/ef dal/orm, called threaded job scheduler pulls data 1 client, stores in our db , passes latest data client , vice versa. so think messages, clientb sends order clienta through our system transforms order readable format clienta. clienta can send messages clientb through our system stuff "your order shipped" or "your order late". i need take these messages , relay them onto clientb want transactional , have full control on failed messages etc. my current thoughts are, simplicity sake, have ordermessages table in our db receives messages, state of "ready" can processed factory , forwarded relevant client using configuration stored against clients. sorry being on place, i've explained im trying :/ neil your proposed architecture classic queue table pattern. remus rusanu canonical resource building such thing sql server. ideas apply othe...

osx - Talend Open Studio on Mac OS X - Failed to create JVM -

this question has answer here: java application not running on os x yosemite 2 answers i want start talend open studio (esb or di) on mac pro. but error: "failed create java virtual machine". tos version v5.6.0 , have installed java sdk 1.7.0_45 64-bit. i have changed values in tos_esb-macosx-cocoa.ini: --launcher.xxmaxpermsize 512m -vmargs -xms64m -xmx768m -xdock:icon=../resources/talend.icns -xstartonfirstthread -dorg.eclipse.swt.internal.carbon.smallfonts -dosgi.instance.area.default=../../../workspace -dfile.encoding=utf-8 but still same error. i found tos use wrong java version javavm: failed load jvm: /library/java/javavirtualmachines/jdk1.7.0_45.jdk/contents/home/bundle/libraries/libserver.dylib my java_home set /library/java/javavirtualmachines/jdk1.7.0_71.jdk/contents/home how resolve this? it depend on problem https://...

android - error: ``Syntax error on token "heading", delete this token'' in eclipse -

so following tutorial on how make tictactoegame. got error same this: no resource found matches given name (at 'title' value '@string/action_settings') added line in code: <string name="action_settings">settings</string> now got new error: ``syntax error on token "heading", delete token''. error in class: r.java > r > string. this line: public static final class string { public static final int =0x7f0a0028; \\red mark @ int i think error because ``settings'' isnt word should use, im not quit sure. this main.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.tictactoetest.mainactivity" > <item android:id="@+id/action_settings" android:orderincategory=...

unix - Gunicorn socket disappears -

distributor id: ubuntu description: ubuntu 12.04.4 lts release: 12.04 codename: precise gunicorn (version 19.1.1) nginx version: nginx/1.1.19 my gunicorn conf: bind = ["unix:///tmp/someproj1.sock", "unix:///tmp/someproj2.sock"] pythonpath = "/home/deploy/someproj/someproj" workers = 5 worker_class = "eventlet" worker_connections = 25 timeout = 3600 graceful_timeout = 3600 we started getting 502s @ around 2pm yesterday in our dev env. in nginx error log: connect() unix:///tmp/someproj1.sock failed (2: no such file or directory) while connecting upstream" both gunicorn sockets missing /tmp. at 11:55am today ran ps -eo pid,cmd,etime|grep gunicorn uptime: 4156 gunicorn: master [myproj.    22:53:54 4161 gunicorn: worker [myproj.    22:53:54 4162 gunicorn: worker [myproj.    22:53:54 4163 gunicorn: worker [myproj.    22:53:54 4164 gunicorn: worker [myproj.    22:53:54 4165 gunicorn: worker [myproj.    22:53:53 5207 grep...

Are Android support libraries necessary for high minimum SDK versions? -

this question has answer here: is there reason use support.v4 library in android? 3 answers i understand android support libraries provide features not exist yet in low android api levels, example fragment. but then, mean that, example, if specify minimum sdk version of app 14, have no need v4, v7, v8 , v13 support libraries? viewpager commonly used class available in support libraries. there other classes available in support libraries. classes fragments included in support library backwards compatibility. depends on need.

stack - reverse of a queue in c++ -

this question exam paper got stuck in below have attached question although wasnt able complete have done of it. question: using following class definitions of stack , queue classes write templated function reversequeue(?), takes pointer queue parameter , uses stack object (or pointer stack object) reverse given queue. function call reversequeue should reverse data of queue passed parameter. [hint: call appropriate methods given below in reversequeue(?) function. not have write implementation code stack , queue classes/methods given below. read each method , use them according need.] template <class t> struct node { node<t> *pnext; t data; }; template <class t> class stack{ private: node<t> * top; public: stack(); ~stack(); void push (t data); //pushes new node data type //t in stack bool pop (t &data); //pops out top node //the stack void printstack(); //prints elements of stack }; templ...

mysql - Select the name and value of a colmun using 2 different inner joined columns' values -

i'm not sure if mysql capable of doing this. i'm no mysql master means me seems might example of pivot table? i've looked @ other pivot table example , find them confusing @ best , i'm still not quite sure if it's relevant in case. here's example of data , tables in question: foo table: rowid | col_one | col_two | col_three ------|---------|---------|----------- 1 | 2 | 34 | 64 2 | 6 | 53 | 23 3 | 8 | 22 | 45 foo_meta table: rowid | fooid | metaname | metavalue ------|-------|----------|----------- 1 | 1 | | 302 2 | 1 | | 466 3 | 1 | other | 132 4 | 2 | | 222 5 | 2 | | 87 6 | 2 | other | 400 7 | 3 | | 732 8 | 3 | | 55 9 | 3 | other | 690 here's example of select i'm using isn't quite i'm looking for: select: select t.col_one, t.col_two, t.col_three, m.metaname, ...

Python, matplotlib: how to set tick label values to their logarithmic values -

Image
i have data plot on semi-log plot (log-lin style, logarithmic scale on y-axis). there way change y-axis tick labels actual values logarithmic values? as example, consider following code: import matplotlib.pyplot plt import numpy np x=np.array([1,2,3,4,5]) def f(x): return 10**(x-1) plt.plot(x,f(x)) plt.yscale(u'log') plt.show() which produces following plot: (sorry kind of big, not know how make smaller, feel free edit out that). in plot tick labels shown 10^0, 10^1, 10^2, etc.; them display logarithmic values: 0, 1, 2, etc. i realize go , change plt.plot(x,f(x)) plt.plot(x,np.log10(f(x))) , make y-axis linear again instead of logarithmic want know if there anyway matplotlib can change y-axis tick values without me having put np.log10() in plt.plot() 's. reason two-fold: have many plt.plot() lines in code , rather not go , have change of them, , wouldn't have logarithmically spaced minor ticks (although i'm sure there's way change l...

css - Position a HTML table element on top of img element -

Image
i want able place html table on top of image using css. want move table looks picture below: this have as: and want this: this code looks like: <img src="@url.content(" ~/images/sortbydivisioncontrol_bg2.png ")" width="570"> <table id="locations-table" style="margin:0 auto;"> <thead> <tr> <th colspan="3"> locations </th> </tr> </thead> <tbody> <tr> <td> <a>anchorage, ak</a> </td> <td> <a>spokane, wa</a> </td> <td> <a>coburg, or</a> </td> </tr> <tr> <td> <a>kapolei, hi</a> </td> <td> <a>toledo, wa</a> </td> <td> <a>medford, or</a> </td> ...

How to Use OpenSSL on Mac -

Image
i'm trying generate openssl cert on mac (for xero woocommerce integration) following these instructions (copied below): http://developer.xero.com/documentation/advanced-docs/public-private-keypair/ openssl genrsa -out privatekey.pem 1024 openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 1825 openssl pkcs12 -export -out public_privatekey.pfx -inkey privatekey.pem -in publickey.cer it works fine, , last step input , verify export password. after submit see nothing. .pfx file saved too? should else displayed on screen? see screenshot below at. the files should saved in same location (working directory) ran these commands from. if run command pwd it should show path working directory.

c# - DropdownListFor on Change updates and posts parent object -

man..and thought project nice , easy.... here's problem: i'm making checklist project manager using mvc 4, , have editor template each task item. within each task item, have dropdownlistfor user can use select task state ('complete', 'inprogress', etc.) when user changes task state, script goes , adds completion date (if changed completed state). want update , save task changes in database using httppost method, "updatetaskstate". as side question, correct , proper way acheive goal? i'd love have don't need refresh tasks view every time change made too.. my task editor template: @model models.task @html.hiddenfor(model => model.task_id, new { @id = "taskid" }) @html.hiddenfor(model => model.task_name) @html.hiddenfor(model => model.task_desc) @html.hiddenfor(model => model.user_completed,new {@id = "usercompleted" }) @html.hiddenfor(model => model.completion_date, new { @id = "completion...

node.js - Node: 100s of simultaneous requests slows down server substantially. O.S issue? -

my node application making requests 2 servers, , b. server a, waits 1 request finish before making next one. server b makes 20 requests second without waiting. when i'm making requests server b, requests server take long time. when don't make requests server b, go quickly. requests server b pile up, there no more few hundred in process simultaneously. i've run exact same application, same node version on joyent smartos instance , don't have problem, assume issue limits operating system sets, , not limits node sets. in node have maxsockets set 10000 explained here, http://markdawson.tumblr.com/post/17525116003/node i'm running application upstart though don't know if have problem without (that next test). in upstart config file have limit nofile 90000 90000. there other limits can raise documented here, http://upstart.ubuntu.com/wiki/stanzas#limit , don't know do. 1 of these causing problem? else might ubuntu machine's limits set? i sh...

swift - How do you use the Optional variable in a ternary conditional operator? -

i want use optional variable ternary conditional operator throwing error error: optional cannot used boolean. doing wrong? var str1: string? var mybool:bool mybool = str1 ? true : false you can not assign string value bool can check str1 nil or not way : mybool = str1 != nil ? true : false print(mybool) it print false because str1 empty.

javascript - How to use Angular form validation on other elements like div? -

i using angular form validation using below code <form ng-app="" ng-controller="validatectrl" name="myform" novalidate> <p>username:<br> <input type="text" name="user" ng-model="user" required> <span style="color:red" ng-show="myform.user.$dirty && myform.user.$invalid"> <span ng-show="myform.user.$error.required">username required.</span> </span> </p> </form> but if want use this: <div ng-app="" ng-controller="validatectrl" name="myform" novalidate> <p>username:<br> <input type="text" name="user" ng-model="user" required> <span style="color:red" ng-show="myform.user.$dirty && myform.user.$invalid"> <span ng-show="myform.user.$error.required">us...

angularjs - Can't $update or $set ~ "undefined is not a function" ~ AngularFire -

what i'm trying do: update status "taken" when chat closed. issue: can't $scope.currentchat.$set() or $scope.currentchat.$update() work when trying update status. (see $scope.close() function.) what i've tried: various methods including $set, $update; don't know. lot of things. been researching several hours, , can't find solution works. notes: $scope.currentchat.$set({status:"taken"}); doesn't work. $scope.currentchat.$getrecord('status'); works. returns: object {$value: "open", $id: "status", $priority: null} so going on here? why can't seem set status taken? the issue in $scope.close() function, when trying update status: // $scope.close // - closes current ticket. $scope.close = function() { // $scope.ticketobject.status = "taken"; // $scope.currentchat.$set({status:"taken"}); console.log("==========================="); co...

c program to allow user to change there already set 4 digit pin -

enter pin , verify correct change pin display number of times pin entered (i) (ii) incorrectly exit program i having problems option 2 in question above supposed following: if select option 2, should allowed change pin. program should verify original pin first. when enter new pin, program must verify new pin asking customer re-enter new pin. verify new pin entered correct , no errors made. if there differences , verification fails, program must display appropriate error message , original pin should remain same. my problem arises when user entering new pin, 1. pin must 4 digits long 2. if user enters pin wrong when entering new pin, original pin must remain same. if enter new pin right new pin must change pin. have posted code have far option 2. if question not clear please ask me questions. case 2: { //ask user enter current pin printf("please enter current pin \n"); scanf("%d",&current_pin); ...

Issue updating rows c# -

i have problem can either update 1 row (and that's it) or 4 @ once. the issue tbl.rows.addat(tbl.rows.count - 1, tr1) on last 2 lines, comments indicating happens when statement placed there. there limit of 6, can't figure out why can't update 1 row @ time more once code i've got. the loops allowing 4 cells per row , no more 4 rows (not including initial row @ start). can point me in right direction please? c#: public void addrows_click1(object sender, eventargs e) { rmvrows.visible = true; // rows (int rowcount = 0; rowcount < 4; rowcount++ ) { tr1 = new tablerow(); // cells (int cellcount = 0; cellcount < 4; cellcount++) { tc1 = new tablecell(); tb1 = new textbox(); tb1.id = "tbid" + cellcount.tostring(); tc1.controls.add(tb1); tr1.cells.add(tc1); } tbl.rows.addat(tbl.rows.count - 1, tr1);// add 4 more rows } tbl.rows.addat(tbl.rows.count - 1, tr1)// adds 1 one no more ...

android - How to start AsyncTask from another class? -

i execute doinbackground() method of asynctask inner class of articlelistfragment_develop.class class. how go doing this. please can me syntax? have tried few things , keep getting errors. public class articlelistfragment_develop extends listfragment { ........ private class downloadxmltask extends asynctask<string, void, arraylist<article>> { /* * @override protected void onpreexecute() { pdialog = new * progressdialog(getactivity()); * pdialog.setmessage("loading search results..."); * pdialog.setindeterminate(true); * pdialog.setcanceledontouchoutside(false); pdialog.show(); } */ @override protected arraylist<article> doinbackground(string... urls) { log.d(tag, "downloadxmltask thread id: " + thread.currentthread().getid()); try { return loadxmlfromnetwork(urls[0]); } catch (xmlpullparserexception e) { e.printstacktr...

git clean does nothing -

i trying clean working tree, however, when enter git clean --force nothing happens. $ git status on branch master branch ahead of 'origin/master' 1 commit. (use "git push" publish local commits) untracked files: (use "git add <file>..." include in committed) packages/microsoft.aspnet.webpages.2.0.30506.0/ packages/microsoft.data.edm.5.2.0/ packages/microsoft.data.odata.5.2.0/ packages/microsoft.net.http.2.0.20710.0/ packages/microsoft.web.infrastructure.1.0.0.0/ nothing added commit untracked files present (use "git add" track) $ git clean --force $ git status on branch master branch ahead of 'origin/master' 1 commit. (use "git push" publish local commits) untracked files: (use "git add <file>..." include in committed) packages/microsoft.aspnet.webpages.2.0.30506.0/ packages/microsoft.data.edm.5.2.0/ packages/microsoft.data...

winapi - Getting the menu handle -

i created menus , sub menus using resource editor in visual studio. want add items 1 of menus during run time. going use insertmenuitem function don't know how access hmenu variable. loadmenu seems need. use load menu resource editor, this: hmenu yourmenu = loadmenu( hinst, // variable stored hinstance makeintresource(idm_menu1) ); // replace idm_menu1 id of menu here lots of useful examples, may find useful. of them address issue, , might useful in future. study example of menu-item bitmaps section if you... if need menu handle assigned window use getmenu member arx said. this: hmenu yourmenu = getmenu(hwnd); // hwnd hwnd of window owns menu do not forget destroy menu when no longer needed ( upon window destruction ) destroymenu . this example might well. introductory tutorial win32, suggest read ( go home page , download both pdf , .zip file code examples ). as have said before, question not entirely clear, if have further questions lea...

ios - Using Core Graphics in Sprite Kit -

i using sprite kit. have shape following core graphics code: cgmutablepathref pathref = cgpathcreatemutable(); cgpathmovetopoint(pathref, null, 300, 300); cgpathaddlinetopoint(pathref, null, 400, 300); cgpathaddcurvetopoint(pathref, null, 400, 335.727, 380.94, 368.739, 350, 386.603); cgpathclosesubpath(pathref); cgcontextsetrgbfillcolor(ctx, 1, 1, 1, 1); cgcontextaddpath(ctx, pathref); cgcontextfillpath(ctx); cgcontextsetlinewidth(ctx, 1); cgcontextsetrgbstrokecolor(ctx, 0, 0, 0, 1); cgcontextaddpath(ctx, pathref); cgcontextstrokepath(ctx); cgpathrelease(pathref); i notice when add skshapenode, looses it's fill , stroke color. notice when scale object, treats spritenode, , not vector. i know can adjust skshapenode's stroke, fill, stroke width, linecap, , other things. i best of both worlds. how complete shape, fills, , strokes coregraphics sknode can translate , receive mouse click events? thanks help. core graphics properties ignored, on shape node ap...

sails.js and how to hook into passport.js -

i created custom policy, , there want additional info twitter passport.js example. i have no idea how hook passport instance. see sails 101 passport implementation example: https://github.com/sails101/using-passport/blob/master/api/hooks/passport/index.js

arrays - C PRGMING 101: Dice game Assignment that adds an extra turn when players roll a 6 -

#include <stdio.h> #include <math.h> #include <time.h> #define filename "dice_rdme.txt" int main (void) { //prototypes int dice(int sets); void print_info(void); int dicereadback(void); //title printf("commence gamble, test might \n"); int sets; srand(time(0)); // user input dialogue printf("enter number of rolls wager \n"); scanf("%i", &sets); dice(sets); dicereadback(); print_info(); return; } //general print info void print_info (void) { printf("\n student info \n"); printf("class professor , ta \n "); printf("homework assignment#6 dice game 2.0 \n"); return; } //generate games, parse outcome, store int dice (int sets) { file * dice_rdme; int a, b; int plyrsum = 0; int j = 0; int k = 0; int d, f, dlrsum; int c[sets], g[sets]; int plyrset = sets; int dlrset = sets; dice_rdme = fopen("dice_rdme.txt","w"); (a=0; a<plyrset; a++) ...

haskell - GHC anything results in "ld: library not found for -lgmp" -

i'm trying compile haskell programs on mac running os x 10.10 yosemite, ghc fails every time ld: library not found -lgmp : $ ghc foo.hs [1 of 1] compiling main ( foo.hs, foo.o ) linking foo ... ld: library not found -lgmp clang: error: linker command failed exit code 1 (use -v see invocation) help? the missing thing on system date command line tools xcode. installing recent version xcode-select --install fixed problem.

how do you echo multiple images that have the same name as part of the file name in php? -

i trying figure out how echo images in directory contain same name part of file-name. have files being uploaded web-server. when uploaded files renamed 108_2.jpg , 108_3.jpg ... etc. i echo images contain 108 file-name. have far: <img src="../uploads/<?php echo $_session['propertyid'].'.jpg'; ?>" alt="photo" width="100" height="100" border="0" /> the $_session['propertyid'] " 108 " part of file name. this way should make trick. careful path, might not same client , server… <?php $path = "../uploads"; foreach (glob("$path/{$_session['propertyid']}*") $filename): ?> <img src="<?php echo $path ?>/<?php echo $filename ?>" alt="photo" width="100" height="100" border="0" /> <?php endforeach ?>

java - How do I set my Jasper Report JDBC URL relative to the location of the application? -

i want connect database, location of database same folder (dist) jar file. folder not in same location on every computer, , have program set accessible on network. (that's why put database in same folder jar file begin with.) i need know how connect database url relative database's location. can't use jdbc:h2:./giftcertificatemanagerdatabase;auto_server=true because thinks i'm searching database in "c:/program files/netbeans 8.0". how fix problem? as always, thank in advance helpful answers. you can use java find out current working directory, there's plenty of examples online: return new file("").getabsolutefile(); for instance. case in "c:/program files/netbeans 8.0" specific when developing under netbeans , running project there, can set flag use while in "development mode" searches fixed development database folder.