Posts

Showing posts from April, 2013

c - multi-threaded file transfer with socket -

i trying make multi-threaded server-client file transfer system in c. there clients send or list or other choice (in switch case can see) , server storing files , serving lot of clients. multi-thread ideology difficult far can see. needs experience instead of knowledge. have been working on project more 1 week , haven't been able on top of problems. there 4 choices: first 1 lists local files of client in directory, second 1 list files transferred between client , server, third reading filename user , copy file server's directory. my vital issue here multi-threading. cannot connect multiple clients. have read code z heaps of times can't catch errors , stuck. the other issue client end when sigint caught, but, instance, after choosing list files when press ctrl-c doesn't stop. same issue server file well. more troublesome compared client's catching because when server gets sigint , clients disconnected respectively server. thanks helps! server.c /

php - Laravel 5 Route::group with public variable -

i have code this: route::group(['prefix'=>'dashboard'],function(){ route::get('addnew',function(){ $user = db::table('users')->where('username','=',session('username'))->first(); $data = array('level' => $user->level, 'name' => $user->name,'email' => $user->email); return view('layout.addnew')->with($data); }); route::get('load',function(){ $user = db::table('users')->where('username','=',session('username'))->first(); $data = array('level' => $user->level, 'name' => $user->name,'email' => $user->email); return view('layout.load')->with($data); }); }); but don't work when use public variable this: route::group(['prefix'=>'dashboard'],function(){ $user = db::table(&

php - Terminate after single validation error - Cakephp 3 -

i know somewhere in documentation, can't find it. how can output 1 validation error @ time instead of aggregating on every possible validation , output in $entity->errors()? in addition that, there simple way give setting every validation in every table? edit i found answer first question following: $validator ->add('body', [ 'minlength' => [ 'rule' => ['minlength', 10], 'last' => true, // particular line 'message' => 'comments must have substantial body.' ], 'maxlength' => [ 'rule' => ['maxlength', 250], 'message' => 'comments cannot long.' ] ]); again, there way apply validation methods, everywhere?

php - How to make image attatchment button -

enter image description here how make attachment activity... means have create activity in have give edit text box user suggestion , image button adding image if necessary related suggestion.. , send data server... i have created edit text , send data web server.. have no idea image upload.. my mainactivity.java public class mainactivity extends activity implements onclicklistener { edittext ed1; button submit; button cancel; button btnselectphoto; string tobesent; string imagepath=null; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); ed1 = (edittext) findviewbyid(r.id.edit1); submit = (button) findviewbyid(r.id.submit); cancel = (button) findviewbyid(r.id.cancel); submit.setonclicklistener(this); cancel.setonclicklistener(this); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmen

c# - Why does using Linker in Xamarin slows down application in release build? -

having used linker in xamarin reduce size of release build of android application, after having installed application.the application runs slower in release build compared when debugging application in debug mode. no error reported , application runs without crashing apart fact application has slowed down. creating release build without using linker not result in application slowing down. this bit confusing believe linker meant reduce application size , not affect application performance. is there explanation kind of scenario?

int - How do you implement the remainder method % for integers in java? How fast is it? -

naive implementation: if want find p % q , subtract q p until number < q . takes p/q subtractions, , p/q comparisons. how java this, , how fast it? when java compiler sees % operator, generates 1 of typed rem bytecode instructions , e.g. irem , lrem , frem , drem , etc. actual instruction depends on type. 2 int s instruction irem . these instructions interpreted jvm, producing cpu actions obtaining remainder. most cpus these days (at least, ones capable of running java) have built-in instructions take divisor , dividend, , produce quotient , remainder pair. why % operator fast division operator / . see this q&a information on how instruction may implemented in cpu.

How to get a tweetable link via stripe API -

i trying tweetable link using stripe relay api. know how can done via dashboard. beginning think not posible via stripe api. true? the tweetable urls have pretty defined structure if looked @ them: https://products.stripe.com/twitter/{{your_stripe_account_id}}/products/{{product_id}}

jsp - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; -

hey guys have error message, connect between server , client , select data mysql server , insert in mysql client insert statement not happen com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near ''context'.login values (1,'alamal','alamal','alamal','alamal)' @ line 1 and code.. <% try{ connection con1; connection con2; class.forname("com.mysql.jdbc.driver"); con1=(connection)drivermanager.getconnection("jdbc:mysql://192.168.101.1:3306/context","hospital","0000"); preparedstatement ps1=(preparedstatement)con1.preparestatement("select * hospital"); string str; resultset rs1=ps1.executequery(); while(rs1.next()){ con2=(connection)drivermanager.getconnection("jdbc:mysql://localhost:3306/context","root",""); con2.setautocommit(true); con2.createstatement

