Posts

Showing posts from April, 2012

javascript - set dijit/form/TimeTextbox programmatically -

i'm not able set value of dijit/form/timetextbox date returned database or string -- i'm using dojo version 1.10.4 widget: <input type="text" data-dojo-type="dijit/form/timetextbox" data-dojo-attach-point="tbmtgtime" value="t15:00:00" trying string: this.tbmtgtime.set("value", "10:30 am");//doesnt work trying value sqlserver database: var mtgdate = new date(parseint(mi.onsitemeetingdateint) * 1000); mtgdate.settime(mtgdate.gettime() + mtgdate.gettimezoneoffset() * 60 * 1000); this.tbmtgdate.set("value", mtgdate); var mtgtime = ddl.format(mtgdate, { selector: "time", timepattern: 'hh:mm a' }); this.tbmtgtime.set("value", mtgdate);//mtgdate 10:30 thanks your string example won't work because it's not in thh:mm f

algorithm - Copying files in a distributed system so that all servers have a copy of all files -

full disclaimer: interview question: there m-machines. need copy data-sets among these m machines each other each server has copy of data-sets. optimal algorithm this? i know can solve problem in o(mn) (where n average number of data-sets on each machine) iterating through each server. there better approach? what self-replication system? http://en.wikipedia.org/wiki/self-replication#a_self-reproducing_computer_program e.g.; if have m=100 machines, each data set have: 1tic: 1machine data 2tic: 2machines data 3tic: 4machines data 4tic: 8machines data 5tic: 16machines data 6tic: 32machines data 7tic: 64machines data 8tic: 64machines data 9tic: 100+machines data i think less complex o(mn)

What is the proper way to getInitialState with remote data in Reactjs? -

it solved. code ok, problem improper import. it long post (due code samples). i'll appreciate patience , thankful help! we have ror back-end , react on front-end , using alt implementation of flux. use babel compile es6 es5. problem can not render component due 2 errors. first uncaught typeerror: cannot read property 'map' of undefined it appears on render function of mappalette component: render() { return ( <div> {this.state.featurecategories.map(fc => <paletteitemslist featurecategory={fc} />)} </div> ); } and second uncaught error: invariant violation: receivecomponent(...): can update mounted component. so here whole mappalette component "use strict"; import react 'react'; import paletteitemslist './paletteitemslist'; import featurecategorystore '../stores/featuretypestore'; function getappstate() { return { featurecategories: featurecategorystore.getstate().featureca

java - Camel in OSGi Container: Apply InterceptStrategy to all camel contexts -

i have several bundles (a, b, , c) deployed osgi container, each containing camelcontext , routes. have bundle (m) camelcontext route (for collecting monitoring data) , interceptstrategy bean. interceptstrategy bean m automatically apply of other camelcontext s in container (i.e., in a, b, , c), without having modify other bundles. ultimately, goal wiretap data each camelcontext route in m, without having make changes a, b, or c explicitly route exchange . approach or similar approach doable? all of camelcontext s configured using spring xml. update: additional context bundles a, b, , c contain core product responsible processing data. bundle m contains optional monitoring tool, designed measure parameters of data flowing through a, b, , c. currently, adding on optional tool requires changing routes in a, b, , c add additional processor s enrich exchange monitoring data , read monitoring data prior <to /> endpoints. the goal able drop in bundle m verified-

sql - Mysql select top N scores per group FOR EACH User -

i'm trying buddy out "simple" website golf group. database i'm trying use store players scores every round completed. there 2 types of games played , stored. example below: id game type score 1 12 1 12 1 1 1 15 1 15 1 b 12 1 b 5 1 b 10 1 b 12 1 b 5 1 b 10 2 6 2 9 2 1 2 3 2 2 2 b 8 2 b 10 2 b 15 2 b 3 2 b 12 what trying is, select top 3 scores of game type each user , select top 2 scores game type b each user. need select yield can sum scores each player: id game type score 1

wif - Why WCF custom ServiceHostFactory getting called every time? -

