Posts

Showing posts from February, 2014

java - How do I send a cookie while trying to grab a sites source? -

i trying grab site's source code using code private static string geturlsource(string url) throws ioexception { url url = new url(url); urlconnection urlconn = url.openconnection(); bufferedreader in = new bufferedreader(new inputstreamreader( urlconn.getinputstream(), "utf-8")); string inputline; stringbuilder = new stringbuilder(); while ((inputline = in.readline()) != null) a.append(inputline); in.close(); return a.tostring(); } when grab site code way error needing allow cookies. there anyway allow cookies in java application can grab source code? have cookie browser uses log me in if helps. thanks john this way have deal raw request data, go apache http client gives abstraction , methods allow set headers in request

calculate no of days between mysql timestamp and php current date -

this question has answer here: finding number of days between 2 dates 22 answers i getting php date date("y-m-d") 2014-03-14 , mysql timestamp 2014-03-02 03:2:23 i want 12 days. select datediff('2014-03-14',date(mysql_timestamp))

c - GCC/x86 inline asm: How do you tell gcc that inline assembly section will modify %esp? -

while trying make old code work again ( https://github.com/chaos4ever/chaos/blob/master/libraries/system/system_calls.h#l387 , fwiw) discovered of semantics of gcc seem have changed in quite subtle still dangerous way during latest 10-15 years... :p the code used work older versions of gcc , 2.95. anyway, here code: static inline return_type system_call_service_get(const char *protocol_name, service_parameter_type *service_parameter, tag_type *identification) { return_type return_value; asm volatile("pushl %2\n" "pushl %3\n" "pushl %4\n" "lcall %5, $0" : "=a" (return_value), "=g" (*service_parameter) : "g" (identification), "g" (service_parameter), "g" (protocol_name), "n" (system_call_service_get << 3...

javascript - Nodeschool's Stream-Adventure #12 Duplexer redux -

it's been days since i'm trying several ways solve exercice. give up. doing wrong here ? why getting "write after end" error if event i'm using "end" event , don't write pipe ? i'm changing object after it's use. or @ least think so. var duplexer2 = require("duplexer2"); var through = require('through2'); module.exports = function (counter) { var countries = {}; var duplex = duplexer2(through.obj(function (obj, encoding, done) { if (obj.country in countries) countries[obj.country]++; else countries[obj.country] = 1; done(); }), counter); duplex.on("finish", function() { counter.setcounts(countries); }); counter.pipe(duplex); return duplex; }; if substitute line counter.setcounts(countries); console.log(countries) see it's populated correctly. problem text: http://pastebin.com/vam4vkzg i have read e...

c# - How to reload page with previously entered parameters? -

i working on code project in asp.net mvc. have issue redirecting user after have completed action. have these controllers: index search page: public actionresult index(){ //this method sets viewmodel data search preferences viewmodel obj = new viewmodel(); //set values of dropdowns , searching capabilities return view("search", obj); } the user fills out search boxes in view, chooses dropdowns. return post search method handles data: [httppost] public actionresult index(viewmodel obj, int? page) { data = in db.database select i; if(!string.isnullorempty(obj.example) { data = data.where(x => x.poss == obj.poss); } //paging , other data formatting here return view("results", data); } once result list displayed, have checkbox/button system in result view allows user select multiple results , mark them "good", "bad" etc. method changes database simply. problem after data...

Does Azure load balancer allow connection draining -

i cant seem find documentation it. if connection draining not available how 1 supposed zero-downtime deployments? rick rainey answered essentially same question on server fault. states: the recommended way have custom health probe in load balanced set. example, have simple healthcheck.html page on each of vm's (in wwwroot example) , direct probe load balanced set page. long probe can retrieve page (http 200), azure load balancer keep sending user requests vm. when need update vm, can rename healthcheck.html different name such _healthcheck.html . cause probe start receiving http 404 errors , take machine out of load balanced rotation because not getting http 200. existing connections continue serviced azure lb stop sending new requests vm. after updates on vm have been completed, rename _healthcheck.html healthcheck.html . azure lb probe start getting http 200 responses , result start sending requests vm again. rep...

java - Coding a MultiThreaded Socket Proxy: IOException SocketClosed where it shouldn't -

i started coding proxy tcp socket connections , although i'm checking if sockets still open i'm getting ioexception. loc causing it. has idea why can happen? while (!from.isclosed() && !to.isclosed() && (numofbytes = in.read(bytebuffer)) != -1) i've debugged code; & not closed when checked. for context: proxy.java public class proxy { public static void main(string[] args) { try (serversocket proxyserver = new serversocket(5432)) { int = 0; while (true) { socket client = proxyserver.accept(); system.out.println(i++); socket server = new socket("localhost", 5000); proxyhandler clienttoserver = new proxyhandler(client, server); proxyhandler servertoclient = new proxyhandler(server, client); clienttoserver.setname("client->server"+i); servertoclient...

c++ - Finding the source of a failed static assertion on Eigen -

i'm trying compile -quite large- code base has dependencies eigen. doing so, got following error: error c2338: the_bracket_operator_is_only_for_vectors__use_the_parenthesis_operator_instead originates here: // eigen\src\core\densecoeffsbase.h /** \returns reference coefficient @ given index. * * method allowed vector expressions, , matrix expressions having linearaccessbit. * * \sa operator[](index) const, operator()(index,index), x(), y(), z(), w() */ eigen_strong_inline scalar& operator[](index index) { #ifndef eigen2_support eigen_static_assert(derived::isvectoratcompiletime, the_bracket_operator_is_only_for_vectors__use_the_parenthesis_operator_instead) #endif eigen_assert(index >= 0 && index < size()); return derived().coeffref(index); } as eigen dependencies on code, how can find line triggering error? (obviously, there line of code accessing eigen matrix using [] , somewhere , line i'm looking for...

c++ - Qt Mouse Event Receiving issue -

this might seem simple question, couldn't find answer long, i've decided ask question here. have class derived qframe . contains 2 buttons. issue: when set parent buttons "this" show have no reaction mouse. when set parent parent of qframe works: when: m_btncompile = new approxguimenubutton(this); m_btnsettings = new approxguimenubutton(this); doesn't work when: m_btncompile = new approxguimenubutton(parentwidget()); m_btnsettings = new approxguimenubutton(parentwidget()); works second option isn't solution me because need buttons in local coordinate system. parent generated qdesigner. i'm working in visual studio 2013 if it's important. need do? please, help. problem solved still don't know reason. i've added new member derived qwidget , inside set parent buttons , worked.

Google Cloud Pub/Sub Publishing from Browser - How does Auth work? -

i have requirement use google cloud pub/sub api directly browser ( similar ga script). wondering how can in handle auth without requiring going through back-end server. i want invoke cloud pub/sub api directly browser. tried , says need authenticate first , issue how secure auth token. is there javascript library available can use in browser ( not backend) invoke google pub/sub api. thanks in advance the general approach in javascript authorizing , making authorized requests google apis shown @ https://developers.google.com/api-client-library/javascript/samples/samples#authorizingandmakingauthorizedrequests -- it's not specific cloud pubsub api, should work all google apis. similarly, https://developers.google.com/api-client-library/javascript/start/start-js general javascript access google apis.

sql server - Return all records within given date -

question how return records today until given number of days in future? example in pseudo code select every record table plandate = today , next 14 days what have tried? select * joblist plandate >= getdate() +14 you can use dateadd : where plandate >= cast(getdate() date) , plandate < dateadd(day,+15, cast(getdate() date)) note have date type if use @ least sql-server 2008.

java - Play 2.2 Return Json Response within Web Application -

is there way make request restfully service on same application , display it's response too? i've created ui has form parameters fill out. when user clicks submit, i'd have response embedded in same page, displaying user json. i'd able called externally of course, restful api. i can define in routes file path return json, i'm not sure how consume application itself. i hope clear. i'd happy provide more details if necessary. ok. first of all, let's consider have route , controller produce json response us. get /foo controllers.foocontroller.foo object foocontroller extends controller { ..... implicit val foowrites = json.writes[foo] def foo = action { ok(json.tojson(foo)).as("application/json") } } then can use ajax our page response: <script> ...... $.get("@routes.foocontroller.foo") .done(function(data){ //do recieved data }); </sc...

mysqli - Select all from the db -

i need print user in db how do that? can't bind baram because there not thing bind? here code: session_start(); require 'inc/connect.php'; $hey = $mysqli->prepare("select * user"); $hey->execute(); $hey->bind_result($all); $hey->fetch(); $hey->close(); echo $all; if table user has 7 columns, give bind_result 7 variable names: $hey->bind_result($column_one, $column_two, $column_three, $column_four, $column_five, $column_six, $column_seven); of course, use variable names reflect nature of data represented. all now: session_start(); require 'inc/connect.php'; $hey = $mysqli->prepare("select * user"); $hey->execute(); $hey->bind_result($id, $fname, $lname, $email, $phone, $addy, $age); while ( $hey->fetch() ) { echo "$id $fname $lname $email $phone $addy $age<br>"; } $hey->close(); i prefer explicit sql , call columns want in results: select id, fname, lname,...

How can I add C++ Source Files and Headers to a C# .Net project? -

this question has answer here: combine native dll , assembly single dll 5 answers i want make use of hidapi library home-brewed usb device. rather having compile vc++ project own .dll , reference in .net project have, prefer have code present within .net project , able reference directly. the reason want avoid having .dll referencing .dll, , instead have single .dll file. i've done in reverse, sort of, have used c# class within c++ program when doing jni stuff. is trying here possible? there idiots guide using c++ in .net projects somewhere? wait, there yes answer, it's evil: how mix c# , c++ code in single assembly? if c++ code not compiled /clr:safe (i.e. compiled /clr or /clr:pure), following: 1) compile c++ code .obj files 2) compile c# code .netmodule, using /addmodule reference c++ .obj files 3) link c# netmodule directly c++ o...

html - Geolocation alert won't stay on screen -

i trying implement basic geolocation on web app alert in chrome won't stay on screen; pops @ bottom disappears before can click of options. geolocation alert won't stay on screen you missing error handler function. try adding: var success = function(position) { //do position }; var failure = function(error) { console.log('error occurred. error code: ' + error.code); // error.code can be: // 0: unknown error // 1: permission denied // 2: position unavailable (error response location provider) // 3: timed out }; navigator.geolocation.getcurrentposition(success, failure); also, consider adding {timout: 5000} (or other length of time) 3rd parameter, since function's default timeout search location infinity. see documentation on mdn .

apache - Intermittent errors with new code release to existing Mojolicious app -

i'm having problem existing mojolicous app. have added new routes, views, controllers, , models, , returning database results view using rose::db::object orm. i updated production version today code had been working great on morbo. but, on apache2/plack/psgi mod_perl config new models returning queries 1 in 5 1 in 10 times. i've eliminated number of variables, can query database directly , results no problem. older model's , queries work. it appears new functionality intermittent. have narrowed requests 1 server , have restarted apache. but, @ point don't understand why issue persisting. i think kind of mod_perl wonky behavior, don't know why apache restart doesn't fix it. any or ideas awesome. i did resolve , turned out simple. missing use statement controller in main application script. script setup routes. i'm not sure understand why working intermittently in production , working time in development. but, once added: use theapp::c...

How to set CApath for NGINX SSL Connection -

i'm trying set ssl connection sagepay website. can run openssl s_client successfully, returns: verify return code: 0 (ok) , if specify capath e.g. openssl s_client -connect test.sagepay.com:443 -capath /usr/local/ssl/certs/ when try using website error: openssl::ssl::sslerror (ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed): how tell nginx find ssl certs have installed?

r - reordering facets in ggplot2 -

Image
i've been through examples changing facet orders on site can't seem work specific case. ideas of how data setup appreciated. i'm new ggplot2 , supremely stumped. models ordered m1, m2, m3 m1 on top of each facet. thanks! outcome<-c(1,1,1,2,2,2,3,3,3) or<-c(1.97,2.47,3.56,1.73,2.25,4.09,1.21,1.48,2.25) min<-c(1.37,1.74,2.55,1.13,1.52,2.84,0.74,0.95,1.49) max<-c(2.83,3.49,4.98,2.66,3.35,5.9,1.97,2.33,3.41) aces<-c(1,2,3,1,2,3,1,2,3) ace<-data.frame(cbind(outcome,or,min,max,aces)) ace_labels <- list('1'="1 ace",'2'="2 aces",'3'="3 aces") ace_labeller <- function(variable,value){return(ace_labels[value])} ace$outcome = factor(ace$outcome, levels=c("1","2","3"), labels=c("m1: depression","m2: mh barrier work", "m3: mh barrier work")) ggplot(data=ace,aes(x=or,y=outcome,label=or...

objective c - Custom keyboard buttons iOS -

Image
i trying setup highlighted state keyboard buttons, have difficulties it: i can't set backgroundimage beneath spacebutton image , won't overlap shift_1 on image below (button tapped). i can't set layer margins, there space bottom , other buttons, , @ same time spacing function button. below code: [self.spacebutton setimage:[uiimage imagenamed:@"shift_1"] forstate:uicontrolstatenormal]; [self.spacebutton setbackgroundimage:[keyboardviewcontroller imagefromcolor:[uicolor colorwithwhite:0.4 alpha:0.5]] forstate:uicontrolstatehighlighted]; self.spacebutton.layer.cornerradius = 7.0; self.spacebutton.layer.maskstobounds = yes; i thankful if me. you have 2 ways: by image : add transparent pixel @ bottom,left,right in image , create new image set image in background image of button. by imageedgeinsets : set button imageedgeinsets , use image property set image(highlighted/no...

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

i've been working on making 2d map editor past 2 weeks or so, , i've run strange problem. trying optimize code, example, making functions should've been functions begin with, did made cpu usage go through roof. i've tried commenting out different sections of code thought culprits (scrolling, rendering, other calculations) no avail. think issue might trying call things within different functions, sake of making modular possible, i'd functionality. the other major change i've made since file i'm comparing i've ported variables external cpp file, since having variables global makes lot easier use within different functions. simple issue, can't life of me understand why happens. with original code, around 2-3% cpu usage. new code, around 20-35%, but, if move mouse around, it'll drop around 6-8%. tl;dr: after trying optimize code using functions, i've somehow killed performance, , found strange quirk moving mouse reduces cpu usage.. /...

jquery - Why is this list being duplicated when parsing JSON? -

i have json file i'm using populate select list. each of entries in json file being duplicated in select list. wrong, seems should work: $.each(data, function(index, item){ items.push('<option value="'+item.partnerid +'">'+item.pname+'</option>'); $('#platform').append( items.join('') ); }); fiddle you're joining , append generated list inside loop, after each item added it. that means every item, you're building list , appending select current item you're iterating over. given inputs [a, b, c, d] , you'll wind [a, ab, abc, abcd] . you need move final join outside loop, you're appending <option> s <select> once after they've been built. $.each(data, function(index, item){ items.push('<option value="'+item.partnerid +'">'+item.pname+'</option>'); }); $('#platform').append( items.join('') ); ...

php - Setting WordPress option values as constants -

pretty straightforward, below code have issues security or performance? believe constants faster using variables sure benefit negligible: $payment = get_option('swd_billing_payment'); define('swd_owner_currency', isset($payment['swd_owner_currency']) ? $payment['swd_owner_currency'] : ''); define('swd_owner_currency_symbol', isset($payment['swd_owner_currency_symbol']) ? $payment['swd_owner_currency_symbol'] : ''); define('swd_owner_bank', isset($payment['swd_owner_bank']) ? $payment['swd_owner_bank'] : ''); define('swd_owner_account_name', isset($payment['swd_owner_account_name']) ? $payment['swd_owner_account_name'] : ''); there end being around 30 constants defined various settings in database.

html - Bootstrap3 Radio Button not working with keyboard -

i using bootstrap3, html, css, php. not using javascript, if possible, or jquery. i want make form several questions, answer is: yes, no, not answered. bootstrap3 has radio buttons ideal, , work - if use mouse. if tab button , press space, bootstrap seems badly broken. button value not posted. or if click on yes button, change no using arrow keys, , submit form, yes value still posted. on firefox 36.0 on linux mint. does know how make radio buttons work keyboard? here sample code (test2.php): <!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <meta http-equiv="x-ua-compatible" content="ie=edge"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" /...

php - Make checkbox checked for each table -

i have lot of tables database , show users. here sample table likes. sample here . once user checked each table bottom right check box, whole check box table checked. php function call each table database function base_generategrouprulechecklist($gid) { //connect database base_connectdatabase(); $count = 0; //get base_modules id $getparentmodulesql = base_executesql("select * base_parent_modules order base_pmod_sort_by" ); $count1 = base_num_rows($getparentmodulesql); while($parentmoduledata_row = base_fetch_array($getparentmodulesql)) if ($count1!= 0) { //show category echo "<table style=\"border-collapse: collapse\" width=\"100%\" class=\"permission\">"; echo "<tr>"; echo "<th class=\"centertext\">".$parentmoduledata_row['base_pmod_name']....

c++ - Multiple Vertex Array Objects: Proper way to display multiple primitives? -

i'm having hard time getting multiple vertex array objects render multiple primitives. opengl tutorials i've found online show using single vao, i'm not sure might doing wrong. i'm using qt-opengl , trying render square , cube (on multiple vaos). using following code, i'm getting 1 primitive displayed on screen (whichever 1 initialized second). can see either primitive when turn off initialization of other one, not @ same time. data struct: struct vbo : public qopenglbuffer { }; struct vao : public qopenglvertexarrayobject { vbo vbo[1]; }; enum { circle, rect, num_vaos }; enum { pos, num_vbos }; vao vao[num_vaos]; initialization: static void init_objects() { for(int = 0; < num_vaos; ++i) { vao[i].create(); } vao[circle].bind(); for(int = 0; < num_vbos; ++i) { vao[circle].vbo[i].create(); vao[circle].vbo[i].setusagepattern( qopenglbuffer::staticdraw ); } vao[circle].vbo[pos].bind(); vao[circle].vbo[pos].allocat...

messaging - SQL Server Service Broker and batches -

am right in understanding of sql server (2008 r2 in case) service broker messages batched in terms of conversations? in other words, if have query this: declare @messages table( handle uniqueidentifier, message_body nvarchar(max), message_type_name sysname ); receive top 5 conversation_handle, message_body, message_type_name dbo.mymessagequeue @messages select conversation_handle, message_body @messages that 5 rows returned if same conversation? @ moment sending out messages 1 conversation @ time, if there ten such messages in queue, being returned 1 @ time. receive dequeue messages belonging one conversation group . unless explicit conversation group management, each conversation own group. if send 1 message per conversation, you'll end receive -ing 1 message every time. covered in conversation group locks . receive expensive statement run, high throughput must group more messages together, via conversation reuse .

php - PHPMailer with codeigniter is not sending mails -

i created website on windows server using codeigniter , phpmailer contact form, setup works well. after few days ago decided make website on linux server, used same codes contact form doesn't seem work. code in controller $email_config=array( "protocol"=>"smtp", "mailpath"=>"/usr/sbin/sendmail", "smtp_host"=>"mail.dnweb-solutions.com", "smtp_user"=>"contact@mail.dnweb-solutions.com", "smtp_pass"=>"****", "smtp_port"=>25, ); $this->load->library("email"); $this->email->initialize($email_config); $this->email->to("sobsdinike@gmail.com"); $this->email->from("contact@mail.dnweb-solutions.com",$_post[...

java - My program keeps generating four times? -

for reason when run program instead of outputting 1 card choice 3, four. i'm trying pick name array list include in path, output image, can see result system out. heres code: public class main { public static void main (string[] args) { main.createscreen(); } public static void createscreen() { jframe p = new jframe("angora realms"); p.setdefaultcloseoperation(jframe.exit_on_close); gamegui g = new gamegui(); p.add(g); p.setlocationrelativeto(null); p.pack(); p.setvisible(true); } } here's create gui , paint: @suppresswarnings("serial") public class gamegui extends jpanel implements actionlistener { public button drawcard = new button("draw card"); public gamegui() { drawcard.addactionlistener(this); add(drawcard); } @override public void actionperformed(actionevent event) { object cause = event.getsource(); if (cause == drawcard) { system.out.println("ay...

javascript - Accessing live data created by jQuery in php -

i have method in jquery code generates rows , add them table in html follows (and works fine): $(document).ready(function () { $("#textdateandtime").datetimepicker(); $(document).on("click","#ulinvite li h6",function(){ var h=this; var selected=h.innertext.split(' ')[0]; var myexp=new regexp(selected,"i"); $.getjson("json_data.php",function(data){ $.each(data,function(key,val){ if((val.username.search(myexp))==0){ var output="<tr>" +"<td>"+val.username+"</td>" +"<td>"+val.firstname+"</td>" +"<td>"+val.lastname+"</td>" +"</tr>"; $("#tableinvite").append(output); h.parentnode.parentnode.removechild(h.parentnode); } ...

objective c - Excluding internal headers from framework umbrella header -

while trying begin using swift in framework (including turning on module support), started getting messages this: [snip]/<module-includes>:1:1: umbrella header module 'presskit' not include header 'npkbaseappearance.h' the headers in question (there ten of them) not listed in presskit.h, reason—they include internal or rarely-used classes , categories don't want expose users of framework. (some of them i'd expose in select places; others should never exposed.) marking headers private doesn't seem help. warning in framework's project, error in each target using framework, can't ignore problem. obviously can add these headers umbrella header, don't want to. violating rule of framework design when using modules? what's recommended way handle sort of situation? don't know if solved issue did try exclude headers don't want export in custom .modulemap file? have at: clang 3.7 documentation - modules

ios - Apple pay integration with Stripe (STPTestPaymentAuthorizationViewController in debug) -

i trying integrate apple pay stripe in ios app. using applepaystub provide stripe check apple pay in debug mode i using latest stripe , applepaystub code git trying run on iphone 6 simulator , code using is: paymentcontroller = [[stptestpaymentauthorizationviewcontroller alloc] initwithpaymentrequest:request]; ((stptestpaymentauthorizationviewcontroller*) paymentcontroller).delegate = self; getting error: error domain=com.stripe.lib code=50 "your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios ." userinfo=0xxxxxxxxxxx {com.stripe.lib:errormessagekey=your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios ., nslocalizeddescription=your payment information formatted improperly. please make sure you're corre...

bitwise operators - Use of | in java -

i came across java code in constant has been defined in following way static final char fm = (char) (constantssystem.double_byte_sep | 0xfe); what use of | in code? the | bitwise or operator. works follows: 0 | 0 == 0 0 | 1 == 1 1 | 0 == 1 1 | 1 == 1 internally, integer represented sequence of bits. if have, example: int x = 1 | 2; this equivalent to: int x = 0001 | 0010; int x = 0011; int x = 3; note using 4 bits clarity, int in java represented 32 bits. specifically addressing code, if assume, example, value of constantssystem.double_byte_sep 256: static final char fm = (char) (constantssystem.double_byte_sep | 0xfe); static final char fm = (char) (256 | 254); static final char fm = (char) (0000 0001 0000 0000 | 0000 0000 1111 1110); static final char fm = (char) (0000 0001 1111 1110); static final char fm = (char) (510); static final char fm = 'วพ'; also note way wrote binary numbers not how represent binaries in java. example: 0000...

classnotfoundexception - Error while executing wsStopApp ant task unable to instantiate class com.ibm.ws.scripting.WasxShell -

i trying execute wsstopapp ant script of websphere wsadmin scripts. code below: <target name="was_wsstopapp"> <property name="dep_var" value="was_home" /> <antcall target="depcheck" /> <property name="dep_var" value="was_appname" /> <antcall target="depcheck" /> <taskdef name="wsstopapp" classname="com.ibm.websphere.ant.tasks.stopapplication" classpath="${was_cp}" /> <echo message="value of was_home ${was_home} , classpath ${was_cp}"/> <wsstopapp application="${was_appname}" user="${was_user}" password="${was_password}" failonerror="${was_failonerror}" washome="${was_home}" profilename="appsrv03"/> </target> all properties set in properties file. was_cp set ant script be...