ios - no visible interface for QMBParallaxScrollViewController declare the selector viewControllerDidScroll -

Image
this question had mentioned many time here question big , maybe not able whats wrong in code purpose asked question trying do mix between 2 library found on internet first 1 qmbparallaxscrollviewcontroller , second 1 m6parallaxcontroller stunning view controller going fine in 1 case in bottomviewcontroller in case scrollviewcontroller calling method when view scrolling need call method inside class scrollviewcontroller class contain : #import "samplescrollviewcontroller.h" #import "qmbparallaxscrollviewcontroller.h" #import "uiviewcontroller+qmbparallaxscrollviewcontroller.h" @interface samplescrollviewcontroller (){ } @end @implementation samplescrollviewcontroller - (void)awakefromnib{ } - (void)scrollviewdidscroll:(uiscrollview *)scrollview { qmbparallaxscrollviewcontroller * parallaxcontroller = [self parallaxscrollviewcontroller]; [parallaxcontroller tableviewcontrollerdidscroll:self]; //here error } - (void)viewdidload

ruby on rails - error during signin in authentication_pages_spec -

Image
fllowing michael hartl tutorial i'm getting following error "undefined method pages" in authentication_pages_spec during sign in chapter 8. authentication_pages_spec.rb require 'rails_helper' rspec.describe "authenticationpages", type: :request subject { pages } describe "signin pages" before { visit signin_path } { should have_selector('h1', text: 'sign in')} { should have_selector('title', text: 'sign in')} end describe "signin" before { visit signin_path } describe "with invalid information" before { click_button "sign in" } { should have_selector('title', text: 'sign in')} { should have_selector('div.alert.alert-error', text: 'invalid')} describe "after visiting page" before { click_link "home" }

c# - Writing list to CSV file -

i have list of list of int called nn write csv file this: list<list<int>> nn = new list<list<int>>(); the nn list: 1,2,3,4,5,6 2,5,6,3,1,0 0,9,2,6,7,8 and output csv file should this: 1,2,0 2,5,9 3,6,2 4,3,6 5,1,7 6,0,8 what best way achieve that? if there better representation recommend instead of nested list i'll glad know. (the purpose each list of int weights between last , next layer in neural network). here how can it: list<list<int>> nn = new list <list<int>> { new list<int> {1,2,3,4,5,6}, new list<int> {2,5,6,3,1,0}, new list<int> {0,9,2,6,7,8} }; //get expected number of rows var numberofrows = nn[0].count; var rows = enumerable.range(0, numberofrows) //for each row .select(row => nn.select(list => list[row]).tolist()) //get row data columns .tolist(); stringbuilder sb = new stringbuilder(); foreach (var row in rows) { sb.appendline(string

java - Error in accessing HTTPS link, shows 403 forbidden and UnknownHostException -

