Posts

Showing posts from January, 2014

memory - Resource constrained devices -

why resource constrained devices resource constrained in context internet of things? why don't arrange more memory or processing power or battery power in it? memory , processor related hardware these days compact , cheap in case of memory too. "memory , processor related hardware these days compact , cheap in case of memory too." if buy 1 or two, yes. iot devices considered large volumes. few dollars here , there start add when buy millions of them. another issue heat. fast processor generates more heat, can real problem if they're literally inside wall.

android - Adding Multiple instance of the same fragment in back-stack, data of previous added instance persists -

i have common list fragment reuse inflating different lists. i followed answer provided @devrimtuncer this question achieve it. consider have 2 lists product , sales inflated using same list fragment. if select products navigation drawer new of list fragment data related products loaded. similarly, new instance related sales created if click sales option. consider below scenario, if select products option followed sales option, separate instances of list fragment created , currently, sales list visible. product list in stack. further, if select products option, product list popped stack. contains data related sales list(somehow arguments in list fragment related b persists). i use unique tags product , sales list fragments while inflating fragments. below method use inflating fragment. private void openlistfragment(bundle arguments, string listname) { boolean fragmentpopped = mfragmentmanager.popbackstackimmediate (listname, 0); if(!fragmentpopped

How to extract the response of youtube channel playlist and playing the videos using RTSP url in android programamtically -

hi new youtube api concept have response youtube channel correct response (www.googleapis.com/youtube/v3/playlistitems?part=snippet&maxresults=10&pagetoken=caoqaa&playlistid=uui87jbesbbhreub9uizmkkq&key=aizasybzeqaz2zifkdjatmkif57mgbwubs5plqu) response working fine cant play video please me my coding is: public class youtubeadapter extends recyclerview.adapter { list<item> feeditems; context ctx; public youtubeadapter(context context, list<item> feeditems) { this.ctx = context; this.feeditems = feeditems; } @override public videoholder oncreateviewholder(viewgroup parent, int viewtype) { view itemview = layoutinflater.from(parent.getcontext()).inflate(r.layout.activity_video_items, parent, false); return new videoholder(itemview); } @override public void onbindviewholder(final videoholder holder, final int position) { final youtubethumbnailloader.onthumbnailloadedlistener onthumbnailloadedlistener = new y

java - Saving variable through app shutdown in android -

this question has answer here: how use sharedpreferences in android store, fetch , edit values 26 answers i want save variable through application shutdown. have heard sharedpreferences, didn't understand it. isn't there easier way store 1 variable. detailed explanation great, still beginning. try saving shared preferences: sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext()); sharedpreferences.edit().putstring("key","value").apply(); for getting shared preferences value: sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext()); sharedpreferences.getstring("key",""); i hope help.

rgb - Matlab 'image processing' -

if pixel location black , white image [row, column] = find(bw2 == 1) ; want move location rgb image how remove location or put mask instead of location in rgb image. how this? have tried this [row, column] = find(bw2 == 1); rgb_image(row,column) = 1; %assign value indices found in bw image; use 1 or whatever want bw2(row,column) = nan; %or other value, next mask won't select these indices

ruby on rails - gem update --system error: no implicit conversion of nil into String -

i'm running on windows , not able update rubygems either using command gem update --system or manually installing gem. following error error: while executing gem ... (typeerror) no implicit conversion of nil string i don't have issue while installing or updating other gems far can see. this complete output when running --verbose http://pasted.co/11325f4e this bug in ruby gem installer system. patch file installer.rb : replace: if ruby_executable question << existing with: if ruby_executable question << (existing || 'an unknown executable')

php - How to send Friend Request or Like type notification using Laravel -

i working on social networking site project created laravel framework. want know how can send "friend" request, "like" or "follow" kind of notification using laravel. i new framework, , appreciate guidance. not expecting source code general hints or suggestions me lot.

python - Bottle - current tab highlighting -

i want tabbed navigation site i'm building, unsure of how implement in bottle. here's direction i'm going in (from .tpl file): <li {{!'id="active"' if true else ""}}><a href="/">index</a></li> <li {{!'id="active"' if true else ""}}><a href="route1">route1</a></li> <li {{!'id="active"' if true else ""}}><a href="route2">route2</a></li> <li {{!'id="active"' if true else ""}}><a href="route3">route3</a></li> i need replace true condition compares current route string. how do that? looks need pass current route views, couldn't find concrete answers. also open better ideas. instance, saw done like this , that's in different framework. thanks.

mysql - Join two SQL Queries based on first query answer -

i have been looking everywhere , best website ask help. have make sql query checks total amount of bookings specific flight , based on number of bookings system should provide choice of aircraft. first query works , finds total number of bookings , think have case statement right choose aircraft cant find way of physically joining both queries , tried use unison , inner join , nested queries appears total number of seats booked (the answer first query ) cannot found please me guys. first sql query(find total number of bookings ) select count(bookingdetails.flightid)as totalnumberofseatsbooked,flightdetails.flightid bookingdetails, bookingdetails temp,flightdetails bookingdetails.bookingid = temp.bookingid , bookingdetails.flightid= flightdetails.flightid group flightid; second sql query(choose aircraft type depending on how many bookings made) select case chooseaircraft when totalnumberofseatsbooked <= 110 'ba 146-200' else'embraer 170' e

c++ - Use the functions of a vector objects using a pointer -

1).why did error? correct syntax? 2).is there way write same code without using library "vector"? #include <vector> myclass() { public: myclass(int x,int y); void dothis() { //something } } int main(void) { std::vector<myclass>*ex_vector = new std::vector<myclass(5,myclass{10,10}); ex_vector[0]->dothis(); //error here delete []ex_vector; } i error: error: base operand of '->' has non-pointer type 'std::vector<myclass>' the correct syntax is (*ex_vector)[0].dothis(); also, should delete ex_vector; , not delete[] ex_vector; since type of new not raw array type. however, there's reason new std::vector . use plain object.

