Posts

Showing posts from July, 2014

Automatically post on wall - Facebook Graph API PHP SDK v4 -

i'm building application event can directly post news messages on facebook. i'm trying use de php sdk v4 there parts of login process don't understand (still couldn't find solution after searching several hours). my problem in login process. first have specify applicaton , give application secret. have login facebook account. but account should use that? 1 of event? mine? (i'm admin of events page) (this means messages posted mine account while i'm not poster...sounds pretty weird..) which method should use login facebook? there veriaty of methonds facebookredirectloginhelper(), facebookcanvasloginhelper() or javascript one. far understand these helpers users login facebook accounts , that's not want. during search found example of making similar system ( facebook graph api php sdk v4 - post on page ). he/she uses folowing piece of code getting facebook session: facebooksession::setdefaultapplication('{app id}','{app secret}');

Python: parsing and extracting op-codes from asm -

i parse assembly file , extract opcodes, stripping-of operands. each line in input file consists of 3 opcodes. should extract first word after "[" in each line , accumulate in list ? there better way of doing this? here input file format : [slli a3,a3,4] [add.n a3,a3,a8] [l32i a11,a3,128] [add.n a3,a3,a8] [l32i a11,a3,128] [l32r a9,0x1fff8954] [l32i a11,a3,128] [l32r a9,0x1fff8954] [l32i.n a10,a11,4] [l32r a9,0x1fff8954] [l32i.n a10,a11,4] [l8ui a8,a11,0] my expected output should this : [ slli : add.n : l32i ] [ add.n : l32i : l32r ] [ l32i : l32r : l32i.n ] [ l32r : l32i.n : l8ui ] finding op-codes: >>> import re >>> re.findall(r'\[(?=([a-z0-9.]+))','[slli a3,a3,4] [add.n a3,a3,a8] [l32i a11,a3,128]') ['slli', 'add.n', 'l32i'] you should wrap function.

c# - Move Slider until Value is reached -