i making app listen online radio. sent https radio site it. hplayradiostream("https://radio.itechnepal.com/pathibhara/stream"); so tried access input stream using following code: private static void hplayradiostream(string spec) throws malformedurlexception, ioexception, javalayerexception { try{ url url= new url(spec); httpsurlconnection huc= (httpsurlconnection) url.openconnection(); inputstream response= huc.getinputstream(); player player= new player(response); player.play(); } catch(exception e){ system.out.println(e); } } and gives 403 forbidden error. tried implementing using sslsocketfactory using following code: private static void hplayradiostream(string spec) throws malformedurlexception, ioexception, javalayerexception { try{ security.addprovider ( new com.sun.net.ssl.internal.ssl.provider()); system.setproperty ("java.protocol.handler.pkgs", &q

jquery - how to fetch json data from url? -

i not able fetch inside elements of json data. here's link json data. here's code: $(document).ready(function() { //after button clicked download data $('.button').click(function(){ //start ajax request $.ajax({ url: "http://www.miamia.co.in/dummy/?json=get_recent_posts", //force handle text datatype: "text", success: function(data) { //data downloaded call parsejson function //and pass downloaded data var json = $.parsejson(data); //now json variable contains data in json format //let's display few items $('#results').html('pages:'+ json.pages + '<br />postid: '+json.posts.id);//here not able id } }); }); }); things note: datatype: "json" data returned json, there no need parse json it data.posts[0].i

php - How can I prevent the ID from showing in the datalist element? -

i trying utilize datalist element. working 1 little hitch. selectable list showing 2 columns, both street_id , street columns. need street_id submitted dont want street_id show in datalist. <?php require 'connect_mysqli.php'; $sql = "select * streets"; $result = mysqli_query($con, $sql) or die ("error " . mysqli_error($con)); ?> <form action="test.php" name="test" method = "post"> <datalist id="street" name="streets"> <?php while($row = mysqli_fetch_array($result)) { ?> <option value="<?php echo $row['street_id']; ?>"><?php echo $row['street']; ?></option> <?php } ?> </datalist> <input type="text" name="street_val" id="test" autocomplete="off" list="street"> <input type="submit" value="submit"&g

amazon web services - How Docker and Ansible fit together to implement Continuos Delivery/Continuous Deployment -

i'm new configuration management , deployment tools. have implement continuous delivery/continuous deployment tool 1 of interesting projects i've ever put hands on. first of all, individually, i'm comfortable aws , know ansible is, logic behind , purpose. not have same level of understanding of docker got idea. went through lot of internet resources, can't the big picture. what i've been struggling how fit together. using ansible , can manage infrastructure code; building ec2 instances, installing packages... can deploy full application pulling code, modify config files , start web server. docker is, itself, tool packages application , ensures can run wherever deploy it. my problems are: how docker (or ansible , docker) extend continuous integration process!? suppose have source code repository, team members finish working on feature , push work. jenkins detects this, runs acceptance/unit/integration test suites , if passed, declares stable build.

javascript - Chart js how to toggle line without click -

i knee-deep in chart.js project , sake of simplicity, let's assume have lines a, b, , c in plain line chart. there way create chart containing 3 lines shows & b, , has c crossed out in legend , not displayed on graph itself? (toggled clicked.) the exact functionality i'm trying have 1. generate lines a, b, , c 2. simulate onclick() onto line c i think i'm overlooking simple , want sure before go rewriting chart.js source code. have searched docs no luck. thanks in advance! ok, simple. data line isn't hidden. (same clicked) { label: object.keys(data)[i], fill: false, linetension: 0.1, backgroundcolor: color, bordercolor: color, bordercapstyle: 'butt', borderdash: [], borderdashoffset: 0.0, borderjoinstyle: 'miter', pointbordercolor: color, pointbackgroundcolor: "#fff", pointborderwidth: 1, pointhoverradius: 5,

android - Delete or avoid receiving messages to default message app kitkat+ -

i'm trying make message application, work along side default messaging application. application needs intercept messages sent particular sender , not let default message application receive it. other messages should received default message app. after searching found not possible kitkat onwards unless message app default one. therefore thought of deleting messages particular number in default message app's inbox after receiving. kitkat onwards not possible unless app made default. isn't there way this? what want receive messages user specified number application while application not default message application.

Setting keys in Azure Key Vault without PowerShell -

how set secrets in azure key vault, without using powershell. using azure key vault securely store out connection strings , other application secrets. able add secrets using powershell scripts, wondering if there way add keys in azure keyvault, preferably using apis. need provide management tool using application admins can add/modify secrets in key vault. you can add keys , secrets via azure portal without having use powershell.

Android studio : using cookies -

i'm attempting use cookies (with no success), can it's value fine sending whole different story. i'm using 2 asynctask classes, 2 buttons , 2 textboxes. after clicking first button first class accesses url , acquires cookie saving first textbox string value (works fine). second click supposed cookie textbox , send second url show online message (does not work). the code 2 buttons: button1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { //executing first asyntask new downloadwebpagetask().execute(firstlink); } }); button2.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { string[] ar= new string[2]; //save value of second link , cookie value in array ar[0]=secondlink; ar[1]= string.valueof(textbox1.gettext()); //executing second asyntask new s

r - How can I merge two dataframes if two cols have to be the same? -

this question has answer here: how join (merge) data frames (inner, outer, left, right)? 12 answers i have 2 data frames. example df1 looks like: name month number 1.h 1 8 2.h 2 7 3.h 3 6 4.a 1 9 5.a 2 10 6.a 3 11 and df2 looks like: name month index 1.h 1 3 2.h 2 2 3.h 3 1 4.a 1 3 5.a 2 5 6.a 3 9 and want merge following df : name month number index 1.h 1 8 3 2.h 2 7 2 3.h 3 6 1 4.a 1 9 3 5.a 2 10 5 6.a 3 11 9 how can merge 2 df's df ? i have tried merge function by.x , by.y allows merging 1 column, want second column. you can merge on more 1 column @ time: merge(df1, df2, = c('name', 'month')) in fact, should default, default value of by int

database - Restore Operation in SQL Server 2008 -

i want restore database backup[.bak] file on existing database. backup file full database backup. more efficient? restoring new database or overwriting existing database? over top better. storage engine need zero-fill files (well... @ least log file if you've set configured instant file initialization) on disk. if files big, that's lot of 0's write. if overwrite, server knows space on disk isn't filled junk , doesn't have work.

Are there any alternatives to the git binary? -

i want run git on old distro (fedora 4). don't want trigger cascade of dependency installation in order have git binary run. i'm looking alternatives git binary, eg. in java or python. if there anywhere can 32 bit static build, might need. i suggest libgit2 . this lib portable, pure c implementation of git core methods. 100% cross-platform , has 0 dependencies. has many language bindings , like: ruby, python, node.js, , many more.

c# - localhost, production, inetpub and authentication -

i have taken on project built in asp.net mvc. project on windows 7 , uses ms visual studio 2012 , in c#. experience in past has been asp.net vb.net. did desktop applications, no web applications asp.net. this new project web application. suppose develop on local pc, once satisfied upload production. question is, on local pc, uses localhost:"with port number". prompts me login don't know (remember taking on someones code). can't pass testing on localhost before uploading production, yet discover whats about. i can't locate c:/inetpub/wwww is there website can suggest? it prompts me login , is prompts window or login page, if prompts window means he's using windows authentication just go web configration , , remove it <authentication mode="windows"/> now if it's login page try search in data base user table or , , if using asp.net membership in visual studio 2012 select web project in top menu select project a

javascript - Kendo UI MVVM declarative async template binding -

i have read docs (ie: http://docs.kendoui.com/howto/load-templates-external-files ) , checked out demos, don't see examples showing how asynchronously load external templates using kendo ui's declarative binding syntax . is behavior supported out of box, or need implement workaround application framework? have not been able dig relative information. here's example of layout block i'm rendering: { tag: 'div', id: 'summary-insured', name: 'summary-insured', class: 'summary-detail', data: { role: 'treeview', bind: { source: { type: 'method', hierarchical: true, config: { transport: { read: { url: 'summary.aspx/getinsureds' } } } }, events: { pa

android - Does SyncAdapter automatically detect internet connection availability to perform Sync? Or should I manually test it? -

i have syncadapter sync device data backend. whenever sync triggered, didn't want check internet connection in "onperformsync" method. have kind of flag ask syncadapter framework automatically? thank guys in advance. "sync manager takes care of other things checking network connectivity before initiating transfers , retrying downloads when connectivity dropped." for more, checkout video : introducing sync adapters provided udacity course developing android apps

ios - Is html_attributions needed for unused photo content from Google Places Web Service API? -

i'm working on ios app utilizes google's web service api. when searching places, each result contains "photos" field. within photos field "html_attributions" field. see "must displayed" when searching information it, have not seen conditions. my question is, if not use photo_reference/height/width fields inside photos field, still need display html_attributions field user or if content within photos field utilized/displayed? i have yet see other location specific attributions using web service google places. there else might missing? thanks , help! the html_attributions inside photos field applies photo, not rest of search / details response. the documentation on photo references says (emphasis added me): if returned photo element includes value in html_attributions field, have include additional attribution in application wherever display image . also, documentation place search responses , place details responses

ubuntu - Nagios, custom plugin doesn't work -

please, help! can't handle check_mem.sh plugin https://exchange.nagios.org/directory/plugins/system-metrics/memory/check-mem-%28by-nestor%40toronto%29/details i used guids found, in nagios web-interface see "(no output returned plugin)". if use command local on remote machine going fine: root@ubuntu:/home/test0# /usr/local/nagios/libexec/check_mem.sh -w 80 -c 90 memory: critical total: 975 mb - used: 937 mb - 96% used!|total=975;;;; used=937;;;; cache=221;;;; buffer=14;;;; in nrpe.cfg wrote this: command[check_mem]=/usr/local/nagios/libexec/check_mem.sh -w 80 -c 90 in nagios-server test0.cfg (config file of remote machine) wrote this: define service { use generic-service host_name test0 service_description memory usege1 check_command check_nrpe!check_mem } in commands.cfg this: define command{ command_name check_mem command_line $user1$/check_nrpe -h $hostaddress$ -c check_mem }

javascript - How do I get the text of a tag -

i trying grab text of clicked. have case 2 different links defined under teh same class , need identify of links clicked <div class="block pdp-estimate-quote"> <ul> <li> <a href="#">estimate payment</a> </li> <li> <a href="#">get quote</a> </li> </ul> </div> and want throw ga event when clicks either link using link text description. following code throws event shows text both links instead of 1 clicked. $('.pdp-estimate-quote a').click(function(){ var ctatext = $(this).closest(".pdp-estimate-quote").find('a').text(); datalayer.push({ 'event':'event', 'eventcategory': 'get quote', 'eventaction':ctatext, 'eventlabel':{{url path}} }) }); i might missing on question in order text of current element need do var ctatext = $(this).text(); so complet