Posts

Showing posts from March, 2013

java - get src attribute inside div tag jsoup -

i trying parse html getting nullpointor. want extract image uri below html. string html = "<div class=\"thumb-box thumb-160\"><a class=\"mimg\" data-id=\"1394085169856_6744\" href=\"#\"><img class=\"thumb\" src=\"http://i.ytimg.com/vi/u7declndzqw/hqdefault.jpg\" style=\"top: -15px;\"><span class=\"btn\"></span></a></div>"; document document = jsoup.parse(html); element element = document.select("div.thumb-box thumb-160").first(); system.out.println(element.select("img").attr("src")); element element = document.select("div.thumb-box thumb-160").first(); you have use . (dot) every class element element = document.select("div.thumb-box.thumb-160").first(); besides rather straight forward select this element element = document.select("div.thumb-box.thumb-160:eq(0) a").first(

asp.net - Error when uploading file? -

i have asp.net application hosted on brinkster . running smoothly before, 1 day got error when opening connection ms access database . tried impersonate = "false" in web config . , problem resolved new problem started. not able upload image in folder in application. if remove impersonate= "false" or add impersonate="true" giving previous error on opening connection. asp.net user has full permission. do has idea? it related permission of folder uploading. need give permission of application pool identity user. change application pool of iis network service. resolve error. if don't have rights change application pool rights. try thing below. <identity impersonate="true" username="network service"/>

java - Print out customer name, id, balance -

i writing java program need: a method read customer names , id , store them in array. (read sequence of 0 or more lines each containing name , id of 1 customer. instantiate 1 customer object per line , store each object in array of objects. array need not more 10 elements long. sequence of name , id end empty line). main import java.util.scanner; public class customertest { public static void main(string[] args) { customer[] customers = new customer[10]; scanner myscanner = new scanner(system.in); int numitem; readcustomer(myscanner, customers); //not sure calling readnameamount(myscanner, customers); ////not sure calling } public static void readcustomer(scanner myscanner, customer[] input) { boolean streamended = false; int numitem = 0; while (!streamended && myscanner.hasnext()) { string name = myscanner.nextline(); string id = myscanner.nextline(); i

java - Why does my code print [I@87816d when i run this code? -

this question has answer here: java arrays printing out weird numbers, , text [duplicate] 10 answers /* * given array of positive ints, return new array of length "count" containing * first numbers * original array. original array contain @ least "count" numbers. */ public class stringex { public static void main(string[] args) { int[] nums = {2,3,5,6,8}; int count = 2; stringex s1 = new stringex(); system.out.println(s1.copyevens(nums, count)); } public int[] copyevens(int[] nums, int count) { int[] n=new int[count]; int c=0; for(int i=0;i<nums.length;i++) { if(nums[i]%2==0&&c!=count) { n[c]=nums[i]; c++; } } return n; } } // output:[i@87816d ar

c# - Load .txt data files to DataGridView -

Image
i have code open point file , read data files: private void cmdload_click(object sender, eventargs e) { stream mystream = null; openfiledialog openfiledialog1 = new openfiledialog(); openfiledialog1.initialdirectory = "\\yamaha"; openfiledialog1.filterindex = 2; openfiledialog1.restoredirectory = true; if (openfiledialog1.showdialog() == dialogresult.ok) { try { if ((mystream = openfiledialog1.openfile()) != null) { using (mystream) { string filename = openfiledialog1.filename; using (var reader = file.opentext(@filename)) { string line; while ((line = reader.readline()) != null) { //do fetch data , paste gridview operation } } } } }

chef - Error with running mysql cookbook on Fedora -

i trying run openstack-chef-cookbooks ( https://github.com/stackforge/openstack-chef-repo ) on fedora 19. when run chef-client, here error getting: recipe: openstack-ops-database::mysql-server * mysql_database[flush privileges] action query ================================================================================ error executing action `query` on resource 'mysql_database[flush privileges]' ================================================================================ mysql::error ------------ access denied user 'root'@'localhost' (using password: yes) cookbook trace: --------------- /var/chef/cache/cookbooks/database/libraries/provider_database_mysql.rb:83:in `new' /var/chef/cache/cookbooks/database/libraries/provider_database_mysql.rb:83:in `db' /var/chef/cache/cookbooks/database/libraries/provider_database_mysql.rb:78:in `exists?' /var/chef/cache/cookbooks/database/libraries/provider_database_mysql.rb:64:in `action_query'

asp.net - How to get the Filename in code behind on selecting a file, before uploading it to the server using aspx and CS? -

i want retrieve file name , perform validation on filename. before uploading have filename of file selected uploading. actually wanted filename , retrieve fields database based on file chosen , , send data retrieved database on client side in textfield. before on click of upload need call method in code behind validate these things. tried using ajaxcontroltoolkit, not working. use getfilename() method. below example msdn link. string filename = @"c:\mydir\myfile.ext"; string path = @"c:\mydir\"; string result; result = path.getfilename(filename); console.writeline("getfilename('{0}') returns '{1}'", filename, result); result = path.getfilename(path); console.writeline("getfilename('{0}') returns '{1}'", path, result); // code produces output similar following: // // getfilename('c:\mydir\myfile.ext') returns 'myfile.ext' // getfilename('c:\mydir\') returns &

Firefox ToolBar Button When Click Changes DOM? -

new firefox development , trying best figure out. say want call function in tap_browser.js modify dom when user clicks on toolbar widget, how this? this code have far require("toolbarwidget").toolbarwidget({ toolbarid: "nav-bar", // <-- place widget on navigation bar id: "tap-icon", label: "tap", contenturl: data.url("favicon.png"), contentscriptfile: [data.url("tap_browser.js")] }); i'm using library create toolbar widget here: https://github.com/rob--w/toolbarwidget-jplib i don't know sdk helped does. check out: var my_wid = widgets.widget({ id: "my-widget", label: "cliiiick", content: "click me", width: 100, onclick: function() { require('sdk/window/utils').getmostrecentbrowserwindow().gbrowser.contentdocument.documentelement.innerhtml = 'hi'; } }); what shows panel 0 width , height, can put stuff in the

javascript - Flexslider DISABLE full-width display, auto adjusting -

i've installed blog template includes slider. template comes from: sight-soratemplates.blogspot.com as can see slider, images full page width, images replace them half width, instead of displaying image is, repeats them cover entire width of page . how can change this? i'm complete beginner @ html coding. slider adapt automatically each image. the html code slider, along 1 image is: <b:if cond='data:blog.pagetype == &quot;index&quot;'> <div class='slider' style='overflow:hidden;'> <div class='fullwidth flexslider' id='homeslider'> <ul class='slides'> <li data-height='500' style='position:relative; background: url(http://x.jpg) 50% 0'> <div class='caption_wrapper'> <div class='caption'> <h3><a href='#'>random title

osx - Execute command in script based on year -

i have powerbook dead laptop battery... everytime disconnect it's power source date gets set year 1969. leads issues network authentication, keychain access, etc. wrote launch daemon executes script in order set date more appropriate @ boot, works fantastically. #!/bin/bash date 0101122014 now want run if year 1969, way if time correct won't set @ all. so like... #!/bin/bash year="date +%y" if [ $year = 1969 ] ; date 010112002014 else exit 0 fi i know syntax totally off, it's give idea of want do. in advance. use command substitution : year=$(date +%y) or even: [ $(date +%y) = 1969 ] && date 010112002014 or, using if : if [ $(date +%y) = 1969 ] date 010112002014 fi

How does Java calculate length of primitive array? -

this question has answer here: where array's length property defined? 6 answers code: char[] chars = "abcd".tochararray(); system.out.println(chars.length); question: how length calculate java here? since char not class, not sure length stored. if isn't stored, calculated every time chars.length? (i presume not) the thing wrote char[] object, array, , has public final field called length . calculated once when array in created. objects has tostring(), notify() , etc...

convert Date to a quarter of an hour type JAVA -

this question has answer here: java date rounding 6 answers i looking way convert datatype date [java] to quarter of hour format, 2010-08-15 12:05:15 2010-08-15 12:00:00 are there ready go methods in java already? how this? any hints/suggestions? up release version 7, java comes terrible date , time api. many developers therefore choose use joda time instead. common third-party dependency in many projects. using joda time, can following: date toquaterofhour(date date) { localdatetime ldt = new localdatetime(date.gettime()); int quater = ldt.getminuteofhour() / 15; return ldt.withminuteofhour(quater * 15).todate(); } java 8 comes date , time api similar of joda time.

c# - Button that expands ComboBox causing infinite loop -

i have button on top of combobox, received element other developer , cannot change drastically. need happen when hover on button combobox open, when leave close. when click button trigger function. problem when hover on button combobox focus , stuck in infinite loop of open close (maybe there else wrong). not work. <grid margin="10,0,10,0" grid.column="1"> <grid.columndefinitions> <columndefinition width="85*"/> <columndefinition width="15*"/> </grid.columndefinitions> <combobox height="30" name="combo2" style="{staticresource categorycombobox}" selectionchanged="combobox_selectionchanged2" grid.columnspan="2" grid.column="0"> <comboboxitem content="combobox item 1 (example)" /> <comboboxitem content="combobox item 2 (example)" />

Customize Emacs for Mac OSX app -

i using emacs mac osx app, , need modify init.el file, according instructions on melpa . problem can't find init.el file. there 1 in obscure location, or there other file serving same purpose? goal make melpa packages available emacs 24 package installer. ==== update ==== to add melpa repository, 1 should add few lines " before call package-initialize in init.el file", according melpa page. emacs osx app doesn't seem have init.el file, though. using command (suggested @alexander-poslavsky) c-h (control-h) v user-init-file ret i "~/.emacs", predicted @abo-abo. however, file doesn't exist, there no call package-initialize. anyway, created ~/.emacs , added custom lines it, suggested @abo-abo, , works. thanks! these contents of .emacs file: (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) emacs osx uses 'normal' configuration setup (unl

java - How to wget from URL that needs a key press -

i trying download url: http://www.histdata.com/download-free-forex-historical-data/?/ascii/1-minute-bar-quotes/eurusd/2014/2 with bash wget . but, need manually press link right of "download historical data here" is there way in code command line? edit 1 or java great too. i think need write code accomplish this, using html client library supports javascript, such phantomjs , mentioned answers this question . other options include python's mechanize library, , of things mentioned in this answer . if you're looking headless browsing library in java , take @ htmlunit . have not used though, can't vouch stability or ease or use.

mysql 3.23 select from one table if value do not exist in table 2 or if exist and date>datenow select it also -

make query in mysql 3.23 select 1 table if value not exist in table 2 or if exist , date>now date(in table 2 exist field date when added) select also. i make in mysql 5.22.25 thik (i deleted it), istalled mysql 3.23 , query not work. is possible problem in .dll (conectors) i use select * x ... , ... not in (select ........) mysql error in "in (select ........)" . can use in in mysql 3.23?

python - django model instance edit -

i have 3 models set follows: #models.py class room(models.model): room_number = models.charfield(max_length=20, primary_key=true, null=false, blank=false) isolation_status = models.booleanfield() class treatment(models.model): room_number = models.foreignkey(room, primary_key=true) treated = models.booleanfield() class isolation(models.model): room_number = models.foreignkey(room, primary_key=true) what need when create new treatment object set room.isolation_status field false. #views.py class addtxview(formview): template_name = 'addtx.html' form_class = txform success_url = '/rooms/addtx/' def update_iso(self, form): instance = room.objects.get(room_number=room_number) instance.isolation_status = false def form_valid(self, form): save_it = form.save(commit=false) save_it.save() return super(addtxview, self).form_valid(form) #forms.py class txform(forms.modelform): class meta: model = trea

gitlab - nginx runs an subdomain to a new app with an existing website -

my server has ror app running on nginx @ port 80 , want set gitlab in same server, now, have access gitlab myserver:1987/ if want access gitlab myserver/gitlab how achieve ? nginx.conf http{ include /opt/nginx/sites-enabled/*; } ... server { listen 80; server_name localhost; passenger_enabled on; #charset koi8-r; #access_log logs/host.access.log main; location / { index index.html index.htm; root /home/poc/projects/zeus/public; passenger_enabled on; } sites-enabled/gitlab.conf # gitlab # maintainer: @randx # chunked transfer # known issue git-over-http requires chunked transfer encoding [0] not # supported nginx < 1.3.9 [1]. result, pushing large object git (i.e. single large file) # can lead 411 error. in theory can around tweaking configuration file , either # - installing old version of nginx chunkin module [2] compiled in, or # - using newer version of nginx. # # @ time of writing not know if either of these theoretical solutions wo

parallel processing - C++ AMP nested loop -

i'm working on project requires massive parallel computing. however, tricky problem that, project contains nested loop, this: for(int i=0; i<19; ++i){ for(int j=0; j<57; ++j){ //the computing section } } to achieve highest gain, need parallelise 2 levels of loops. this: parallel_for_each{ parallel_for_each{ //computing section } } i tested , found amp doesn't support nested loops. have idea on problem? thanks you could, @high performance mark suggest collapse 2 loops one. however, don't need c++ amp because supports 2 , 3 dimensional extent s on array s , array_view s. can use index multi-dimensional index. array<float, 2> x(19,57); parallel_for_each(x.extent, [=](index<2> idx) restrict(amp) { x[idx] = func(x[idx]); }); float func(const float v) restrict(amp) { return v * v; } you can access individual sub-indeces in idx using: int row = idx[0]; int col = idx[1]; you should consider amoun

Websphere Application startup error -

i using websphere 7 , getting error while trying start application. 00000018 servlet e com.ibm.ws.webcontainer.servlet.servletwrapper init srve0100e: uncaught init() exception created servlet application initialization servlet in application xxx-portal: java.lang.nullpointerexception @ com.xyz.zyx.web.init.applicationinitservlet.init(applicationinitservlet.java:75) and code : final properties props = init.initialize(url, getservletcontext().getrealpath("/web-inf/classes")); don't know happened of sudden..something have change in server parameters since cannot change code. the solution simple: go installed applicaton > class loader , update detection > under war class loader policy, select 'single class loader' now application start. found after long struggle .

ruby on rails - unable to sign up with json devise -

i have problem devise registration using /users/sign_up. have pass registration details via rails terminal using curl this: curl: //your-domain:3000/users/sign_up --data "email=jump@gmail.com&password=123456789&password_confirmation=123456789" and should return: {"success":true,"info":"registered","email":"jump@example.com","auth_token":"n8n5mpqfnddz3g1jrsc9"} but getting below error message: actioncontroller::routingerror (no route matches [post] "/users/sign_up"): while users/sign_in working perfectly: curl: //your-domain:3000/users/sign_in.json --data "email=abc@gmail.com&password=123456789" return: {"success":true,"info":"logged in","auth_token":"czzbpins7mkkqjabhymo","email":"abc@gmail.com"} below registrationscontroller class: class registrationscontroller < devise::reg

java - Android - client causing "Connection reset by peer" exception -

i know, whether there possibility implementation of client side, causing ioexception? far know, exception caused remote site, sending rst packet, shutting down connection. whatever answers have come far, claim server's fault. but problem following. communicating server via tcp sockets , android app client. communication used work prefectly, after making modifications (to client side only), keep getting exception. i having hard time pinpointing source of problem, because updates i've made had nothing communication implementation. i've added query server handle. is possible produce exception client side(that code, cause remote side produce outcome)? perhaps overloading server requests? or maybe android closing sockets, itself? or perhaps somehow closing sockets, produce different type of exception. any advice on matter appreciated. as turns out, problem wasn't in client implementation afterall. server ending connection, after query had been executed.

winapi - How to identify inside screen resolution the multiple display that is enabled? -

i've searched on google found no answer, if knows thankful! i want use command line or winapi check state of multiple display. example : if set : "extended screen" or "duplicate screen" want able verify it. have no idea start. thanks lot i start winapi enumdisplaymonitors function: http://msdn.microsoft.com/en-us/library/dd162610%28vs.85%29.aspx bool enumdisplaymonitors( _in_ hdc hdc, _in_ lpcrect lprcclip, _in_ monitorenumproc lpfnenum, _in_ lparam dwdata ); you need call function setting first 2 parameters null this: enumdisplaymonitors(null, null, mypaintenumproc, 0); //enumerates display monitors. //the callback function receives null hdc. now have monitorenumproc callback function: http://msdn.microsoft.com/en-us/library/dd145061%28v=vs.85%29.aspx bool callback monitorenumproc( _in_ hmonitor hmonitor, _in_ hdc hdcmonitor, _in_ lprect lprcmonitor, _in_ lparam dwdata ); you wiil filled lprcmonitor back:

oracle - Pro-rata volumes between a start time and an end time -

simplified, have table so: start_date end_date units 06/03/2014 14:00:00 06/03/2014 15:30:00 300 what want , have been trying find out duration (end_date - start_date). split half hour intervals , divide units equally between these intervals. in case, duration 90 minutes, 3 half hour intervals, meaning 100 units in each interval. from want create along these lines: interval_date units 06/03/2014 14:00:00 100 06/03/2014 14:30:00 100 06/03/2014 15:00:00 100 i have got work, involved numerous nesting of sub-queries (probably clean bit use less). involved hard-coding columns interval, rather 1 column hold different intervals. example, looked this: id d0000 ... d1400 d1430 d1500 d1530 d1600 ... d2330 1 0 100 100 100 0 0 0 and reason wasn't flexible in case wanted change interval duration (15 mins, 1 hour etc). any ideas or appreciated. this solution covers any amount of rows (other

sqlite3 - compileStatement or db.insert in android -

i want insert records table multiple number of times, have choice either use compilestatement or use db.insert shown below. string tablename = "table"; //fields in table: id, name sqlitestatement statement = db.compilestatement("insert "+tablename+" values(?,?);"); statement.bindlong(1,666); statement.bindstring(2,"john"); statement.executeinsert(); or string tablename = "table"; contentvalues values = new contentvalues(); values.put("id", 666); values.put("name", "john"); db.insert(tablename, null, values); which 1 should optimal? edit:- application running single threaded. insert() compiles sql on each invocation while compilestatement() approach compiles sql once. when same sql different bind arguments used more once, compilestatement() approach less work , faster. in addition, consider wrapping inserts in transaction reduce time spent waiting on i/o.

ios - Usage of rtmp-dump/librtmp -

i using compiled version of rtmp-dump github in ios project. following code connect server. rtmp = rtmp_alloc(); rtmp_init(rtmp); nsstring *url = @"rtmp://192.168.0.119:1935/red5/sw231/"; char *strurl = (char *)[url cstringusingencoding:nsasciistringencoding]; rtmp_setupurl(rtmp, strurl); rtmp_connect(rtmp, null); since proper documentation of rtmp-dump or lib-rtmp not available want know methods can use following functionalities. i want send array of values while connecting. query method of rtmp-dump can send values server when connecting? how can call methods of server , pass parameters server? how can receive response server? how can implement client-side method invocation through rtmp-dump ? how can explicitly provide name of stream want play or listen after connecting? by using rtmp_close() , able disconnect connection? i know post asked 12 months ago may usefull. download this , see examples of usage of librtmp. don't know why library

jquery - how to disable html body on pop-up and close pop-up on document click -

on bootstrap html page using modal pop-up fade-in , fade-out(j-query functions) of div. (i tried using bootstrap modal pop-over,but error shown, stating 'popover function not known'.) pop-up contains registration form.pop-up works fine,there no close button within pop-up,so want pop-up closed when user clicks anywhere within body except pop-up area,also want disable html body when pop-up shown. at present pop-up closed if click anywhere within html body(that includes pop-up area also!!!) in short,what need is: (1) pop-up shouldn't closed when clicked within pop-up area (2) when pop-up shown user shouldn't access link or text-box in html-body(i have got no idea how this!!) html: <div class="form-group row "> <section class="col-lg-6 col-md-6 col-xs-6"> <label for="firstname ">first name</label> <input type="text" class="form-control create

Android: Error in functional testing -

i have android tab layout swipeable views. the file structure follows: there activity class: tabmainactivity.java , under activity, there fragment class named booklockerfragment.java .this fragment class linked xml file contains various buttons. code follows, public class booklockerfragment extends fragment { button btnsis; public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { rootview = inflater.inflate(r.layout.fragment_booklocker, container, false); btnsis = (button) rootview.findviewbyid(r.id.btnsis); } ....... } i wrote code test functionality whether can launch next activity( populatelockerlist.java ) when click button , manually tested , works however, error: junit.framework.assertionfailederror when run junit test. below test code: package com.example.mobilelog6.test; public class booklockerfragmenttest extends activityinstrumentationtestcase2<tabmainactivity>{ private static final string

javascript - Manipulate object's property while in event handler -

i've learned scope reasons this keyword inside event listener, embedded in object, doesn't refer global object rather element triggered event. now, understand if want fetch property can save variable before event handler called. can if want manipulate property's value? in following piece of code trying manipulate drugcount property within removedrug event listener. var drugs = { drugs: $("#drugs_table"), drugrow: $("#drug").html(), drugcount: 0, init: function() { this.adddrugrow(); this.removedrugrowhandler(); }, adddrugrow: function() { this.drugcount++; this.drugs.append(this.drugrow.replace(/{{id}}/,this.drugcount)); $(".drugsselect").select2(); }, removedrugrowhandler: function() { drugcount = this.drugcount; // problematic solution, because retains inital drugcount. // i.e need way access "live" count within event $(document).on

OCaml Interpreter: Why my interpreter just execute only one line in my file -

i'm writing interpreter, using ocamlyacc , ocamllex compile parser , lexer. my problem that, have file calles test, contain 2 commands defined in lexer: print print b but interpreter execute line print a only! know problem in main in parser, need recursed. fixed (code below) still doesn't work. %{ open path %} %token <int> int %token <string> string %token eol %token eof %token get_line %token print %start main %type <path.term> main %% main: | expr eol {$1} | expr eof {$1} ; str: | string { $1 } ; intger: | int {$1 } ; expr: | print str { print $2 } | print str expr { print $2 } | get_line int str { print_line_in_file ($2, $3) } | get_line int str expr { print_line_in_file ($2, $3) } ; edit this lexer, tried simplify as possible spot error. (* file lexer.mll *) { open parser } rule main = parse | [' ''\t''\n'] { main lexbuf } | &

bit manipulation - C++ Points of Vertices in Cuboid (Bitwise AND) -

Image
i'm trying calculate points in cuboid given centre (which vector3) , lengths of sides along x, y , z axis. found following on math.stackexchange.com: https://math.stackexchange.com/questions/107778/simplest-equation-for-drawing-a-cube-based-on-its-center-and-or-other-vertices says can use following formulae: constructor world class is: world::world(vector3 o, float d1, float d2, float d3) : origin(o) { // if consider edge length d, need find r such // 2r = d in order calculate positions of each vertex in world. float r1 = d1 / 2, r2 = d2 / 2, r3 = d3 / 2; (int = 0; < 8; i++) { /* sets vertices of cube. * * @see http://bit.ly/1cc2rpg */ float x = o.getx() + (std::pow(-1, i&1) * r1), y = o.gety() + (std::pow(-1, i&2) * r2), z = o.getz() + (std::pow(-1, i&4) * r3); points[i] = vector3(x, y, z); std::cout << points[i] << "\n"; } } and passing following parameter

JQuery Datepicker Custom CSS -

i have got following code: <script> function reserveddates(date) { var reserved = ["2014-03-03","2014-03-04","2014-03-05","2014-03-06","2014-03-07","2014-03-08","2014-03-17","2014-03-18","2014-03-19","2014-03-20","2014-03-21","2014-03-22",]; var checkoutdates = ["2014-03-09","2014-03-23",]; var string = jquery.datepicker.formatdate('yy-mm-dd', date); return [ reserved.indexof(string) == -1 ]; } $.datepicker.setdefaults($.datepicker.regional['nl']); $(function() { $( "#startdate, #enddate" ).datepicker({ beforeshowday: reserveddates, mindate: 0 }); }); </script> which works great, can see, got second array named checkoutdates change css of cells not disable them. have no idea how this. i looked @

python - Error says Unexpected Character, while back referencing in conditional regular expression -

purpose match pattern "abc" or "<abc>" not "<abc" or "abc>" . closing angle braces @ end should matched if opening angle braces exist. logic thought work following (<)?(abc)(?(\1))> i'm trying use referencing , conditionals available. error says unexpected character @ second question mark "?" in regular expression. incase needed i'm trying on python. the syntax conditionals different, try this: (<)?(abc)(?(1)>|) this means: if (1) (if group 1 matched), match > , otherwise ( | ), match nothing. if want prevent match of abc> , need negative lookahead: (<)?(abc)(?(1)>|(?!>)) but considered more complex simpler <abc>|(?<!<)abc(?!>) regex posted donal.

authentication - Spring security : auto login issue -

i trying auto login user after signup. here code auto login private boolean autologin(httpservletrequest request, user user) { simplegrantedauthority auth = new simplegrantedauthority("admin"); collection<simplegrantedauthority> authorities = new hashset<simplegrantedauthority>(); authorities.add(auth); usernamepasswordauthenticationtoken token = new usernamepasswordauthenticationtoken( user.getemail(), user.getpassword(), authorities); token.setdetails(new webauthenticationdetails(request)); authenticationmanager.authenticate(token); securitycontextholder.getcontext().setauthentication(token); return true; } and inside interceptor check logged in user code is object principal = securitycontextholder.getcontext().getauthentication().getprincipal(); problem when debug code (after auto login) principal object has logged in user's email address instead of userdetails object. things working fine when lo

Graphhopper: edit motorway speed online -

i'm trying edit motorway speed user's preferences , return route result of change. have input field labeled 'motorway' on webpage's form , when submitting, value change speed of motorways. i have see answer here: does graphhopper support dynamic edge weights? , know how edit edges , through java file. the plan have user preferences road speeds (for busy times), regularity of turnings , traffic lights. point in right direction appreciated by default graphhopper import process stores speed , accessibility (forward+backward) information edge. so, first step create custom flagencoder stores type of road e.g. integer somewhere in long/int flags. can use encodedvalue class this. the next step create custom weighting implementation calculates speed flag information stored. weighting called while querytime can take account user preferences, can changed per query. note: you'll need disable ch when allow changing preferences every query note: cha

Error in running python script using chef -

so, trying run simple python script using python resource of chef-cookbook. here recipe looks like: python "excute_file" cwd '/home/peeyush/' code <<-eoh python #{filename} eoh end but when run cookbook, following error: recipe: hellochef::default * python[excute_file] action run ================================================================================ error executing action `run` on resource 'python[excute_file]' ================================================================================ mixlib::shellout::shellcommandfailed ------------------------------------ expected process exit [0], received '1' ---- begin output of "python" "/tmp/chef-script20140306-18792-iqfp89" ---- stdout: stderr: file "/tmp/chef-script20140306-18792-iqfp89", line 1 python test.py ^ indentationerror: unexpected indent ---- end output of "python" "/tmp/chef-script20140306-18792-iqf

eclipse - Unable to access camera after adding plugin and feature and use permission in phonegap android project -

i trying access camera in android phone. i did steps still unable access. using latest phonegap , have installed plugins , have added permission in manifest.xml file , added features in config.xml . still stuck :( can please? following files. html <!doctype html> <html> <head> <title>capture photo</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> var picturesource; // picture source var destinationtype; // sets format of returned value // wait device api libraries load // document.addeventlistener("deviceready", ondeviceready, false); // device apis available // function ondeviceready() { alert('ondeviceready!'); alert('navigator = ' + navigat

ios - How should I handle push notifications with an app that's distributed through multiple channels? -

we have developed ios app makes use of push notifications. our client wants distribute app through own mdm server. means they'll compile , sign app , have appropriate apns certificate, include in our server-side application. far, good. now, client wants distribute app other devices aren't connected mdm server. mean different (adhoc, app store, ...) distribution channel different certificate chain. how should handle on our server side send push notifications apns? can send every push notification twice, once each certificate? need determine app installation requires device (depending on distribution channel)? this dependent on way distribute app. when distributing if application identifier same refer same app. if different install multiple times. means if have same app id in both cases enough send 1 notification no matter how distribute send notification. in case if have changed app ids yes have send multiple times. thing may change app id , introduce wildca

java - Sieve of Eratosthenes implementation not checking certain numbers -

i writing program find prime numbers using ol' sieve of eratosthenes algorithm (although twist). in order halve size of byte-array needed, don't represent numbers, , stick odd (calculating position in array integer division two). i have 1 problem, however. program doesn't seem recognize 17 or 113 prime numbers, although indeed prime numbers. here code: public class eratosthes { byte[] checklist; int range; public eratosthesconcurrent(int range) { this.range = range/2; this.checklist = new byte[this.range]; this.initallchecked(); this.findprimesseq(); this.printprimes(); } private void initallchecked(){ for(int = 1; < checklist.length; i++){ checklist[i] = 1; } } private void crossout(int i){ checklist[i/2] = 0; } private void findprimesseq(){ int curr = 3; outer: while(curr < range*2){ for(int = curr*curr; < range*

motorola droid - Android Moto G - sleep causes destroy message -

im fixing bugs when app not main active app. devices pause message, lost messages etc. these expect. thing dont on moto g device destroy message when returning app menus etc, or device put sleep. is there reason this? fixing up, seems harsh have destroy app because phone call or sleep device, not im loading complex game or anything the moto g appears have rather aggressive memory management. android has low memory killer, determines processes kill depending on device configurations. while moto g have 1gb of ram, minfree settings applied motorola seem kill apps on background. there instructions on web how address user, developer, best save state when backgrounded in onpause(). http://m.androidcentral.com/fine-tuning-minfree-settings-improving-androids-multi-tasking http://developer.android.com/reference/android/app/activity.html#processlifecycle

angularjs - Mocking service for Jasmine testing? -

i new jasmine testing , not solid picture how unittest controller. controller assignments , want test following: mock service calls. mock data in scope. test behaviour of particular method in controller. verify that: service has been invoked once. verify that: service passed correct data. i need have complete possible example how write test, , declarations use mock methods. controller method in question looks this: .controller('projectconfigurationctrl', function($scope, $routeparams, infraservice, projectconfigurationservice) { // pre-init... $scope.clickupdate = function() { if ($scope.projectdata.id === 0) { projectconfigurationservice.save(angular.tojson($scope.projectdata), function(project) { $scope.projectdata = project; $scope.newproject = false; $scope.info = "project " + project.projectname + " created successfully."; }, function() { $scope.info = "project " + $scope.proje

c# - Window 8 retrieve HTML content -

here simple function retrive html content website. people can extract data it. found window 8 have http webservice html. , found way only. if anyonehave better way please share. protected override void onnavigatedto(navigationeventargs e) { gethtml("url"); } public async void gethtml(string url) { httpwebrequest myrequest = (httpwebrequest)webrequest.create(url); webresponse myresponse = await myrequest.getresponseasync(); streamreader sr = new streamreader(myresponse.getresponsestream(), system.text.encoding.utf8); maintxtbox.text = sr.readtoend(); } since window 8 httpwebrequest have "getresponseasync" have use await. , away in async function. async function return task<> or void. , after change task<> other format confuse , messy. make return void , transfer data other global source. dont find simp