i try "animate" slider while value true, until reaches designated value. reason not work easy thought: while (depthscan == true) { depth_max_slider.value += 10; console.writeline("working"); if (blobcount <= 400) { depth_max_slider.value += 10; } else { depthscan = false; } } what doing wrong? something should trick... public class mywindow : window { void startbutton_click( object sender, routedeventargs e ) { // method run on ui thread backgroundworker worker = new backgroundworker(); worker.dowork += worker_dowork; worker.workerreportsprogress = true; worker.progresschanged += worker_progresschanged; worker.runworkerasync(); // start thread // ui thread continues // exit click event handler, ui thread goes wpf control can keep rendering... } void worker_pro

jquery - How do I post specific json data from php/mysql instead of all data -

i have code working pretty except it's going post of results php want specific json_encoded data. here's php pulls database. <?php session_start(); $_session['charname'] = 'egahtrac'; require_once ('mysqli_connect.php'); $q = "select * dps charname='" . $_session['charname'] . "';"; $r = mysqli_query($dbc, $q); $row = mysqli_fetch_array($r, mysqli_assoc); $dmg = $row['dmg']; $curr_hp = $row['curr_hp']; $tot_hp = $row['tot_hp']; $attk_spd = $row['attk_spd']; if ($_server['request_method'] == 'post') { if (isset($_post['attack'])) { if ($curr_hp > 0) { $row['curr_hp'] = $row['curr_hp'] - $row['dmg']; $q = "update dps set curr_hp='" . $row['curr_hp'] . "' charname='" . $_session['charname'] . "';"; $r = mysqli_query($d

PHP paths from within included files -

scenario i have 2 files: file.php , admin/file.php file.php has require_once 'admin/functions.php'; admin/file.php has require_once 'functions.php'; so they're both including same file. trouble within functions.php , things file_get_contents , include , require see defined paths relative file.php , admin/file.php , not functions.php . because of this, can't use same functions.php different directories without creating duplicate files don't think best thing doing incase edit one, i'll have remember edit other well. what's best practice type of situation? edit: see comment on accepted answer below. what's best practice type of situation? easy. set base path manually in config file & don’t worry it—relative paths—ever again. that said, if trying simplify way files loaded, should explicitly set $base_path this: $base_path = '/full/path/to/your/codebase/here/'; if don’t know file system base

node.js - mongodb incremental numbering - 500 internal server error -

i trying number id's of documents node , mongodb. getting 500 internal server error: 'cannot read property 'seq' of null. // submit ticket - returning 500 error - not updating id router.post('/ticketform', function(req, res){ var db = req.db; function getnextsequence(name, callback){ db.counters.findandmodify( { query:{ _id:name}, update:{$inc:{seq:1} }, new:true }, callback ); } getnextsequence('ticket', function(err, obj) { if (err) console.error(err); db.users.insert( { '_id': obj.seq, 'firstname':req.body.firstname, 'lastname':req.body.lastname, 'email':req.body.email, 'phone':req.body.phone, 'issue':req.body.issue }, function(err,docs) { if (err) console.error(err); console.log(docs);

javascript - Unexpected behavior of displaying and hiding a popup menu after resizing a screen or changing screen orientation -

i'm working on menu allows me open , close pop content. menu can opened pressing button, , closed clicking button once more or clicking anywhere else other pop-up content container. when i'm using code, experiencing weird issue after resizing window or changing screen orientation example on tablet, , clicking menu button, pop-up won't stay opened. opens , hides right after opening. i cannot duplicate error in jsfiddle made example using same code. why experiencing issue on demo page? how avoid it? code have sort of limitations i'm not aware of? this function trowed on click handler on each of buttons. function mainmenufunction(eid) { var num = $(eid).attr('id').substr($(eid).attr('id').length - 1); var elem = $("#menu-content-" + num); var parent = $("#menu-item-" + num); var p = parent.position(); var o = parent.offset(); if (elem.css("display") == "none") { elem.sli

javascript - Change the value of CJuiSlider with input box value -

i have cjuislider works fine.. when slider value changed value displayed in input box.. fine, want totally different of this. i.e. when value changed in input box (by typing value using keyboard) slider change value according value of input box.. my code is-- $this->widget('zii.widgets.jui.cjuislider', array( 'value'=>1, 'id'=>'planslider', 'change'=>'js:function{$("#plan_year").value($("#planslider").slider( "option", "value" ));}', // additional javascript options slider plugin 'options'=>array( 'min'=>1, 'max'=>100, 'slide'=>'js:function(event, ui) { $("#plan_year").val(ui.value);}', //'onchange'=>'js:function{$("#plan_year").value($("#planslider").slider( "option", "value" ));}', ), 'htmloptions'=>array( 'style

entity framework - How to publish solution into Azure -

Image
i have solution multiple projects project.core - business logic project.data - entity framework context (code first) - has connection string project.domain - models project.web - mvc i created project in azure portal db. try publish the problem is: no database found in project. how find it? you can ignore , try publish it. you'll need create database on azure, application can talk real database. if using local storage, you'll fine without "databases" section. this part of web-deploy deals database connection strings. if have connection string in web.config , have .release transformation, again "databases" section can ignored.

android - Cordova plugin javascript not getting response data from Plugin -

i using cordova develop hybird app android. writing simple plugin alert "hello" message. so have testplugin.java public class testplugin extends cordovaplugin { @override public boolean execute(final string action, final jsonarray args, final callbackcontext callbackcontext) throws jsonexception { callbackcontext.sendpluginresult(new pluginresult(pluginresult.status.ok, "hello")); return true; } } my config.xml: <?xml version='1.0' encoding='utf-8'?> <widget id="com.essue.magicmirror" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>myproject</name> <description> sample apache cordova application responds deviceready event. </description> <author email="dev@cordova.apache.org" href="http://cordova.io"> apache cordova team

HTTP process does not continue before the execution of PHP is completed -

i have php code executes php file in background shown below. problem http process not continue before execution completed. if out appreciate it. //process firstsearch/getinfo.php in background $file = "/home/cyber/public_html/firstsearch/getinfo.php"; //set options array used command execution $options=array(); $option['sleep-after-destroy']=0; $option['sleep-after-create']=0; $option['age-max']=40; $option['dir-run']=dirname(__file__); $option['step-sleep']=1; $option['workers-max']=(int)file_get_contents($file); $option['destroy-forcefull']=1; $workers=array(); //description pipe declaration $desc = a

sql - Why is not needed to declare the begining of a transaction? -

the title explains everything. why not needed declare begining of transaction, needed explicitly declare end? because possible determine when transaction must started - when first statement executed (there possibility explicitly begin it, since might want enter before statements ready run). but it's not obvious when you're done. may finish logical unit of work after query, or 10 hours , million more queries after.

primefaces - create native query JSF -

i got error in codes : javax.persistence.persistenceexception: exception [eclipselink-4002] (eclipse persistence services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.databaseexception internal exception: java.sql.sqlsyntaxerrorexception: syntax error: encountered ":" @ line 1, column 42. error code: -1 call: select userlevelid users id = :id query: datareadquery(sql="select userlevelid users id = :id ") and code : public string cek() { if (tmp.equals(tmp2)) { y =1; level = getitems().tostring(); } ..... ..... } public list<users> getitems() { if (y.equals(1)) { y=0; tmp = tmp.trim(); return em.createnativequery("select userlevelid users id = :id") .setparameter("id", tmp).getresultlist(); } } so where's fault ? can me ? thx b4 main problem native queries don't use named paramet

digital ocean - Node.js / VPS - page doesn't show update -

i've signed digital ocean start learning node.js; i've got working when change this: res.end('hello world\n'); to this: res.end('something else\n'); and click refresh in ff , chrome, both still show 'hello world', if clear history. however, when click [power cycle] on droplet in digital ocean dashboard, changes shown when refresh ff & chrome. any ideas why? do need configure on vps? thanks in advance... think found problem... i using batch script called deploy.bat that: copied js file updates using winscp.exe called restart file plink.exe update server the restart file had these 2 lines: sudo /sbin/stop www sudo /sbin/start www so trying write updates node server whilst node still running (using ps aux | grep node show running processes) , when tried refresh browsers, updates weren't showing. if opened putty.exe , ran sudo /sbin/stop www made changes server.js file , ran sudo /sbin/start www , updates

ruby on rails - Cannot install gem RMagick after upgrade to Mac OS X Maverick -

i have issue rails, after upgrade new version of mac os x maverick. rmagick wont install. i've follow install imagemagick 6.8.0-10 , add $ cd " magick-config --prefix lib" $ ln -s libmagick++-q16.7.dylib libmagick++.dylib $ ln -s libmagickcore-q16.7.dylib libmagickcore.dylib $ ln -s libmagickwand-q16.7.dylib libmagickwand.dylib and install gem install rmagick. , got message. fetching: rmagick-2.13.2.gem (100%) building native extensions. take while... error: error installing rmagick: error: failed build gem native extension. /system/library/frameworks/ruby.framework/versions/2.0/usr/bin/ruby extconf.rb checking ruby version >= 1.8.5... yes checking xcrun... yes checking magick-config... yes checking imagemagick version >= 6.4.9... yes checking hdri disabled version of imagemagick... yes package magickcore not found in pkg-config search path. perhaps should add directory containing `magickcore.pc' pkg_config_path envir

javascript - Jquery Mobile Panel Content not Styled -

Image
i adding entire html markup in pagebeforecreate method in jqmobile. @ last append html empty page , use trigger('create') style entire markup properly.everything styled fine except panel comes out of area.i have tried using trigger.(updatelayout) method of panel no use. know there simple command missing couldn't figure out . looking someone's help code: $(document).on('pagebeforecreate', '#pageone', function(){ var str = '<div data-role="panel" id="user-panel" data-display="overlay" data- swipe-close="false" >'+ '<ul data-role="listview" id="list" data-theme="a">' var str1='' $.getjson( "url", function( data, status) { $.each(data.category, function (key, value) { if(value.id==2) str = str + '<li ><a href = &quo

uitableview - Updating frame of UITableViewCell Subview with AutoLayout -

i using auto layout. have uiview subview custom uitableviewcell. in cellforrow i'd set frame of uiview in cell row. here's have: uiview *bar; -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { bar = (uiview *)[cell.contentview viewwithtag:2]; [bar setframe:cgrectmake(bar.frame.origin.x, bar.frame.origin.y, 10, bar.frame.size.height)]; } if turn auto layout off, works. how can accomplish using auto layout? i've searched thoroughly , haven't found solution. you can using storyboard or interface builder create uiview in tools, , use constraints desired size of view. autolayout can done programmatically i've seen it's annoying. best way autolayout using visual building tools. check out uitableviewcell xib stackoverflow posts se

jquery - Php "continue" on click -

i have values in array. first, want show first 2 values of array in view , next want show remaining values after button click action incrementing array index 1. example: 1 click shows 3rd value click shows 4th . how can achieve ?? $array=[1,2,3,4,5,6,7,8,9]; foreach($array $a) { if($a>2) continue; echo $a.'<br/>'; } for first time want view like 1 2 and after once button clicked need show 3 4 5 . . . that not how php works. a php script runned on server build web page. once have it, need rebuild page, according new parameters (recived or post), asking server again. it that: <?php $array=array(1,2,3,4,5,6,7,8,9); //that how declare array in php if(empty($_get["count"])){ //it's first time on page, show first 2 elements echo $array[0] . ' ' . $array[1]; echo '<br><a href="page.php?count=1">next</a>'; //send same page, send count } else{ //it's

Jenkins - Run same job on DIFFERENT machine concurrently -

here scenario problem. have 1 job plays machine host file. want run job flag(to change host) 0 , 1 concurrently. got know jenkins plugin concurrent run may happen both job instances run on same slave , creating problem host file(different flags change/unchange file) i looking can run both instances, on different slaves. help needed. thanks in advance. throttle concurrent builds plugin - in configuration of plugin set maximum concurrent builds per node = 1

java - Hibernate postgresql notify functionality -

i`m writing app using hibernate + jpa orm , postgresql 9.3 database backend , need react java code database events. more precise want build trigger uses pg_notify() when new row inserted table. have read tutorials direct jdbc connection , not through hibernate. (think i) cannot use hibernate events rows not inserted through hibernate 3rd party app. is there way can receive notifications send pg_notify through hibernate ? -- update right have classcastexception : java.lang.classcastexception: com.sun.gjc.spi.jdbc40.connectionwrapper40 cannot cast org.postgresql.pgconnection @ com.xxx.core.impl.dao.postgresqllowlevelnotificationdaoimpl$1.execute(postgresqllowlevelnotificationdaoimpl.java:36) @ com.xxx.core.impl.dao.postgresqllowlevelnotificationdaoimpl$1.execute(postgresqllowlevelnotificationdaoimpl.java:1) i have mention use glassfish 4.0 as. connection pool created on glassfish , accessed app through jndi. entitymanager injected container spring. here code:

javascript - why expression with 'undefined' does not return boolean -

this question has answer here: javascript , operator within assignment 6 answers my questions might silly, why in expression var query; var n = query && query.length > 0; n 'undefined' , not false? expected expression evaluates boolean. made me curious. && evaluates left operand. if left operand falsy, evaluates left operand . otherwise, evaluates right operand. since javascript doesn’t have strong typing, works in same way boolean result part, , allows convenient tricks, one, || : var requestanimationframe = requestanimationframe || window.webkitrequestanimationframe || window.mozrequestanimationframe || window.msrequestanimationframe || window.orequestanimationframe || function (callback) { settimeout(callback, 16); }; here’s it’s specified. the production logicalandexpression : logicalandex

java - how to set default image size in image view with zoom in zoom out? -

i using horizontal scrollview, , when clicking on image buttom of horizontal scrollview, image showing in imageview. functionality working properly. , in image view able zoom image. after zooming, when clicking on next image button of scrollview then, imageview bydefault showing zoomed image. taking zoom of previous image. problem how can remove previous zoom, next image. mean next image must come default size, not zoomed. here code. public class viewbuttonactivity extends activity implements onclicklistener, ontouchlistener { imageview imgview; private progressdialog pdialog; public static boolean istouch = false; imagebutton imgbutton1, imgbutton2, imgbutton3, imgbutton4, imgbutton5; horizontalscrollview horizontalscrollview; public imageloader imageloader; public static string[] imageurl = { "http://0-03/_cover.jpg", "http://www.magazine.jpg", "http://large_1.jpg", "http://4.bp.apr2011.jpg",

qml - Is it possible to implement SystemTrayIcon functionality in Qt Quick application -

i writing qtquick desktop application. use both c++ (for functionality) , qml (for ui) in it. use qquickview show interface written in qml. i want application reside in system tray when minimised. i mean functionality similar example. http://qt-project.org/doc/qt-4.8/desktop-systray.html . trying implement feature not find way in qt quick application. here main.cpp code: #include <qguiapplication> #include <qqmlengine> #include <qqmlcontext> #include <qqmlfileselector> #include <qquickview> #include "myapp.h" int main(int argc, char* argv[]) { qguiapplication app(argc,argv); app.setapplicationname(qfileinfo(app.applicationfilepath()).basename()); qdir::setcurrent(qapp->applicationdirpath()); myapp myappobject; qquickview view; view.connect(view.engine(), signal(quit()), &app, slot(quit())); view.rootcontext()->setcontextproperty("myappobject", &myappobject); new qqmlfilese

java - First item getting selected in listbox -

Image
i want select items keywords facebook , twitter in it. problem first item "aggregator" gets selected. can tell me wrong in code. thanks. int j=0; jlist1.setmodel(listmodel); (int i=0;i<listmodel.size();i++){ if (listmodel.getelementat(i).tostring().indexof("facebook")!=-1||listmodel.getelementat(i).tostring().indexof("twitter")!=-1){ a[j]=i; j++; } } jlist1.setselectedindices(a); to select multiple elements, can use jlist#addselectioninterval , example... import java.awt.borderlayout; import java.awt.eventqueue; import javax.swing.defaultlistmodel; import javax.swing.jframe; import javax.swing.jlist; import javax.swing.jscrollpane; import javax.swing.uimanager; import javax.swing.unsupportedlookandfeelexception; public class listselectionexample { public static void main(string[] args) { new listselectionexample(); } public listselectionexample() { e

sql - Hiding alias column in MySQL -

it might repeated question need help. new mysql. here problem. i have query calculate distance between latitude , longitude. based on distance order have return id's. select dlo.id, (3959 * acos(cos(radians(12.9)) * cos(radians(y(gproperty))) * cos(radians(x(gproperty)) - radians(77.5)) +sin(radians(12.9)) * sin(radians(y(gproperty))))) distance db1.gfeature dgf, db2.loc dlo, db2.cust dcu gf.o_type = 6 , dcu.id = 240 , dgf.o_id = dlo.p_id having distance < 20 order distance limit 10; which returns +------+-----------------------+ | id | distance | +------+-----------------------+ | 101 | 0.00025714756425665 | | 199 | 0.10971525612556807 | | 722 | 0.22772618588406165 | +------+-----------------------+ but need id column displayed. asked same-question yesterday. using three tables data. confused in joining 3 tables. can suggest me.? i tried way select id ( select dlo.id, ( 3959 * acos( cos( radians(1

java - Java7 WatchService: Is there a "built-in" way to Ignore OS-specific files like .DS_Store? -

so, know it's possible "the manual way" ignore such files. at moment, like: path filename = ev.context(); if(filename.equals(".ds_store")){ break; //the event loop } but seems little hacky me (ok, create enum string, create method checks , on, still, in context of os-specific generated files hoped find "built-in" handle me.), i'm asking if there's kind of built-in way in java7 watchservice haven't discovered yet ignore such files. p.s: use-case it's (sadly) not option other way round, "ignore files except pattern ". has "allow files except few ones". i don't believe java supports os-specific file name check. however, seems fine check hidden files, prefer more general starts '.' if (filename.charat(0) == '.') { continue; // skip hidden files. break wrong, i'd continue. }

android - How to convert time in 12 hr format? -

i'm getting call time through cursor , want display in 12 hr format instead of 24 hr format. here code time cursor string calldate = managedcursor.getstring(dateindex); date calldaytime = new date(long.valueof(calldate)); and set call day time text view lastintreactionvaluetv.settext(calldaytime+""); it's showing like thu jun 26 14:36:24 edt 2014 what should convert 12 hr format? use simpledateformat set format need, example: date calldaytime = new date(); dateformat sdf= new simpledateformat("eee, mmm dd kk:mm:ss z yyyy",new locale("en")); system.out.println(sdf.format(calldaytime) ); this output: thu, jun 26 08:54:51 cest 2014

Formula Field Not growing when in the same page footer as a sub-report -

basically, have formula runs while printing records, can print 0-3 rows using chr(13) , global stringvars form final string (tried chr(10) , chr(13)), in same page footer sub report can have anywhere 0 rows above 3. both set "can grow" formula field never grows past sub-report. i'm using crystal reports 9. i tried using box around formula leading previous page footer page footer. here's formula whileprintingrecords; global stringvar wd; global stringvar adv; global stringvar nasc; stringvar final :=""; if wd <> "" , adv <> "" , nasc <> "" final := wd + chr(13) + chr(10) + nasc + chr(13) + chr(10) + adv else if wd = "" , adv <> "" , nasc <> "" final := nasc + chr(13) + chr(10) + adv else if wd <> "" , adv = "" , nasc <> "" final := wd + chr(13) + chr(10) + nasc else if wd <> "" , adv <> "

javascript - how to restrict going to back in firefox (private window)? -

i make simple html , open in firefox (new private window).i run in new private window .when press backspace display same screen same when open new private window.it why? can restrict on same page on pressing ? used lot of things nothing work . <!doctype html> <html> <head> </head> <body> <h1>my web page</h1> <p id="demo">a paragraph.</p> <button type="button" onclick="myfunction()">try it</button> </body> </html> $('html').keyup(function (e) { if (e.keycode == 8) { e.preventdefault(); e.stopimmediatepropagation(); e.stoppropagation(); alert('backspace trapped') return ; } e.preventdefault(); e.stopimmediatepropagation(); e.stoppropagation(); }) try this.. just insert within head. <script type="text/javascript"> function noback(){window.history.forward()}

ajax - Reuse https connection with libcurl (PHP) -

i have server , multiple servers behind in local network server (server has connection outside) server has webpage multiple ajax request script this //get myserverb_ip database ... $url = "https://myserverb_ip/someurl.php" $ch = curl_init(); curl_setopt($ch,curl_version_ssl,true); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_connecttimeout, 5); curl_setopt($ch, curlopt_fresh_connect, false); curl_setopt ($ch, curlopt_timeout,30); curl_setopt($ch, curlopt_cookiejar, '/tmp/sess.txt'); curl_setopt($ch, curlopt_cookiefile, '/tmp/sess.txt'); curl_exec($ch); ... with http, worked fine, when adding https there big delay because every single ajax call requests new key exchange serverb there way reuse connection avoid key exchange in every request ?

c# - How does visual studio (or Resharper ?) know that "Expression is always true"? -

this question has answer here: how resharper know “expression true”? 4 answers using visual studio 2012 resharper. sample code: public void dosomethingwithtable(datatable dt) { if (dt.primarykey != null) // xx { // } } in ide, warning: "expression true" @ line marked xx. question is, how ide (or resharper ?) know datacolumn[] value of primarykey not null ? i know if used tool reflector see inner workings of ado.net, come same conclusion, how resharper ? such warnings 100% reliable ? i don't have reflector, maybe uses decompiler? it can indeed never null , decompiled via ilspy : public datacolumn[] primarykey { { uniqueconstraint uniqueconstraint = this.primarykey; if (uniqueconstraint != null) { return uniqueconstraint.key.toarray();

php - How to output query data -

i've been trying day, looked @ references, looked @ other questions similar mine, nothing seems working. problem: can't output query data. this recent iteration of code: try { $link = new pdo('mysql:host=localhost;dbname=users_db', 'root', '56235623'); } catch (pdoexception $e) { print "error!: " . $e->getmessage() . "<br/>"; die(); } $sql = $link->prepare('select * users'); $sql->execute(); $result = $sql->fetchall(pdo::fetch_assoc); foreach ($result $key=>$value){ echo $key.$value; } here output: notice: array string conversion in c:\xampp\htdocs\myproject\includes\cn.php on line 23 0array notice: array string conversion in c:\xampp\htdocs\myproject\includes\cn.php on line 23 1array notice: array string conversion in c:\xampp\htdocs\myproject\includes\cn.php on line 23 2array notice: array string conversion in c:\xampp\htdocs\myproject\inclu

How to build streaming API with Ruby Grape? -

i want build api grape, post file through http streaming. how that? ps grape example of rack-stream couldn't work error info: http/1.1 503 service unavailable i want make grape can handle request this: net::http.new('localhost', 9292).start |h| req = net::http::post.new('/api/http_streaming_post') file.open('binary_file.bin') |f| req.body_stream = f req['content-length'] = f.lstat.size.to_s req['content-type'] = 'text/html;charset=utf-8' response = h.request req end end i don't know how it. after found reading body_stream in sinatra , use sinatra instead.

mysql - How can I get a matrix table from two related table by one query statement? -

Image
this question has answer here: mysql pivot table query dynamic columns 3 answers how can matrix table 2 related table 1 query statement picture shows? or have use temporary table instead? here possible solution this, note solution current data structure, if there more roles in role table not proper solution. since inner query needs changed accommodate new roles. select id, name, coalesce(max(t.fw),'no') fw, coalesce(max(t.df),'no') df, coalesce(max(t.gk),'no') gk, coalesce(max(t.mf),'no') mf user u left join ( select case when r.id = 1 , ur.role_id not null 'yes' else null end `fw`, case when r.id = 2 , ur.role_id not null 'yes' else null end `df`, case when r.id = 3 , ur.role_id not null 'yes' else null end `gk`, case when r.id = 4 , ur.role_id

javascript - d3.parseDate Error cannot read property 'forEach' of undefined -

i hope y'all can me. stuck trying make bar chart time series using d3 , json file. json file structured so: { "projectcode": "prj2.1", "numberofschools": 1188, "newschools": 0, "date": 2011-12 }, the y axis supposed show numberofschools whilst x axis supposed show years passed. used combination of time scale , ordinal scale x axis , parsed date so: data.foreach(function(d) { d.date = parsedate(d.date.tostring()); d.numberofschools = +d.numberofschools; }); i'm guessing json file not being parsed , have tried solutions here , here no luck. i'm using d3.v3. , below jsfiddle http://jsfiddle.net/siyafrica/esye3/ i've seen above fiddle, , understood, can give exact location file is. url of json file might wrong that's why problem raising. read below definition d3.json(url[, callbac

email - c# - send mass mailing with personalized link through Sendgrid with personally managed addressee list -

i have c# website uses dynamics crm 2011 backend. intent our client can use website create html mail, preview in browser , send predefined crm marketing list. plan on using sendgrid send our mails, not manage unsubscribes because want use custom unsubscription implementation involving footer in mail link containing id of customer received mail. we don't want manually create mail each of our contacts can put id in there. there way tell sendgrid through api: "here's list of email addresses coupled ids, want replace text in footer id corresponding email address you're sending to"? yes, can substitution tags in smtp api header or parameter.

jQuery isotope 2 check if is applied -

i'm using isotope 2 ( http://isotope.metafizzy.co/ ) , need check if isotope applied, or destroyed. i need destroy applied isotope in mobile size, $container.isotope('destroy'); on windowresize, if window width less 767. after destroying, need check if isotope active or destroyed. in isotope v1 class "isotope" added, there no class in v2. any ideas? best regards ch

linux - Problems with SCP stalling during file copy over VPN -

i have series of files need copy via scp on vpn remote linux server virtual linux server. files not large(4m-500m), file copy stalls. seems network disconnect after that, because could't receive reply ping operation. , have restart network service. the virtual linux server's os centos 6.4, , use pptp vpn client. from /var/log/messages find messages this: pptp[14514]: anon log[decaps_gre:pptp_gre.c:414]: buffering packet 1181 (expecting 1043, lost or reordered) pptp[14514]: anon log[decaps_gre:pptp_gre.c:414]: buffering packet 1182 (expecting 1043, lost or reordered) pptp[14514]: anon log[decaps_gre:pptp_gre.c:414]: buffering packet 1183 (expecting 1043, lost or reordered) ... rsyslogd-2177: imuxsock begins drop messages pid 14514 due rate-limiting rsyslogd-2177: imuxsock lost 130 messages pid 14514 due rate-limiting ... anon log[decaps_gre:pptp_gre.c:414]: buffering packet 104763 (expecting 104761, lost or reordered) anon log[decaps_gre:pptp_gre.c:414]: buffering pack

html - Inconsistent spacing in different browsers -

Image
i need create simple calendar design. problem is, cannot change html markup, created php script. calendar created unordered list, each li -tag represents 1 day. from left right, these google chrome , mozilla firefox , internet explorer : i want each of them chrome-example (i remove unnecessary border right afterwards). have tried lot of things solve this, negative margin instance - of course changed in chrome. according this article caused spaces, tabs , linebreaks between li -tags, half truth. i figured out, creating script returns list without spaces in between. true days, not heading - don't ask why, don't know either... see code below example. <li class="day first">mo</li> <li class="day">tu</li> <li class="day">we</li> <li class="day">th</li> <li class="day">fr</li> <li class="day">sa</li> <li class="day">su&l

How to put images into an array Ruby on Rails -

i have ruby on rails app allows user save 6 images can viewed in carousel. the images saved strings image, image_2, image_3, image_4, image_5, image_6. i want able write 'for' loop display of images in carousel. what best method of combining of these image strings array can looped through , outputted carousel? further details i calling images below works isn't particularly dry. <div style="position:relative"> <div id="home-carousel" class="carousel"> <div class="carousel-inner"> <div class="item active"> <%= image_tag @place.image %> </div> <% if @place.image_2.present? %> <div class="item"> <%= image_tag @place.image_2 %> </div> <% end %> <% if @place.image_3.present? %> <div class="item"> <%= image_tag @place.image_3

r - Graphing distribution of independent variable for any given dataset -

i looking automate process of exploratory data analysis , graph distribution (using line plots, histograms, density curves, etc.) of input variables. code stands, getting 4 blank graphics windows. doing incorrectly? if there better approach, open well. mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv") (i in names(mydata)){ qplot(data=mydata,i,geom="bar", fill="admit") dev.new() } this situation looks 1 aes_string come in handy (along addition of print around call ggplot ). found this post showing how use aes_string ggplot inside loop. so this: mydata$admit = factor(mydata$admit) for(i in names(mydata)) { print(ggplot(mydata) + geom_bar(aes_string(x = i, fill = "admit"))) } i'm working in rstudio have skipped dev.new part of code. found needed convert admit factor, well.

xml - How do I initialize an IXMLDOMNode in VBA? -

when use code in excel vba macro: dim xmlknoten new ixmldomnode i error. how initiate right? the initiation of domdocument works: dim xmldoc object set xmldoc = createobject("msxml2.domdocument") thanks helping. first, ensure have microsoft xml reference enabled (my version v3.0 ). once have enabled, code should work, if doesn't can write this: dim xmlknoten new msxml2.ixmldomnode hope helps.

libevent - does this c++ code have memory leaks? -

i'm trying understand libevent c++ code got this page . i'm bit confused - correct think code might have memory leaks? it seems connectiondata pointer created in on_connect() callback, delete() called on bad read or after write complete. if connection accept() ed - there no reads or writes? pointer stays in daemon memory? #include <event.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #include <iostream> // read/write buffer max length static const size_t max_buf = 512; typedef struct { struct event ev; char buf[max_buf]; size_t offset; size_t size; } connectiondata; void on_connect(int fd, short event, void *arg); void client_read(int fd, short event, void *arg); void client_write(int fd, short event, void *arg); int main(int argc, char **argv) { // check arguments if (argc < 3) { std::cout << "run options:

database design - How to assign ordinality to text, for the purpose of grouping data in Access report -

i want group access report base on custom grouping (as oppose alphabet descending or ascending) for example: proposal phase data... discovery phase data... identification phase data... right now,with order alphabet , shows proposal -> identification -> discovery, or vice versa. i assign numbers text itself, such 1.proposal, 2.discovery, 3.identification. i'd avoid that. there feature in access allows me assign ordinality , sort of factors r? add numeric column, name position or rank... sort column. that's way can achieve this.

ssh - Bash: how to duplicate input/output from interactive scripts only in complete lines? -

how can capture input/ output script in realtime (such tee), line-by-line instead of character-by-character? goal capture input typed interactive prompts of script after backspaces , auto-completion have finished processing (after return key hit). specifically, trying create wrapper script ssh creates timestamped log of commands used on remote servers. the script , uses tee redirect output filtering, works well, redirected output gets jumbled unsubmitted characters whenever use backspace key or up/down keys scroll through remote history. example: service test stopexitservice test stopart or cd ..logs[1pls -al . perhaps there way capture terminal's scrollback , redirect tee? update: have found character-based cleanup solution want of time. however, still hoping answer question (which may msw's answer difficult do). in unix world there 2 primary modes of handling keyboard input. these known 'raw' in characters passed terminal reading program 1 @ time