Posts

Showing posts from March, 2013

java - android unparseble date Exception? -

i making application in using date functionality,but looking after several existing posts, still not able simpledateformat parser working. here code: public class gpsdemo extends activity { public static string tag = "abhi's log"; public static string imeii = "imei"; public static string start_time = "starttime"; public static string working_status = "workingstatus"; public static string address = "address"; public static int level = 0; button stop, hide; sharedpreferences pref; editor edit; date d1 = null; date d2 = null; string startingtime; string currenttime; context ctx = this; textview txt_start_time, txt_total_time, txt_total_distance, txt_address; @suppresslint("newapi") @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.demoooo); pref = preferencemanager.getdefaultsharedpreferences(getapplicationcontext()); edit...

jsf - SelectManyBox - Enum Not saving -

i still have problem selectmanycheckbox.. selectmanycheckbox: <p:selectmanycheckbox converter="genericenumconverter" value="#{aview.newobject.avalue}"> <f:selectitems value="#{enumbean.avaluevalues}" var="s" itemvalue="#{s}" itemlabel = "#{s.name}"/> </p:selectmanycheckbox> converter selectmanycheckbox same described here: use enum in h:selectmanycheckbox @facesconverter("genericenumconverter") public class genericenumconverter implements converter { private static final string attribute_enum_type = "genericenumconverter.enumtype"; @override public string getasstring(facescontext context, uicomponent component, object value) { system.out.println("getasstring 1: "); if (value instanceof enum) { system.out.println("getasstring 2: "); component.getattribu...

Encrypted databags in chef-environments -

we manage critical information in encrypted databags, e.g. ssl certificates: databags/ssl . we'd prefer give limited set of people access secret decrypts these encrypted databags avoid having our private keys on place. people knife-bootstrapping , deploying servers that, should have access. databags not limited environment global. either have make our recipes toggle on environments , pick different databags, or we'd need encrypt part of databag: only entries : { "id": "some_data_bag_item", "production" : { # hash data here }, "testing" : { # hash data here } } bag_item[node.chef_environment]["some_other_key"] how manage encrypted data-bags? keep secret , how avoid having hand out secret working on chef?

yii - filter grideview work with having condition in search function in criteria? -

i have grideview code $this->widget('zii.widgets.grid.cgridview', array( 'id'=>'lecture-grid', 'dataprovider'=>$model->search(), 'filter'=>$model, 'columns'=>array( array( 'header'=>'name', 'type' => 'raw', // 'name'=>'name', 'value' => 'chtml::link($data->name,yii::app()->baseurl . "/uploads/" . $data->name)', ), array( 'header'=>'pages', 'value'=>'$data->slide_num' ), array( 'header'=>'type', 'value'=>'$data->type' ), array( 'header'=>'size', 'value'=>'$data->size' ), // 'subject.name' array ( 'header'=>'subject', 'value' =>...

android - setGravity in code not working -

Image
in program have edittext . want, set text gravity in code: { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); int size = 40; tablelayout tl; tl = (tablelayout)findviewbyid(r.id.layout); tablerow tr; tr = (tablerow)findviewbyid(r.id.tablerow); edittext et = new edittext(this); tablerow.layoutparams params = new tablerow.layoutparams(); params.height = size; params.width = size; et.setlayoutparams(params); et.setbackgroundcolor(color.blue); et.setgravity(gravity.center_horizontal | gravity.center_vertical); et.settextsize(size - size / 4); et.settext("3"); tr.addview(et); } my xml: <tablelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/layout" xmlns:android="http://schemas.android.com/apk/res/android"> <tablerow android:id="@+id/tablerow...

c++ - Why can't GCC optimize the logical bitwise AND pair in "x && (x & 4242)" to "x & 4242"? -

here 2 functions claim same thing: bool fast(int x) { return x & 4242; } bool slow(int x) { return x && (x & 4242); } logically same thing, , 100% sure wrote test ran 4 billion possible inputs through both of them, , matched. assembly code different story: fast: andl $4242, %edi setne %al ret slow: xorl %eax, %eax testl %edi, %edi je .l3 andl $4242, %edi setne %al .l3: rep ret i surprised gcc not make leap of logic eliminate redundant test. tried g++ 4.4.3 , 4.7.2 -o2, -o3, , -os, of generated same code. platform linux x86_64. can explain why gcc shouldn't smart enough generate same code in both cases? i'd know if other compilers can better. edit add test harness: #include <cstdlib> #include <vector> using namespace std; int main(int argc, char* argv[]) { // make vector filled numbers starting argv[1] int seed = atoi(argv[1]); vector<int> v(1000...

linux - how to get exit code when using xargs (parallel) -

i'd made script launching parallel rsync process: #! /bin/bash list=$1 dest_dir=$2 rsync_opts=$3 #echo "rsyncing from=$src_dir to=$dest_dir rsync_opts=$rsync_opts" echo $list|xargs -n1 -d, echo|xargs -n1 -p 0 -i% rsync --rsync-path='sudo rsync' ${rsync_opts} % ${dest_dir} then, have problems exit status of rsync process. know possible array of pipestatus, need catch exit code know if rsync made or not. anyone knows? the man page xargs shows possible exit status values, can produce single aggregated exit code, not exit code per child runs. try 1 of these options: have process xargs spawns print exit code , have parent task parse exit code outputs determine exit code each rsync. use gnu parallel --joblog option. create file containing commands run in parallel along exit code , other information. file parsed after parallel exits determine rsync commands failed , respective error codes.

Error empty response when logging in magento admin -

i stuck on issue, everytime log in magento admin, it's give me err_empty_response on google chrome , connection reset on mozilla . the shop still accessable, it's load slowly. it's working fine before, , become this. i can't find similiar issue this, shop return empty response , still can access admin page , it's caused of enabling flat category/products set up. i'm not sure if client enabling flat category/products . if so, table should edit using phpmyadmin ? since can't access admin page, or there thing cause this? some error code, files missing in admin directory or htaccess thing, i'm not doing changes on htaccess before . need help. restarting apache , mysql worked me service httpd restart service mysqld restart hope helps.

Why does Java allow null value to be assigned to an Enum -

this more of design question. (so, no code. post code of creating enum , assigning null if want me it. :)) i've been thinking lot lately can't come 1 reason. enum constants implicitly static , final. enum meant - "i can take value of 1 of constants present in me". why allow enum have null value?. why not implicitly default enum's value enum.default or enum.none?. isn't better approach allowing enum null? firstly null means non-existence of instance. providing default constant default or none , change meaning. secondly, why need default represent seems non-existent? purpose of null . basically, have initialize , store object, shouldn't exist whatsoever. btw, it's not language choice. it's on how implement enum. can provide constant default , or unknown in enum, , avoid assignment of null reference in code. famously known null object pattern . saying null assignment should compiler error, say, since enum anyways compiled class ,...

android - Loading spinner not showing correctly -

i trying put spinner while data loaded , ui updated task this: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_road_details); settitle("details"); startbutt = (button)findviewbyid(r.id.beginjourney); map = (button)findviewbyid(r.id.map_btn1); boolean greenbuttstate = getintent().getbooleanextra("greenbuttstate", false); boolean fastbuttonstate = getintent().getbooleanextra("fastbuttonstate", false); asynctask<void, void, void> loadingtask = new asynctask<void, void, void>() { progressdialog dialog = new progressdialog(roaddetails.this); @override protected void onpreexecute() { this.dialog.setmessage("message"); this.dialog.show(); } @override protected void doinbackground(void... params) { final hashmap<string...

ruby on rails - Best practice for testing capybara visit page -

so wondering best way go testing page visited using capybara describe "pages" subject { page } describe "home page" "should have title 'my home page'" visit root_path expect(page).to have_title('my home page') end end end now seems standard way test compare title of page (as above). doesn't seem super robust though, if page title changes, break tests reference this. is standard practice? or there way test it. thanks, matt i don't think example gave standard way test page visited. standard way see if page's title match expect =p if want make assertion path in capybara, more reliable way using current_path . so, can rewrite example follows: describe "pages" describe "home page" "will visit root_path" visit root_path expect(current_path).to eql root_path end end end notice not valuable test though. know capybara tested ,...

Windows Phone 8 C# facebook app registration -

Image
hi i've created app windows phone 8 using contososocial facebook login interface. uses following call this: facebooksessionclient fb = new facebooksessionclient(appid); fb.loginwithapp("basic_info,publish_actions,read_stream", "custom_state_string"); this works fine when use default appid when change 1 given facebook following app registeration following error: given url not premitted application cofiguration.: 1 or more of given url's not allowed app's settings. must match website url or canvas url, or app domain must subdomain of 1 of apps domains..? i've searched , problem has come on several occations , far can work out it's app settings on facebook.? facebook asks app domain i've left blank i'm not sure or used for..? need one..? i've followed several tutorials scrumptious show different app registration process on screens i'm faced with. little research revealed facebook has changed process making more conf...

javascript - How to add json value inside ng-model in angular -

<div data-ng-repeat="credentialsdata in credentialsdatas"> <div data-inline-validate data-error="{{ credentialsdata.key }}"> <label>{{ credentialsdata.key }}<i class="text-error">*</i></label> <input type="text" data-ng-model="datasource.{{ credentialsdata.key }}" placeholder="{{ credentialsdata.key }}" /> </div> </div> but here throwing error data-ng-model="datasource.{{ credentialsdata.key }}" you don't need use binding in case, try javascript bracket notation syntax: data-ng-model="datasource[credentialsdata.key]"

javascript - html() & text() ignoring \n and <br /> -

i don't understand why happening, got description of app google play store, in form of json, using jquery add description div, instead of printing is, gives block of paragraph , ignores \n or <br /> tag. var description = json.description; alert(description); when alert description, shown above, there proper paragraph format next line[\n] included want it, when add required div either html() or text() , ignores next line \n $('#appname').html(description) ; i tried replace next line tags, still result same, don't know why var test = description.replace(/\s\n+/g, '<br />'); $('#appname').html(description) try this var test = description.replace(/\n/g, '<br />'); $('#appname').html(test ); your regex not work if there no white space before newline character. dont need put + /g replace new line characters.

subtype - Equivalence of Array types in Ada -

while trying make ada binding third party c/c++ library (sapnwrfcsdk) came problems of type inference array types: first problem: the gnat-binding-generator gcc (gcc -fdump-ada-spec) generating lots of intermediate named array types different index ranges: type anon3115_anon3128_array array (0 .. 8) of aliased sap_uc; type anon3115_anon3131_array array (0 .. 3) of aliased sap_uc; type anon3115_anon3134_array array (0 .. 12) of aliased sap_uc; those types used in records. if want pass fields procedure or function have unbounded type signature example following type: type sap_uc_array array (int range <>) of aliased sap_uc; but generated types no subtypes of cannot passed. 1 solution change field declarations in records to: field : sap_uc_array(0 .. 8); but mean "process" generated binding file , change definitions. possible create named array subtype specified index range or solution? second problem: some array type definitions have equivalent com...

c++ - SDL_Quit is ambigious -

everytime use sdl_quit or sdl_mousebuttondown or event error messages ambigious.i using sdl 2.0 , error dissapears when don't include sdl_image.h. don't know or whats problem? ideas? void game::handleevents() { sdl_event event; if(sdl_pollevent(&event)) { switch (event.type) { case sdl_mousebuttondown: m_brunning = false; break; default: break; } } } my sdl_image.h /* sdl_image: example image loading library use sdl copyright (c) 1997-2013 sam lantinga <slouken@libsdl.org> software provided 'as-is', without express or implied warranty. in no event authors held liable damages arising use of software. permission granted use software purpose, including commercial applications, , alter , redistribute freely, subject following restrictions: 1. origin of software must not misrepresent...

sql - Creating MySQL relationships with foreign keys and alter statements -

i try specific because feel understanding of subject isn't quite precise well. problem understanding how create relations between tables foreign keys add alter statements. have these tables. create table article ( content text not null, published_on date not null, created_on date not null, ); create table category( name varchar(30) not null, date_created date not null, ); create table user( income float(30, 30) not null, password varchar(30) not null, picture_url text not null, ); create table tag( description varchar(30) not null, second_priority float(30, 30) not null, ); to have make there relationships: tag has 1 one connection category category has many 1 connection user user has 1 many connection article and use there statements: alter table tag add constraint foreign key (tag_id) references category (category_id); alter table category add constraint foreign key (user_id) references user (user_id); alter table user add ...

Why is logging behaving this way in python -

so, recently, i've experienced weird behaviour in project, did small test reproduce behaviour. here complete code: import logging logging import config config.dictconfig({ 'version': 1, 'formatters': { 'fmt_root': {'format': '[ / ] - %(levelname)s - %(name)s - %(message)s'}, 'fmt_pkg': {'format': '[ /pkg ] - %(levelname)s - %(name)s - %(message)s'}, 'fmt_pkg_sub': {'format': '[ /pkg/sub ] - %(levelname)s - %(name)s - %(message)s'}, }, 'handlers': { 'hnd_root': { 'class': 'logging.streamhandler', 'level': logging.debug, 'stream': 'ext://sys.stdout', 'formatter': 'fmt_root', }, 'hnd_pkg': { 'class': 'logging.streamhandler', 'level': logg...

ios - Values in my table not showing -

i new xcode. trying small project on ibeacon. problem have included tableview in viewcontroller (i using tab view controller). wanted update table once have found matching beacon major value wanted. with code, once got region , detected beacon, have received notification. when open notification table not updated array set. #import "sbsfirstviewcontroller.h" @interface sbsfirstviewcontroller () @property (strong, nonatomic) clbeaconregion *beaconregion; @property (strong, nonatomic) cllocationmanager *locationmanager; @property bool checkdidenterbusstop; @property (strong, nonatomic) clbeacon *selectedbeacon; @end @implementation sbsfirstviewcontroller nsarray *buses; bool checkdidenterbusstop = no; -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{ if(checkdidenterbusstop == yes){ return [buses count]; } return 0; } -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath: (nsindexpath *)in...

java - AES-NI intrinsics enabled by default? -

oracle has java 8 regards aes-ni: hardware intrinsics added use advanced encryption standard (aes). useaes , useaesintrinsics flags available enable hardware-based aes intrinsics intel hardware. hardware must 2010 or newer westmere hardware. example, enable hardware aes, use following flags: -xx:+useaes -xx:+useaesintrinsics to disable hardware aes use following flags: -xx:-useaes -xx:-useaesintrinsics but not indicate if aes intrinsics enabled default (for processors support it). question simple: if processor supports aes-ni, aes intrinsics used? bonus question: there way test if aes-ni being used? guess can guess based on performance, that's not optimal or sure fire way of testing. for readers not familiar aes-ni intrinsics: it's replacing byte code pre-compiled machine code, using aes-ni instruction set. happens jvm, not show in api of java runtime or bytecode. the flag has default of true , set false if detection fails, can use +...

objective c - how to keep commas in float value in ios? -

i want format floating point number 3,535,816.85 format. have used nsnumberformatter this. here code, nsnumberformatter * formatter = [[nsnumberformatter alloc] init]; [formatter setnumberstyle:nsnumberformatterdecimalstyle]; [formatter setmaximumfractiondigits:13]; // set if need 2 digits nsstring * newstring = [formatter stringfromnumber:[nsnumber numberwithfloat:floatpspercentage]]; however, not getting expected result. missing? try code: nsnumberformatter *formatter = [[nsnumberformatter alloc] init]; [formatter setnumberstyle:nsnumberformattercurrencystyle]; nsstring *groupingseparator = [[nslocale currentlocale] objectforkey:nslocalegroupingseparator]; [formatter setgroupingseparator:groupingseparator]; [formatter setgroupingsize:3]; [formatter setalwaysshowsdecimalseparator:no]; [formatter setusesgroupingseparator:yes]; as can see here .

kineticjs (HTML5 Canvas) - smoothing image when scaling down -

Image
when add large images onto page kineticjs getting poor quality when setting them quite small sizes. result jagged/rough. if add same image , set dimensions img src better quality , smoothly scaled down version. is there can add combat this? jsfiddle, screenshot , code below jsfiddle: http://jsfiddle.net/vtlkn/6/ // define stage var stage = new kinetic.stage({ container: "canvas", width: 300, height: 200 }); //define layer images var layer = new kinetic.layer(); stage.add(layer); // draw image function function drawimage(image,w,h,x,y) { // define function's image properties var theimage = new kinetic.image({ image: image, x: x, y: y, width: w, height: h }); // add function's image layer layer.add(theimage); layer.draw(); } // define image 1 , draw on load var image1 = new image(); image1.onload = function() { drawimage( this, 250, 188, 0, 0); }; image1.src = "http...

navigation - How to put something extra while navigate another page in windows phone -

i created listpage , when click in general button in main page have navigate page listpage , put while navigating in order understand page going list, otherwise have create lots of listpages every category private void btn_general_click(object sender, routedeventargs e) { navigationservice.navigate(new uri("/listpage.xaml", urikind.relative)); } you can use page uri put contextual data: navigationservice.navigate(new uri("/listpage.xaml?list=list1", urikind.relative)); in listpage , can retrieve data looking navigationcontext.querystring property: protected override void onnavigatedto(navigationeventargs e) { if (navigationcontext.querystring.containskey("list")) { string list = navigationcontext.querystring["list"]; // whatever } }

html - Allowed children for an <a> element? -

i have been working lot of html structuring lately , started wonder elements allowed children of <a> element? changes in html5 although previous versions of html restricted element containing phrasing content (essentially, in previous versions referred “inline” content), element transparent; is, instance of element allowed contain flow content (essentially, in previous versions referred “block” content)—if parent element of instance of element element allowed contain flow content. html language reference

Google Stack column chart works fine with Chrome but doesnt work with IE8 -

i looked out solution problem couldnt find solution. i have code work fine chrome , firefox, throws error "expected identifier, string or number" ie8 <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback(drawchart); function drawchart() { var data = google.visualization.arraytodatatable([ ['genre', 'fantasy & sci fi', 'romance', 'mystery/crime', 'general', 'western', 'literature', { role: 'annotation' } ], ['2010', 10, 24, 20, 32, 18, 5, ''], ['2020', 16, 22, 23, 30, 16, 9, ''], ['2030', 28, 19, 29, 30, 12, 13, ''], ]); var o...

html - Insert data with id on a table with auto-increment - WebSQL -

i'm trying import data websql database. on tables have auto-increment, prevents me inserting data normal insert into query. is there equivalent of set identity_insert (on/off) websql or work around? thanks

android - ClickListener in ScrollView intercepts scrolling -

i have 2 rows of imageviews in scrollview. imageviews have onclicklistener , when want scroll in area doesn't work. guess click listeners intercept scrolling of scrollview. what's best way change behaviour ? view hierarchy this: <scrollview> <relativelayout> <framelayout> </framelayout> <relativelayout> </scrollview> in framelayout put fragment has linearlayout in inflate other linearlayouts this: productholder.productlayout.setonclicklistener(new view.onclicklistener() { @override public void onclick(final view v) { } }); maybe use ontouchlistener instead of onclicklistener. in ontouchlistener can check if action of motion event click , consume event (return true). otherwise can leave event other listeners (return false) consume. note, might need add additional implementation figuring out image view clicked, without seeing layout, it's hard ...

c# - Issues invoking calls in Windows Azure Management Libraries 1.0.1 -

when invoke async method in azure management library application crashes without exception or other indication. using visual studio 2013 .net 4.5 , windows azure management libraries 1.0.1 private static async void listlocation() { const string filepathcert = @"c:\path\to\certificate"; var certificate = new x509certificate2(filepathcert, "password"); var credentials = new certificatecloudcredentials("xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx", certificate); try { using (managementclient client = cloudcontext.clients.createmanagementclient(credentials)) { var result = await client.locations.listasync(); //here application terminates without message /exception var locations = result.locations; foreach (var location in locations) { console.writeline("location: {0}", location.name); foreach (var feature in location.available...

c# - columnwidthchanging event of Listview is not fire? -

i try not allow resize column in listview can't don't know reason why columnwidthchanging event of listview not fire try debug , see never method listview1_columnwidthchanging in form1.designer.cs: partial class form1 { /// <summary> /// required designer variable. /// </summary> private system.componentmodel.icontainer components = null; /// <summary> /// clean resources being used. /// </summary> /// <param name="disposing">true if managed resources should disposed; otherwise, false.</param> protected override void dispose(bool disposing) { if (disposing && (components != null)) { components.dispose(); } base.dispose(disposing); } #region windows form designer generated code /// <summary> /// required method designer support - not modify /// contents of method code editor. /// </summary> ...

Use HTML to move or copy a file -

i using html web-page, don't want use php coding. trying find code allow me upload file , place in specified directory. how that. input type="file", allows me specify file code allows me move or copy file location. it's impossible oparte on upload file without server-side technology (like php), sorry...

java - JComboBox inside a Border causes IllegalComponentStateException -

Image
i found useful code create titled border contains component title santhosh kumar t: componenttitledborder . employed using check box, when decided use combo box, shows text part of combo box not drop down button: when click on combo box following exception: exception in thread "awt-eventqueue-0" java.awt.illegalcomponentstateexception: component must showing on screen determine location @ java.awt.component.getlocationonscreen_notreelock(unknown source) @ java.awt.component.getlocationonscreen(unknown source) @ javax.swing.jpopupmenu.show(unknown source) @ javax.swing.plaf.basic.basiccombopopup.show(unknown source) @ javax.swing.plaf.basic.basiccombopopup.togglepopup(unknown source) @ javax.swing.plaf.basic.basiccombopopup$handler.mousepressed(unknown source) @ java.awt.component.processmouseevent(unknown source) @ javax.swing.jcomponent.processmouseevent(unknown source) @ java.awt.component.processevent(unknown source) @ java.awt.container.processevent(unknown sour...

Previous button in Android application -

i developing simple android application. have fragment 2 buttons: prev , home. if touch home works fine (back main menu) must touch twice prev button if want previous activity. don't know going on. searched nothing. has got same problem? thanks help. here code: @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.navigation_activity_fragment, container, false); textview textview = (textview) view.findviewbyid(r.id.activitytitle); button home = (button) view.findviewbyid(r.id.home); button prev = (button) view.findviewbyid(r.id.button2); home.setonclicklistener(new onclicklistener(){ @override public void onclick(view v) { intent = new intent(getactivity(), mainmenuactivity.class); startactivity(i); } }); prev.setonclicklistener(new onclicklistener(){ @override public void onclick(view arg0) { ...

extjs3 - Extjs Show Custom row in grid -

i using ext js 3.2. have grid. want customize existing grid. want add hardcoded value row0, not working below code my store var store = new ext.data.store({ id : 'user', proxy : proxy, reader : reader, writer : writer, // <-- plug datawriter store url: 'cat/view.action?catid='+catid_para+'&teaid='+teaid_para+'&flag='+0, remotesort: true, remotesort: true, autosave : false, // <-- false delay executing create, update, destroy // requests until told [save] // buton. }); var record = new siteutility({ id:'0', fname:'4', lname:'3444', attandance: 'g', }); var parent_grid=ext.getcmp('org_gri...

Feature test Rails engine using current_user -

i'm breaking big rails app pieces using mountable engines. my engine accesses current user in controller so: require_dependency "lesson_notes/application_controller" module lessonnotes class notescontroller < applicationcontroller def index @notes = current_user.notes end end end in feature spec create user using factorygirl , log user in - this: feature "notes page" let(:user) { create(:user) } before login_as user visit "/lesson_notes" end end however, in engine feature spec, how create user using factorygirl? model in parent app in engine mounted, how accessible engine specs? from point of view, engine separate box main application , mounted in application, hence it's test cases should independent of those. may should mock user model test engine's feature instead of creating factory.

sockets - How to keep a tcp connection always open with node.js -

i'm building tcp-message server nodejs. sits on server waiting accept connection lets arduino. as it, @ connection-time, identifies unique id (not ip) i'm able write data server > arduino without knowing ip address of client-device. but efficient, want connection open long possible, preferably long client-device closes connection. (eg on ip change or something) this (relevant part of) server: var net = require('net'), sockets = {}; var tcp = net.createserver(function(soc){ soc.setkeepalive(true); //- 1 soc.on('connect', function(data){ soc.setkeepalive(true); //- 2 }); soc.on('data', function(data) { //- stuff data, , after identification // store in sockets{} }) }).listen(1111); is soc.setkeepalive(true) right method keep connection alive? if so, right place put it? in connect event (1), or right in callback (2). if not way it, is? your best bet periodically send own heartbeat m...

shell - Stop android adb ping progamatically and print statistics -

i trying send ping x amount of seconds instead of amount of pings , gather results. notice if shell in , run "ping www.google.com" , stop ctrl + c not print statistics, if run "ping -c5 www.google.com" statistics print. there way send ping command, have time out after specified time, , print ping statistics? note: sending programmatically java. c:\users\field_test>adb shell shell@android:/ $ ping www.google.com ping www.google.com ping www.google.com (173.194.46.116) 56(84) bytes of data. 64 bytes ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=1 ttl=54 time =55.7 ms 64 bytes ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=2 ttl=54 time =70.9 ms 64 bytes ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=3 ttl=54 time =60.8 ms 64 bytes ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=4 ttl=54 time =71.1 ms 64 bytes ord08s13-in-f20.1e100.net (173.194.46.116): icmp_seq=5 ttl=54 time =69.8 ms 64 bytes ord08s13-in-f20.1e100.net (173.194.46.116...

android - How long onhandleintent wait after stop service -

suppose have service , in onhandleintent task running , meanwhile stopped service , ondestroy() called how long stays in onhandleintent. suppose code this... boolean isrunning = true; public void ondestroy() { super.ondestroy(); // suppose don't false here bool. } protected void onhandleintent(final intent intent) { super.onhandleintent(intent); while(isrunning){ // stuff running here... } } i know should false boolean in ondestroy() buti want know how long stay in onhandleintent() evenif don't make boolean false. please give me valuable views.

c# - Nancy - embedded views from other assembly -

i have created 2 projects: class library file views\other.html set embedded resource. console app nancy self-hosting set up, bootstrapper , nancy module responds returning view named "other.html" - 1 defined in other assembly. bootstrapper config: protected override void configureapplicationcontainer(tinyioccontainer container) { base.configureapplicationcontainer(container); resourceviewlocationprovider.rootnamespaces.add(gettype().assembly, "consoleapplication1.views"); // (1) resourceviewlocationprovider.rootnamespaces.add(typeof(class1).assembly, "classlibrary1.views"); } protected override nancyinternalconfiguration internalconfiguration { { return nancyinternalconfiguration.withoverrides(onconfigurationbuilder); } } private void onconfigurationbuilder(nancyinternalconfiguration x) { x.viewlocationprovider = typeof(resourceviewlocationprovider); } application starts configuration fails return "other.html...

html - align two divs, one at top one at bottom of a third div -

i have code: <div id="container"> <div id="1"> div 1</div> <div id="2"> div 2</div> </div> i want put div 1 @ top, , div 2 @ bottom of container , no matter how height of container . how can so? set container's position relative, , position of div's 1 , 2 absolute. set div 1 top:0 , div 2 bottom 0 (also avoid using number id's css compatibility): jsfiddle example #container { position:relative; height:100px; width:100px; border:1px solid #999; } #div1, #div2 { position:absolute; } #div1 { top:0 } #div2 { bottom:0; }

Optimizing MySQL self-join query -

i have following query: select distinct(a1.actor) actions a1 join actions a2 on a1.ip = a2.ip a2.actor = 143 , a2.ip != '0.0.0.0' , a2.ip != '' , a2.actor != a1.actor , a1.actor != 0 this explain of query: +----+-------------+-------+-------+------------------+---------+---------+------------------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | | +----+-------------+-------+-------+------------------+---------+---------+------------------+------+--------------------------+ | 1 | simple | a2 | range | actor,ip,actorip | actorip | 66 | null | 3800 | using where; using index | | 1 | simple | a1 | ref | ip | ip | 62 | formabilio.a2.ip | 11 | using | +----+-------------+-------+-------+------------------+---------+---------+------------------+------+--------------------------+...