postgresql - Java Servlets set urlPattern from database -

i have been practicing java servlets. can set urlpattern database? @webservlet(name = "patternservlet", urlpatterns = "/pattern") the following servlet creates html pages getting information postgres, content dynamic. url address remaining same each time. import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.io.ioexception; import java.io.printwriter; import java.util.list; @webservlet(name = "patternservlet", urlpatterns = "/pattern") public class patternservlet extends httpservlet { string title; string content; list<string> headeritems; protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { printwriter out = response.getwriter(); initializefields();

r - Removing elements from nested list -

i have problem i've been working on days , can't find right answer. i have list needs put mongo database. looks this: listtest = list( list(section_id = null, name = "name1", slug = "slug1"), list(section_id = null, name = 'name2', slug = 'slug2'), list(section_id = null, name = 'name3', slug = 'slug3', categories = list( list(section_id = null, name = 'name31', slug = 'slug31'), list(section_id = null, name = 'name32', slug = 'slug32', categories = list( list(section_id = null, name = 'name321', slug = 'slug321'), list(section_id = null, name = 'name322', slug = 'slug322'), list(section_id = null, name = 'name323', slug = 'slug323') )), list(section_id = null, name = 'name33', slug =

reactjs - React Native 0.43 upgrade: react@16.0.0-alpha.6 does not satisfy its siblings -

i'm trying upgrade react native project 0.38 0.43. react-native-git-upgrade did not work , tried upgrade manually. when try upgrade react @16.0.0-alpha.6, following error: $ npm install --save react@16.0.0-alpha.6 npm err! darwin 16.4.0 npm err! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--save" "react@16.0.0-alpha.6" npm err! node v4.3.0 npm err! npm v2.14.12 npm err! code epeerinvalid npm err! peerinvalid package react@16.0.0-alpha.6 not satisfy siblings' peerdependencies requirements! npm err! peerinvalid peer react-native@0.38.1 wants react@~15.4.0-rc.4 npm err! peerinvalid peer react-test-renderer@15.4.1 wants react@^15.4.1 does have pointers or suggestions me? appreciated! i had problem tonite. deleted node_modules , yarn.lock , ran fresh yarn install

xaml - How to get {x:DataType} for a DataTemplate in C# for custom DataTemplateSelector -

i'm writing custom datatemplateselector combobox control , i'll need use display different datetemplates different kind of objects, in both closed , open modes combobox . here's datatemplateselector came with: public class comboboxtypeddatatemplateselector : datatemplateselector { public ienumerable<datatemplate> selectedtemplates { get; set; } public ienumerable<datatemplate> dropdowntemplates { get; set; } protected override datatemplate selecttemplatecore(object item, dependencyobject container) { ienumerable<datatemplate> source = container.findparent<comboboxitem>() == null ? selectedtemplates // template closed mode : dropdowntemplates; // template open ui mode type type = item.gettype(); return null; // linq first datatemplate in source {x:datatype} equals type } } public sealed class datatemplatescollection : list<datatemplate> { } and here's how i&

php - add to cart button work with price of zero -

i have variable products in woocommerce have 3 skus. each sku has2 options (size , color) , has retail , wholesale pricing set each variation. i'm using plugin set wholesale pricing. link wholesale plugin based on size, in ounces, of skus have price set 0 retail customers. sample product set skus follows: 500ml - wholesale = $9.95 retail =$19.95 250ml - wholesale $4.75 retail =$9.95 1000ml wholesale = $39.95 retail = $0.00 some skus set 0 (0) retail pricing because 1000ml size not available retail shoppers. when retail customer chooses option of 1000ml message "sorry, product unavailable. please choose different combination." perfect. if wholesale user logged in , chooses 1000ml want show price , allow them place in cart. instead shows item price , cart button disabled. and, message shows "sorry, product unavailable. please choose different combination." see link screenshot example i found hook show if product purchasable or not, don't know ho

php - empty Symfony's profiler? -

Image
i discovered profiler not working. every time try open profiler /app_dev.php/_profiler/empty/search/results?ip=&limit=10 empty profiler page: with default , customc onfiguration. here custom one: framework: profiler: dsn: 'file:/tmp/symfony-profiler' and here more precise configuration: framework: profiler: dsn: "file:%kernel.root_dir%/../var/cache/%kernel.environment%/profiler" no calls stored in theprofiler. no log keep trace of happens under carpet. symfony needs same file permissions write profiling data logs or cache. symfony write files if dsn left @ default write them var/cache/dev/profiler (or app/var older version). it's possible profiler service has been overridden, can checked bin/console debug:container profiler , other such tools.

Run Batch Command Without Checking For Confirmation -

i have batch file restarts several computers in center. batch file works fine if ran faster. reason slow when runs computer has been turned off, continues try find computer 15 seconds before moves next one. can lower time batch command looks computer or have send command , move on next? i have pasted current batch command below: shutdown /f /r /m \\vamar-3sthwv1 /t 000 with ping command believe can it. telling ping command send 1 echo request , && ing result shutdown command, like: ping vamar-3sthwv1 -n 1 >nul && shutdown /f /r /m \\vamar-3sthwv1 /t 000 that way shutdown command gets executed when ping reached out vamar-3sthwv1 in 1 echo request.

Empty values in my SQLite table (Android) -

whenever press 'done' button cardview's title empty. occurred when moved list in singleton sqlite. addwallpaperfragment form user enters title of card. when hit 'done' button returns them main activity (wallpaperlistfragment), recyclerview/cardview, each card has title. wallpaperlab handles adding , getting wallpaper(s) database. wallpaperlab public void addwallpaper(wallpaper w) { contentvalues contentvalues = getcontentvalues(w); mdatabase.insert(wallpapertable.name, null, contentvalues); } public void updatewallpaper(wallpaper wallpaper) { string uuidstring = wallpaper.getid().tostring(); contentvalues values = getcontentvalues(wallpaper); mdatabase.update(wallpapertable.name, values, wallpapertable.cols.uuid + " = ?", new string[] { uuidstring }); } private wallpapercursorwrapper querywallpapers(string whereclause, string[] whereargs) { cursor cursor = mdatabase.query( wallpape

Postgresql function plpython select json value -

i'm using postgresql 9.6. build function "selec"t : id = td["new"]["id"] qry = plpy.prepare ("select (decode->>'key')::integer key table id = $1;", ["int"]) res= plpy.execute(qry,[id]) the request work fine, result hold key , value, not value. in fact, result : {"key":2937} i want value. the result object emulates list or dictionary object. result object can accessed row number , column name. create or replace function pf() returns integer $$ query = 'select 1 key' rs = plpy.execute(query) plpy.notice(rs.__str__()) return rs[0]['key'] $$ language plpythonu; select pf(); notice: <plyresult status=5 nrows=1 rows=[{'key': 1}]> pf ---- 1 https://www.postgresql.org/docs/current/static/plpython-database.html

amazon web services - AWS Cloudfront (with WAF) + API Gateway: how to force access through Cloudfront? -

i want put waf in front of api gateway, , (little) info find possible manually putting cloudfront distribution waf enabled, in front of apig. it's bit of shame, since apig supports custom domains natively, should work. now make solution secure rather obscure, want enforce apis can accessed through cloudfront distro. best option this? i hoping able use 'origin access identities' similar s3, don't see how that. if assign iam user (or role?) cloudfront distro, use apig iam feature, don't see how can done. i require api key in apig, , pass origin custom header cloudfront. work, long don't want use api keys other purpose, i'm not entirely happy that. a dummy (!) custom authorizer used, token validation expression checking secret passed origin custom header cloudfront. should work, it's more flexible, bit dirty... or not? any better ideas? or perhaps "the right way" exists overlooked it? i api gateway. unfortunately, best s

laravel - Two store() methods, one doesn't work (Call to undefined method save()) -

one of 2 similar store methods doesn't work. clarify me? relations a team hasmany users <> user belongsto team a user hasmany characters <> character belongsto user working code (charactercontroller) public function store() { $fighters = fighter::pluck('name')->toarray(); $this->validate(request(), [ 'name' => 'required|min:3|max:25|alpha_num|not_in:'.rule::notin($fighters).'unique:characters', 'fighter' => 'required|in:'.rule::in($fighters), ]); auth()->user()->characters()->save(new character([ 'name' => request('name'), 'fighter' => request('fighter'), ])); return redirect()->route('character.index'); } not working (teamcontroller) public function store() { $this->validate(request(), [ 'name' => 'required|min:3|max:25|alpha_num|unique:teams',

php - How to create table with raw SQL in symfony controller and get a response -

i have controller create table doctrine raw sql: $sql = 'create table if not exists testtable (id int auto_increment not null, name varchar(255) not null, primary key(id)) default character set utf8 collate utf8_unicode_ci engine = innodb'; $em = $this->getdoctrine()->getmanager(); $statement = $em->getconnection()->prepare($sql); $statement->execute(); yet cannot seem figure out how response know if executed successfully. ideas? cerad correct. errorcode , check if '0000'. i'm using mysql , '0000' errorcode if ran successfully. ... $statement->execute(); var_dump( $statement->errorcode() ); // error code. i think should work you. for reference got doctrine api documentation , tried out. here link reference: http://www.doctrine-project.org/api/dbal/2.4/class-doctrine.dbal.driver.statement.html

Css media-queries Galaxy Note 10.1 horizontal/landscape doesn't display -

i use mediaqueries target mobile , tab in order display 4 different images orientation & portrait. everything's fine on devices except on samsung galaxy note 10.1 n8010... mediaqueries don't work. bmh : image mobile landscape bmv : image mobile portrait bth : image tablette landscape btv : image tablette portrait image displaying correctly in portrait (btv) doesn't display in landscape mode (bth) "samsung galaxy note 10.1 n8010 800x1280" /* ------------------------------ media queries ----------------------------------- */ @media (min-width:320px) , (orientation: portrait) { /* smartphones, iphone, portrait 480x320 phones */ .bmh{display:none;} /* .bmv{} */ .bth{display:none;} .btv{display:none;} } @media (min-width:481px) , (orientation: portrait) { /* portrait e-readers (nook/kindle), smaller tablets @ 600 or @ 640 wide. */ .bmh

java - Apache POI library - writing new excel file and force browser to download it -

im trying write data new excel file , force browser download it. i'm using nashorn javascript engine. what need set headers , somehow catch outputstream? have no clue how , therefor need help. code: var output = (function() { var excel = { init: function() { this.cell = packages.org.apache.poi.ss.usermodel.cell; this.row = packages.org.apache.poi.ss.usermodel.row; this.sheet = packages.org.apache.poi.xssf.usermodel.xssfsheet; this.workbook = packages.org.apache.poi.xssf.usermodel.xssfworkbook; this.fileexception = packages.java.io.filenotfoundexception; this.outputstream = packages.java.io.fileoutputstream; this.ioexception = packages.java.io.ioexception; this.createexcel(); }, createexcel: function() { var workbook = new this.workbook(); var sheet = workbook.createsheet("excel example"); var row = sheet.createrow(1); var cell = row.createcell(1); cel

Debugging in Rodeo python IDE -

i novice python, coming r . find rodeo ide bit similar of rstudio. need debug of functions in rodeo. functions browser() in r debug functions. i want peek functions inserting breakpoints can read values of python objects during run time.

stata - How to Lag in Different Time Periods? -

i using large panel data covering years 1970 2002. 1 of variables has observation years 1985, 1995, 1999 , 2002. variable looks follows: +-------------------------+ | country year groups | |-------------------------| 1. | germany 1985 5 | 2. | germany 1995 10 | 3. | germany 1997 . | 4. | germany 1998 . | 5. | germany 1999 20 | +-------------------------+ my intention lag groups variable next observation. have created dummy showing 1 these time periods, don't know how take next step. can lag group variable? it not entirely clear me whether want groups represent value of next or of previous year. anyhow, syntax simple if have each country/year once in dataset: bysort country year: replace groups=groups[_n-1] //for previous observation bysort country year: replace groups=groups[_n+1] //for next observation i not sure why doing this, maybe want rid of missing values. in case take @ this

javascript - Mouse event function is not working -

i have declared function in javascript, , when calling onclick not work. here code: function delete(val) { alert(val); } <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> <i class="fa fa-trash" onclick="delete('.$id.');">'.'</i> delete reserved word in javascript. use different name function. function del(val) { alert(val); } <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> <i class="fa fa-trash" onclick="del('.$id.');">'.'</i>

svn - IntelliJ IDEA(2017.1.2 EAP) : Asking user name and password for subversion every time -

is there way force ide remember username , password, not have reenter them again after restart? ticking box(save credentials) on pop-up windows did not help... seems issue: https://youtrack.jetbrains.com/issue/idea-141048 please check if this comment helps

apache - Redirect from root to Specific URI with HTTPD.conf -

the first rule works fine when maintenance file in place. when it's not - second rule not redirecting specific uri. there ordering issue of rules or ? ######################################### rewritecond %{document_root}/server_maintenance.html -f rewritecond %{request_filename} !/server_maintenance.html rewriterule ^.*$ /server_maintenance.html [l] ######################################### ## %{http_host} evaluates http header name given in case host.server.org, nc being non case sensitive. ## rewrite url @ server side append uri of lawson/portal ########################################################################## rewritecond %{http_host} ^host\.server\.org$ [nc] rewriterule ^host\.server\.org$ "https\:\/\/host\.server\.org\/lawson\/portal" [l] ######################################### you don't match hostname in rewriterule, more reason if matching in defined rewritecond. so do: rewritecond %{http_host} ^host

Simple Java mistake -

package e.power.bhd; import java.util.scanner; public class epowerbhd { public static void main(string[] args) { int accountnum = 1; double cmeter; double pmeter; double eusage; double totaldueamount = 0.0; double tot = 0.0; scanner input = new scanner(system.in); while (accountnum != 0) { // user enter account no system.out.print("enter account number (0 stop ) : "); accountnum = input.nextint(); // user enter current meter reading system.out.print("current meter reading : "); cmeter = input.nextdouble(); // user enter previous meter reading system.out.print("previous meter reading : "); pmeter = input.nextdouble(); eusage = cmeter - pmeter; system.out.print("electricity usage(in kwh) : " + eusage); system.out.println(); if (eusage >= 1 &

How do write two methods with different number of arguments in Ruby -

i trying write inside class: class << self def steps @steps.call end def transitions @transitions.call end def steps(&steps) @steps = steps end def transitions(&transitions) @transitions = transitions end end that won't work since in ruby, can't kind of method overloading. there way around this? you can kind of method aliasing , mixins, way handle methods different signatures in ruby optional arguments: def steps(&block) block.present? ? @steps = block : @steps.call end this sort of delegation code smell, though. means there's awkward interface you've designed. in case, better: def steps @steps.call end def steps=(&block) @steps = block end this makes clear other objects in system how use interface since follows convention. allows other cases, passing block steps method other use: def steps(&block) @steps.call(&block) end

laravel - How to add a custom attribute to Auth::user() when one logs in -

so, first hope title not misleading. please let me know if title fits question. question. i'm using laravel 5.3 , i'm trying find way add attribute "role" auth::user() can access like auth::user()->role. role not field in user table used authentication it's value calculate get. reason ask don't want calculate role every single time need value, instead want set when authentication succeeds reuse it. any idea how can this? or there way can persist value through out time user logged in can calculate once , reuse it? the best way can achieve in user.php model: <?php namespace app; use illuminate\notifications\notifiable; use illuminate\foundation\auth\user authenticatable; class user extends authenticatable { use notifiable; /** * attributes mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password'

javascript - Calling a function in the page constructor results in empty array -

this question has answer here: how return response asynchronous call? 21 answers i try load , bind this.studentnames[i].checked prepare checkboxes (key-value pair in localstorage if checkbox set). however, after correctly pushing entries storage in this.studentnames array (i can see of them in storage in view), this.studentnames array empty [] in array , hence not longer accessable model. do use here in wrong way? thought, when use => functions, erverything should ok?! my view (html) : <ion-list> <ion-item *ngfor="let studentname of studentnames; let i=index"> <ion-label>{{studentname.name}}</ion-label> <ion-checkbox [(ngmodel)]="studentname.checked" (ionchange)="checkboxtoggle($event,studentname)"></ion-checkbox> </ion-item> </ion-list> my model (typescript) : @m

playframework - Where to put application.conf in Play for Scala standalone? -

Image
i using slick in play scala standalone (i.e. not web application). put application.conf file slick takes database configuration? i tried in main/resources/application.conf doesn't work. directories structure: and error i'm getting: exception in thread "main" com.typesafe.config.configexception$missing: no configuration setting found key 'dbcontrol' and appplication.conf: dbcontrol = { url = "jdbc:mysql://localhost:3306/control0001" driver = com.mysql.jdbc.driver connectionpool = disabled keepaliveconnection = true user=root password=xxxx } this worked me, putting application.conf in src/main/scala folder directly.

nlp - How to evaluate the transfer function f(h) for a set of two synsets -

how evaluate transfer function f(h) set of 2 synsets(synonym sets) used evaluate sentence similarity based on semantic nets , corpus. here 'h' stands for? http://ants.iis.sinica.edu.tw/3bkmj9ltewxtsrrvnoknfdxrm3zfwrr/55/sentence%20similarity%20based%20on%20semantic%20nets%20and%20corpus%20statistics.pdf

Why is there no generic operators for Common Lisp? -

in cl, have many operators check equality depend on data type:  = , string-equal , char= , equal , eql , whatnot, on other data types, , same comparison operators ( edit don't forget answer these please :) have generic < , > etc ? can make them work object ?) however language has mechanisms make them generic, example generics (defgeneric, defmethod) described in practical common lisp. imagine same == operator work on integers, strings , characters, @ least ! there have been work in direction: https://common-lisp.net/project/cdr/document/8/cleqcmp.html i see major frustration, , wall, beginners (of am), specially come other languages python use 1 equality operator ( == ) every equality check (with of objects make on custom types). i read a blog post (not monad tutorial, great serie) today pointing this. guy moved clojure, other reasons of course, there 1 (or two?) operators. so why ? there reasons ? can't find third party library, not on cl21. on othe

java - How to get only first level nodes with Jsoup -

i have following xml tree , i'm using jsoup parse it. <?xml version="1.0" encoding="utf-8" ?> <nodes> <node> <name>node 1</name> <value1> <value1>node 1 value 1</value1> </value1> <nodes> <node> <name>node 1 child</name> <value1>node 1 child value 1</value1> </node> </nodes> </node> <node> <name>node 2</name> <value1>node 2 value 1</value1> </node> </nodes> however when try first level of node-elements. returns elements including children nodes, , doing correctly, because child elements match query. elements elements = data.select("nodes > node"); is there way first level node-elements without adding additional level information xml data? you c

php - Uploading image after image and displaying them all -

i've asked couple of questions regarding , each step gets me closer still doesnt work intended. i want upload image , write textfile, when upload image written end , on forth. you'll have long file lots of images. as far can tell code should work doesn't. here link site website testing . testing maybe useful , below code. it creates empty element @ end of array you'll see testing site. the php: $sfilename = "imgdb.txt"; ($i=0 ; $i < count($_files) ; $i++) { move_uploaded_file( $_files['file-'.$i]['tmp_name'], "img/". $_files['file-'.$i]['name'] ); } $simgs = file_get_contents($sfilename); //gets string file. if (json_decode($simgs, true) != false) { $ajimgs = json_decode($simgs, true); } else { $ajimgs = array(); } $aoutput = array_merge ($ajimgs, $_files); $asendtofile = json_encode( $aoutput, json_pretty_print | json_unescaped_unicode ); file_put_contents(

java - resultset is returning null pointer exception -

i have struts program fetching data db. in front end (jsp) i'm giving condition not fetch data(data condition not there in db). when execute code i'm getting null pointer exception because not fetching data. code working fine if there data present in db specified conditions. have exception handlers. these handlers handle exception , show error message user. in case if data not there in db want display message user saying 'no data found'. i'm checking list in jsp (using jstl) whether empty or not.but execution not coming jsp since handled exception handler. can 1 me ?

sql - Oracle update based on rownum -

i need write oracle sql update column value unrelated table using rownum. i cannot work: update table_1 set a.id = (select b.id table_2 b a.rownum = b.rownum) thanks. just need insert value column id table. there no columns can use join rownum. possible? use merge statement instead of update. please find simple example below. test data first ( id column in table_2 null): create table table_2 select level id, chr(64+level) name dual connect level <= 5; create table table_1 select * table_2; update table_2 set id = null; commit; select * table_1; id name ---------- ---- 1 2 b 3 c 4 d 5 e select * table_2; id name ---------- ---- b c d e this merge command copier id values 1 table second 1 basing on rownumns: merge table_2 t2 using ( select * ( select t.*, rownum r

foreach loop syntax in javascript -

consider myarray array of objects. are these 2 pieces of code equivalent ? myarray.foreach((item) => { return doanaction(item); }); myarray.foreach((item) => { doanaction(item); }); is there of them better in terms of syntax? if yes, why ? the better question is, why not use function directly callback, like myarray.foreach(doanaction); the callback must follow api of array#foreach , is function execute each element, taking 3 arguments: currentvalue : current element being processed in array. index : index of current element being processed in array. array : array that  foreach() being applied to. if need element, use given callback directly without mapping.

Stuck : filling html <ul> with <li> using Javascript with a loop? -

i have function retrieves last 10 facebook posts, when use console.log(); displays messages correctly.but when trying fill ul each message list item displays first message , can't seem fix it. in advance function getinfo() { fb.api('/me', 'get', {fields: 'first_name,last_name,name,id,posts.limit(999),email,picture.width(150).height(150)',}, function(response) { document.getelementbyid('myname').innerhtml = response.name; document.getelementbyid('myemail').innerhtml = response.email; var gpost = document.getelementbyid('myposts').innerhtml = response.posts; ///////////only last 10 status posts///////////// var postcount =0; var ul =document.createelement('ul'); for(var i=0;i<999;i++){ if(!gpost.data[i].message==" "){ if (postcount<10){ var li = document.createelement('li'); var list=document.getelementbyid('myposts').innerhtml=gpost.dat

javascript - getJSON works for some addresses, but not others -

having strange problem. i'm using getjson retrieve information online using following code: $.getjson("url", function(json) { $("#quote").html(json.stringify(json)); }); strangely, have been able above code work when use https://api.whatdoestrumpthink.com/api/v1/quotes/random source. other sources have tried, such http://quotes.rest/qod.json not seem return anything. using codepen make page. i can retrieve quotes first url , access how i'd to, not else. have tried using , ajax methods no avail. i'm relatively new code there must obvious i'm missing? thanks help. looks server uses https protocol. correct url , try again. or provide logs if in case request fails.

swift - Save map annotation using UserDefaults -

i have been searching relentlessly solution , left no choice except rely on expertise here on stackoverflow. working on saving map annotation if app closes , have been using userdefault save annotation. this objective c code found , tried converting swift , think there error it. not sure. place code @ viewdidload() this save annotation var pinnedannotation: cllocationcoordinate2d = (parkedcarannotation?.coordinate)! var coordinatedata: nsdata = nsdata(bytesnocopy: pinnedannotation, length: sizeof(pinnedannotation), freewhendone: false) userdefaults.standard.set(coordinatedata, forkey: pinnedannotation) userdefaults.standard.synchronize() and needed load annotation when app open. i dont know if viewdidload right place put. put in mapview function of updatinglocation edited: added code further clarification of have done needed corrected override func viewdidload() { super.viewdidload() mapview.delegate = self mkmapviewdelegate checklocationau