Image
i have wcf service (hosted in iis 7.5) has svc file less activation using following <servicehostingenvironment> <serviceactivations> <add factory="string" service="string"/> </serviceactivations> </servicehostingenvironment> i using custom host factory not default one. and service wstrustservicecontract. if see declaration of class [servicebehaviorattribute(name = "securitytokenservice", namespace = "http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice", instancecontextmode = instancecontextmode.single, concurrencymode = concurrencymode.multiple)] [aspnetcompatibilityrequirementsattribute(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class wstrustservicecontract : iwstrustfeb2005synccontract, iwstrust13synccontract, iwstrustfeb2005asynccontract, iwstrust13asynccontract, iwsdlexportextension, icontractbehavior so can infer that

nasm - Assembly Language -

i need following covert problem in assembly 64-bit nasm. convert decimal binary , vice versa. when print dont right answers integer part of binary decimal , fraction part of binary decimal. comments appreciated. feedback. here output: the integer part of decimal binary is: 1111100 fraction part of decimal binary .011 integer part of binary decimal 173 fraction part of binary decimal .768 here code: ;convert: convert numbers between bases ;compile: nasm -f elf64 -l convert.lst convert.asm ;link: gcc -m64 -o convert convert.o

regex - extract loosly structured wikipedia text. html -

some of html on wikipedia disambiguation pages is, shall say, ambiguous, i.e. links there connect specific persons named corzine difficult capture using jsoup because they're not explicitly structured, nor live in particular section in this example . see page corzine page here . how can hold of them? jsoup suitable tool task? perhaps should use regex, fear doing because want generalizable. </b> may refer to:</p> <ul> <li><a href ^this here standard, maybe use regex match that? <p><b>corzine</b> may refer to:</p> <ul> <li><a href="/wiki/dave_corzine" title="dave corzine">dave corzine</a> (born 1956), basketball player</li> <li><a href="/wiki/jon_corzine" title="jon corzine">jon corzine</a> (born 1947), former ceo of <a href="/wiki/mf_global" title="mf global">mf global</a>, former gover

ruby on rails - Asset pipeline DEPRECATION WARNING tsort.rb:226 -

i have rails 4.2 working fine on development in production env have following warning: deprecation warning: configuration option `config.serve_static_assets` has been renamed `config.serve_static_files` clarify role (it merely enables serving in `public` folder , unrelated asset pipeline). `serve_static_assets` alias removed in rails 5.0. please migrate configuration files accordingly. (called block in tsort_each @ /home/xxx/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:226) however don't have config.serve_static_assets in app config. might configured somewhere. please how rid of this. in advance. the deprecation warning you're getting caused gem that's setting configuration you. me, we're using rails_serve_static_assets , we're using version 0.0.2 . remove deprecation warning, update gem (issue has been fixed in version 0.0.3 ) bundle update rails_serve_static_assets

rust - When should I implement std::convert::From vs std::convert::Into? -

i see std::convert::into has implementation implements std::convert::from : impl<t, u> into<u> t u: from<t> there far more specific implementations of from , while into has 3 specific implementations, makes seem prevailing decision implement from default. i'm there times want implement into , not from , i'm not seeing them. interestingly, the original rfc std::convert traits suggesting opposite blanket impl: impl<t, u> from<t> u t: into<u> but on pr implementing it, it changed opposite : added from => into implementation, makes possible add conversions in both directions without running afoul of coherence. example, have from<[t]> vec<t> t: clone , yields corresponding going in other direction -- despite fact 2 types live in different crates. i believe addresses few concerns things implementing instead of into it indeed not possible make impl<'a, t> into<foo> &'a

Android app keeps 'closing', but no errors being shown in logcat -

this main class forwarding username goalactivity class. cannot figure out issue is. keeps crashing unknown reason me. i've followed various tutorials, , cannot figure out issue. seems retrieve username correctly, , convert string. create intent , pass username value key. mainactivity.java import android.app.activity; import android.app.dialog; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.toast; import com.example.agray.carpediem.logindatabaseadapter; import com.example.agray.carpediem.r; import com.example.agray.carpediem.signupactivity; public class mainactivity extends activity { button btnsignin,btnsignup; logindatabaseadapter logindatabaseadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //create instance

Stop new line for C++ cin -

in c++, iostream automatically puts in new line after cin. there way rid of this? i want use iomanip format information table, so: cin cout 0.078125 3da00000 -8.75 c10c0000 23.5 41bc0000 (random numbers) example code: #include <iostream> using namespace std; int main() { int num; cin >> num; //now new line. cout << num << endl; return 0; } you presumably pressed return key send input command line program's standard input. that's newline coming from. can't read number cin before newline appears in console, because newline causes console hand input on program in first place. could, user, configure console (or whatever running program) act differently, there's no way program force such behavior. if want have input , output on same line, need find way "write previous line". how works depends on console (see how rollback lines cout? ). there no standard way because cin , co

Artificial neural network configuration -

Image
i believe know answer question already, wanted input community. below question. the following diagram represents artificial neural network associative memory discussed in chapter. stable configuration associate initial pattern in 2 neurons opposite each other on perimeter excited? answer 1 : if network given initial configuration in 2 opposing units excited, blink – alternating between vertical , horizontal “lines.” answer 2: if network given initial configuration in 2 opposing units excited, center until excited , perimeter units remain inhibited. answer 3: pattern in @ least 2 perimeter units excited , center unit inhibited associated pattern in perimeter units, center unit, excited. answer4: pattern in @ least 2 perimeter units excited , center unit inhibited associated pattern in perimeter units excited , center unit inhibited. the answer choose answer 4. reason why choose answer 4 because if @ diagram weight of outer diagram positive. may sound trivial, bec

angularjs - Fetching an object from a service which hasn't yet been created -

folks: i have 2 controllers, ctrla , ctrlb - both unrelated each other within same page. ctrla queries end point , returns json object tags , passed service method myservice.savetags(tags) store object. ctrlb needs populate $scope variable $scope.tags fetching tags object created via ctrla . the service: .factory('myservice', function($http, $q, $window) { var myservicefactory = {}; var savedtags = {}; // ..other methods.. myservicefactory.savetags = function(tags) { if(!savedtags.tags){ console.log('saving tags..'); savedtags.tags = tags; } }; myservicefactory.getsavedtags = function() { console.log('returning tags..'); return savedtags.tags; }; return myservicefactory; }) this issue appears ctrlb gets called first, when $scope.savedtags = myservice.getsavedtags(); runs, returns undefined. question: angular n00b here - best way fetch tags after ctrla has populated object? you can u

dplyr - R: Merge tables and fill empty cells with factor information -

i have relatively complex table merge/expansion problem. below have included example data , desired result tables. have 4 factors ( site , date , sample , taxa ) , 3 numeric columns ( 1 , 2 , 3 ). need have each site , date , , sample have taxa 1, 2, 100, , 150. through process need fill in empty factor cells appropriate info , fill in numeric columns 0’s. i apologize large "example" data sets, capture complexity of data set. complete data set large, including 4 site , 15 date , 12 sample , , 167 taxa . solutions using dplyr preferred, open other options. doing in excel takes coon’s age! in advance. data site date sample taxa 1 2 3 nsv 8-jul-13 pool 1 10 10 10 nsv 8-jul-13 pool 2 10 10 10 nsv 8-jul-13 riffle 1 10 10 10 nsv 8-jul-13 riffle 2 10 10 10 nsv 23-oct-13 pool 1 10 10 10 nsv 23-oct-13 pool 2 10 10 10 nsv 23-oct-13 riffle 1 10 10 10 nsv 23-oct-13

Jagged Java arrays of int -

i understand x jagged array in int x[][] = {{0,1,2,3,4},{0,1,2},{0,1,2,3}}; but given array a like int a[] = {10,3,47,4,8}; is a jagged array? the overall cs answer the term "jagged" (i've seen "ragged") array refers a multi-dimension array (>1) each element array . thus int[] = {1,2,3}; is not jagged array, int[][] = {{1,2,3,4}, {5,6,7}}; is. however, counterintuitively, int[][] = {{1,2,3,4}, {5,6,7,8}}; is jagged array, though "looks even" if draw out: int[][] = { {1,2,3,4}, {5,6,7,8} }; this because other coding languages (such c#) distinguish between multi-dimensional arrays , jagged arrays. in languages, "jagged" not description of current structure of array in question, type of object entirely. see difference between 2 here the java answer unlike other languages, java allows single arrays of given type. type int[][] "an array of int[] ". java doesn't support true mu

networking - Aix equivalent of tcp_retries2 -

please me aix equivalent of tcp_retries2 parameter available linux machines. found link in https://stackoverflow.com/questions/23892502/aix-equivalent-of-the-following-linux-parameters and followed searching in http://unix.stackexchange.com , https://superuser.com/ but didn't got answer yet. thanks in advance. i don't understand difference between linux's tcp_retries1 , tcp_retries2. basic answer question rto_length option no command. no -a | grep rto rto_high = 64 rto_length = 13 rto_limit = 7 rto_low = 1 tcp_low_rto = 0 those guys want focus on (except tcp_low_rto). but, speaking of tcp_low_rto, aix has 2 methods. normal , "low rto" method has own set of no options. no -h <option> provides information on these parameters.

What are python classes? -

i'm trying learn programming , came across in core app. from django.shortcuts import render django.views.generic import templateview # create views here. class splashview(templateview): template_name = "index.html" what above class do, in context? it templateview does, plus has attribute called "template_name" value of "index.html".

Django rest framework email validation -

i want validate email id if exists in user model before registration this serializer validation class registrationserializer(serializers.serializer): username = serializers.charfield(max_length=100) email = serializers.emailfield() password = serializers.charfield(max_length=100) def validate_email(self,attrs): email=attrs['email'] print email if email: emailset = q(email__icontains=email) emailres = user.objects.filter(emailset) if emailres: msg = _('the email address taken') raise serializers.validationerror(msg) else: return attars it throwing error "typeerror:string indices must integers" email=attrs['email'] typeerror: string indices must integers i guess have upgraded or using drf 3.x, there no more attrs dic

emberfire - Namespace "Firebase" already declared -

i cannot find life why it's saying i've declared namespace twice. the error message is: uncaught error: namespace "firebase" declared. i saw people having error named app 'emberfire' or 'firebase'. named app 'nutella' don't know why it's complaining namespace. i tried searching word "firebase" , here's result: /users/sunoceansand/nutella/app/adapters/application.js: 1 import config '../config/environment'; 2: import firebase 'firebase'; 3: import firebaseadapter 'emberfire/adapters/firebase'; 4 5: export default firebaseadapter.extend({ 6: firebase: new firebase(config.firebase) 7 }); 8 /users/sunoceansand/nutella/app/initializers/session.js: 4 var session = ember.object.extend({ 5 6: addfirebasecallback: function() { 7 var session = this; 8 /users/sunoceansand/nutella/app/serializers/nutella.js: 1 import ds 'ember-data'; 2 3: export defaul

linux - ssh: connection refused on port 22 -

i have installed openssh-sever . started ssh-server using following command : :~$ sudo service ssh start ssh start/running, process 20013 with following command can see port 22 open : :~$ sudo nmap localhost -p 1-65535 starting nmap 6.40 ( http://nmap.org ) @ 2015-04-22 23:46 edt nmap scan report localhost (127.0.0.1) host (0.000013s latency). not shown: 65533 closed ports port state service 22/tcp open ssh 631/tcp open ipp nmap done: 1 ip address (1 host up) scanned in 7.24 seconds furthermore, check if port listening used following command results : :~$ sudo netstat -plunt active internet connections (only servers) proto recv-q send-q local address foreign address state pid/program name tcp 0 0 127.0.1.1:53 0.0.0.0:* listen 1061/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* listen 20013/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:*

unix - cvs delete all versions -

i have set of files in cvs each multiple versions. there no need have files , versions in cvs, space. remove files entirely cvs (all versions). noticed cvs delete file1 followed by cvs commit only removes last version of file cvs. how remove versions of file. thanks! seriously consider ramifications before doing this. use of version control supports tracking history. cannot recommend continuing course of action. removing versions of file frowned upon in sense alters history - tagged revision sets altered no longer represent saved historical state. you might know front cvs not allow removing revisions. @ least 1 revision must retained. solution follows intended cvs authors used collapse intermediate revisions between revisions single change. remaining revision(s) may cvs remove d, cannot totally removed repository without performing surgery on repository. warning: use of cvs admin -o causes sorts of problems in sandbox. not trivial avoid causing m

c - static variable used with != operator and that too not in if or any loop condition -

#include <stdio.h> int main() { static int var; var!=0; var+=1; printf("static value :%d\n",var); return 0; } in above code var!=0 do? , if returns anything, returns? var!=0 nothing, except comparison, not stored or used in other way . should if used comparison, not use result of comparison: if (var!=0) { // here }

jdbc - Python connect to Hive use pyhs2 and Kerberos authentication -

i'm connecting hive use pyhs2. hive server required kerberos authentication. knows how convert jdbc string pyhs2 parameter? like: jdbc:hive2://biclient2.server.163.org:10000/default;principal=hive/app-20.photo.163.org@hadoop.hz.netease.com?mapred.job.queue.name=default i think this: pyhs2.connect(host='biclient2.server.163.org', port=10000, authmechanism="kerberos", password="something", user='your_user@hadoop.hz.netease.com') i'm doing same, still not succeed, @ least having meaningful errorcode: (server hive/xxx@yyy.com not found in kerberos database)

Scheme code for Pollard's Rho algorithm -

i trying learn scheme implementing few algorithms. pollards-rho(n) g(x) = x2 + 1 mod n x ← 2; y ← 2; d ← 1; while d = 1: x ← g(x) y ← g(g(y)) d ← gcd(|x - y|, n) if d = n, return failure. else, return d i trying implement above algorithm in scheme. appreciated. thanks an implementation in racket: ;;; algorithm 19.8 pollard's rho method ; input n>=3 neither prime nor perfect power ; output either proper divisor of n or #f (: pollard : natural -> (u natural false)) (define (pollard n) (let ([x0 (random-natural n)]) (do ([xi x0 (remainder (+ (* xi xi) 1) n)] [yi x0 (remainder (+ (sqr (+ (* yi yi) 1)) 1) n)] [i 0 (add1 i)] [g 1 (gcd (- xi yi) n)]) [(or (< 1 g n) (> (sqrt n))) (if (< 1 g n) (cast g natural?) #f)])))

logstash - Replacing Terms with human readable names in Kibana Tables -

i have kibana table shows terms , counts against them ( example ). how apply separate mapping, exists, maps these id's onto actual human readable names? how translate{} filter in logstash? can define values in-line, or have read file.

java - How do I let a JSplitPane move smooth? -

i have simple java swing gui jsplitpane divide 2 jpanels. wonder how let move smooth, can see moving when resizing window. standard setting ugly, because jsplitpane moves if release it. spend lot of time searching that. is there function in class jsplitpane move smooth? i believe looking jsplitpane#setcontinuouslayout sets value of continuouslayout property, must true child components continuously redisplayed , laid out during user intervention. default value of property , feel dependent. , feels might not support continuous layout; ignore property.

Not able to make call using Intent Android -

i trying make call using intent, if try run code linux eclipse working fine, on windows eclipse not working. here code intent intent = new intent(intent.action_dial); intent.setdata(uri.parse("tel:"+"1234567890")); intent.setflags(intent.flag_activity_new_task); startactivity(intent); try use windows. may you // todo auto-generated method stub intent intent = new intent(intent.action_dial); intent.setdata(uri.parse("tel:" + uri.encode("your number here"))); intent.setflags(intent.flag_activity_new_task); startactivity(intent);

java - How to determine if a TreeItem is a leaf or not -

i have jface treeviewer wherein user can select treeitem , check whether ist leaf node or not through menu option. how achieve this? you can selected object tree viewer with: istructuredselection selection = (istructuredselection)viewer.getselection(); object selected = selection.getfirstelement(); where 'viewer' treeviewer selected model object returned content provider. you can use content provider test if has children with: itreecontentprovider provider = (itreecontentprovider)viewer.getcontentprovider(); boolean haschildren = provider.haschildren(selected);

Python script not calling main function, says process finished with exit code 0 -

im using pycharm , says process finished exit code 0 without restaurant_list or after it def main(): # make list of resturaunts resturaunteur go restaurants_list = ['mcdonalds', 'burgerking', 'wendys', 'panerabread'] print(restaurants_list) # remove expensive resturaunt list print('here restaurants in list') print(restaurants_list) # restaurant change restaurant = input('which restaurant remove?') # remove restauraunt restaurants_list.remove(restaurant) #display list print('here revised list') print(restaurants_list) if __name__ == "__main__": main() you need add following @ end of file: if __name__ == "__main__": main() ... call main function. make sure pycharm configured run right script.

conditional - Conditionally load different Javascript for different domains on mouse click -

i working on website have lot of external links different websites amazon.in, flipkart.com, snapdeal.com etc. lets have 3 different javascript files amazon.js snapdeal.js flipkart.js restall.js i want when user clicks on link amazon.in base url amazon.js should load. same others , don't want load js file if base url doesn't match in these three. -ravi

reporting services - how to view TFS API report data in share point project portal -

i using tfs apis through c# application create customised tfs reports , charts. connecting data source , creating data set programatically. want know there way upload these report on share point server or project portal page? or type of report should create using tfs apis can uploaded on share point poject portal.

.htaccess - rewrite url from example.com?prodid=qwerty to exmaple.com/abc.php?prodid=qwerty -

i want redirect from http://www.example.com/partnerlogin?authid=abcde79989#$@hk to http://www.example.com/partnerlogin.php?authid=abcde79989#$@hk rewriteengine on rewritecond %{query_string} ^partnerlogin?authid=$ [nc] rewriterule ^partnerlogin?authid=$ partnerlogin.php?authid= [nc,l] i writing above in .htaccess not working, result getting is: the requested url example.com/partnerlogin not found. rewritecond %{query_string} ^partnerlogin?authid=$ [nc] rewriterule ^partnerlogin?authid=$ partnerlogin.php?authid= [nc,l] partnerlogin not part of query_string , authid not part of url-path matched rewriterule pattern. query string not end ( $ ) after authid= . try following instead: rewriteengine on rewritecond %{query_string} ^authid= rewriterule ^partnerlogin$ partnerlogin.php [l] the query string (ie. authid=abcde79989 ) automatically copied across substitution url. i've removed nc flags. unless need case-insensitive match, these not

android - Dagger2 multi-module design -

for dagger2 release , plan split module few small module re-use on other projects. application module contains many things, can group 3 type. type related, type b related, type c related. so want put 3 different module , therefore can re-use part of if need on other projects. reference google's fork build.gradle application buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' // note: not place application dependencies here; belong // in individual module build.gradle files } } allprojects { repositories { mavencentral() } } build.gradle app module apply plugin: 'com.neenbedankt.android-apt' //below lines go dependenc compile 'com.google.dagger:dagger:2.0' apt 'com.google.dagger:dagger-compiler:2.0' provided 'org.glassfish:javax.annotation:10.0-b28' after above st

java - Storing an image in postgresql -

i'm trying store image in postgresql database, have procedure used store image in database, image column type bytea.i tried convert image string(base64) , converted byte[], not able update image. code read image , convert string this:- file file = new file("filepath\\image.jpg"); try { // reading image file file system fileinputstream imageinfile = new fileinputstream(file); byte imagedata[] = new byte[(int) file.length()]; imageinfile.read(imagedata); // converting image byte array base64 string calling encodeimage function byte[] imagedatastring = encodeimage(imagedata); callablestatement statement = con.preparecall(" { call products_update_image( '" + id + "', '" + imagedatastring + "') } "); statement.execute(); } catch (exception ex) { system.out.println("exception is:- " + ex); } public static byte[] encodeimage(byte[] imagebytearray) { retu

javascript - Safari ignores css dir="ltr" after switcing css files -

i added english website support 2 languages. on first language, use css file rtl. now, when switch english, remove rtl css file , add css file dir ltr. on chrome, ir , firefox works fine. on safari (i tried mobile safari) partaily ignores ltr. can see here: http://parkplanner.co.il/ , use 'english' button on menu change language. this ltr css file - http://parkplanner.co.il/css/ltr-adj.css thanks! use direction:ltr; not dir attribute

When to deregister a java/android object from another -

in oo think not uncommon object register object (perhaps singleton) callbacks. in c++ think not uncommon registration in constructor or super class constructor of object being registered , deregistration destructor. gives assurances right timing. i have 2 questions. best strategy achieve in java in general, given lack of destructor? in android, if object member of activity or fragment, guess object should registered , deregistered within 2 of on... methods in activity or fragment. think may hard know when object destroyed. 2 on... methods in activity or in fragment best use this? additionally, perhaps less common, if object referenced number of other objects can 1 decide deregister on basis going out of scope , how or can 1 deregister based on other state implies on balance happy no longer receive call backs?

android - Volley, Webservices and login -

i'm trying communicate api volley. ideally, able use dataaccesslayer this: dal.addtransaction(value, description); the main problem is, before doing call api, must login. login request return me access token, have integrated in other call. i thinking doing login in dal constructor, in fact, since requests made asynchronously, addtransaction request refused if reaches api before login request. do have clue how develop kind of data access layer without dirty coding? i have been trying play listeners, it's far less easy javascript's callbacks function. thanks in advance.

JavaScript retrieving element's CSS values -

i'm making basic drag , drop system , need retrieve top , left properties of element being moved. if this: var mover = document.getelementbyid('mover'); alert(mover.style.top); will alert nothing ( ' ' ) is there way of retrieving css values (in js) without having define them js first? you need use getcomputedstyle if wish retrieve properties computed rather defined. https://developer.mozilla.org/en-us/docs/web/api/window/getcomputedstyle from mdn link... <script> function getthestyle(){ var elem = document.getelementbyid("elem-container"); var thecssprop = window.getcomputedstyle(elem,null).getpropertyvalue("height"); document.getelementbyid("output").innerhtml = thecssprop; } getthestyle(); </script>

c# - Sum values in datatable using linq based on conditions -

i'm having datatable mentioned below. id percentage 1 50 1 30 2 0 2 100 result: id percentage 1 80 2 100 i tried , doesn't work var n = dt.asenumerable() .where(r => (int)r["id"] != "0" || (int)r["id"] != "100") .sum(r => (int)r["percentage"]); i'm new linq , pls provide suggestions. now need sum percentage each id , percentage each id should 0 or 100 percentage. if 1 of id in table doesn't have 0 or 100 need alert. pls suggest me how can in linq , think best way. var result = row in dt.asenumerable() group row row["id"] g select new { id = g.key, sum = g.sum(x => int.parse(x["percentage"].tostring())) }; var erroritems = result.where(x => x.sum != 100 && x.sum != 0); if (erroritems.any())

phonegap plugins - What's the most popular method for Cordova/Ionic push notification? -

i'm new guy in hybrid mobile development , want know popular methods cordova/ionic push notification(not local notification)? does know has guidelines or tutorial field? thanks in advance! this tutorial still works fine: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 here have german one: http://www.cordova-forum.de/index.php/thread/99-cordova-push-notification-tutorial-ios-phonegap/ you need plugin that: cordova pushplugin and here finaly tutorial android: http://apigee.com/docs/app-services/content/tutorial-push-notifications-sample-app

arrays - How to split string by character with exceptions (Java) -

i want process csv file. there problems processing it: i need split lines every ; i'd use .split method btu in case there exceptions: a line can have empty "cells" x;y;z;;a;;;b still need empty ones in array. example array[0] = "x"; array[1] = "y"; array[2] = "z"; array[3] = ""; and on. exception is: there 1 cell contains html code (which has ";" in it). string shouldn't split if ; between "". there way handle this? parsing data of form common problem, , has been solved csv parsers. use apache commons csv , change delimiter ; instead of default , .

javascript - How can I create a "view to desktop version" link on mobile site without it looping back to mobile version when it resolves? -

i've created separate mobile skin website. site serves mobile version of page based on screen size of device being viewed on using following code. <script type="text/javascript"> if (screen.width <= 600) { window.location = "mobile/"; } </script> i'd add "view desktop version" link @ bottom of page. naturally, above code in header of each page, detects screen size again , loops back. could please suggest how around this. suspect session or cookie i'm new java , don't know how set these up. thanks in advance advice. this should handled viewport in metatag of website. use of jquery can allow users opt out of responsive design: var targetwidth = 980; $('#view-full').bind('click', function(){ $('meta[name="viewport"]').attr('content', 'width=' + targetwidth); }); see this link more clarification.

javascript - Copy rich text format string as formatted text -

i have rtf string coppied clipboard ( c#/javascript code ). user should able copy text outlook. should nice looking , user friendly formatted text , not actual rtf string. how 'convert' string nice formatted text ? ( in case outlook rich text editor, takes string plain text ) you need make sure use right parameters when add rtf data clipboard. here c# code tested wark copying formatted text richttextbox wordpad: clipboard.setdata(dataformats.rtf, (object)richtextbox1.rtf); if rtf text in clipboard in wrong, plain-text format, retrieve , put correctly: string temp = clipboard.getdata(dataformats.text).tostring(); clipboard.setdata(dataformats.rtf, (object)temp);

html - jQuery Mobile - Persistent Toolbars with backbutton -

Image
edit fiddle of problem: https://jsfiddle.net/9k449qs2/ - debug fiddle , try select header picker. not able so, select whole page every time click. i'm working on project has persistent header , footer. content changes clicking through application. wanted add backbutton header did with: <header id="headermain" data-position="fixed" data-role="header"> <a href="#" data-rel="back"> <div class="backbutton">go back</div> </a> </header> the rest of code directly after header looks this: <div data-role="page" id="pagemain"> <div class="content gray"> <a href="#checkconnection">adfjsöalfjasödf</a> </div> </div><!-- pagemain end --> <footer id="footermain" data-position="fixed" data-role="footer"> footer </footer> <d