Posts

Showing posts from April, 2013

Compare two arrays with unordered items in php -

h have array year,month,day,hour,minute,second (i not know item in array year,month,etc.. it's unordered) have fixed date format like: yy-mm-dd-h-m-s can me. i wrote code , tried underestand true item. function ($date,$format) { $year = $month = $day = $hour = $minute = $second = 0; $format = 'yy-mm-dd-h-m-s'; //string $date = (1998,12,31,23,44,49) ; // array $format = explode("-",$format); $date = explode("-",$date); $date = array_filter(array_unique($date)); $format = array_filter(array_unique($format)); for($i=0;$i<6;$i++) { if($format[$i] == 'yy') $year = $date[$i]; elseif($format[$i] == 'mm') $month = $date[$i]; elseif($format[$i] == 'dd') $day = $date[$i]; elseif($format[$i] == 'h') $hour = $date[$i]; elseif($format[$i] == 'm') $minute = $date[$i]; elseif($format[$i] == 's') $second = $date[$i]; } echo $year.$month.$day; } but got error: notic

php - Form stops to pass data after user has logged in -

i want sort items on page , using form: <form method="get" action=""> <label for="sort">sort items by</label> <select id="sort" name="sort"> <option value="">-</option> <option value="plth">price (low high)</option> <option value="phtl">price (high low)</option> <option value="naz">name (a-z)</option> <option value="nza">name (z-a)</option> </select> <input type="submit" name="sortsubmit" value="go >"> </form> after form has been processed, use sql statements retrieve items in desired order database: if(isset($_get["sortsubmit"]) && $_get["sort"] == "plth") {

c# - Combine query and use 1 datareader -

i want receive 2 values datareader. don't know how put 1 query. , how can receive using 1 sqldatareader? string query = "select date ars.kmstand ritnr=(select max(ritnr) ars.kmstand)"; string query2 = "select nr ars.kmstand ritnr=(select max(ritnr) ars.kmstand)"; sqlcommand com = new sqlcommand(query2, conn); sqldatareader rt = com.executereader(); while (rt.read()) { ritnr = rt.getint32(0); } rt.close(); sqlcommand comm = new sqlcommand(query, conn); sqldatareader rd = comm.executereader(); while (rd.read()) { value = rd.getsqldatetime(0); } combine queries , pass column index getxxx methods of idatareader value of each column result set. string query = "select nhr, date ars.kmstand ritnr=(select max(ritnr) ars.kmstand)"; sqlcommand com = new sqlcommand(query, conn); sqldatareader rt = com.executereader(); while (rt

ubuntu - A Proper Explanation for the following lex/yacc example -

i having difficulty understanding following code.if possible suggest me site can read through documentations or explain code please every detail. %{ int yylineno; %} %% ^(.*)\n printf("%4d\t%s", ++yylineno, yytext); %% int main(int argc, char *argv[]) { yyin = fopen(argv[1], "r"); yylex(); fclose(yyin); } the code you've posted lex (or flex) code. specification lexical analyser lex (or similar flex) program generate. these days, flex more used lex although believe they're pretty compatible each other. the official flex documentation good: http://flex.sourceforge.net/manual/ and here's link page in manual simple examples 1 you've given explained: http://flex.sourceforge.net/manual/simple-examples.html#simple-examples hope helps.

css - Can’t set custom font when using SASS - Ionic framework -

i set custom font using sass. able when using default configuration style.css file when try run same code on ionic.app.scss doesn't work. //style.css @font-face { font-family: 'bariol_regular'; src: url('../lib/ionic/fonts/bariol_regular.eot'); src: url('../lib/ionic/fonts/bariol_regular.eot') format('embedded-opentype'), url('../lib/ionic/fonts/bariol_regular.woff2') format('woff2'), url('../lib/ionic/fonts/bariol_regular.woff') format('woff'), url('../lib/ionic/fonts/bariol_regular.ttf') format('truetype'), url('../lib/ionic/fonts/bariol_regular.svg#bariol_regular') format('svg'); } .login_title { font-family: "bariol_regular"; text-align: center; } //ionic.app.scss $ionicons-font-path: "../lib/ionic/fonts" !default; //common @font-face { font-family: 'bariol_regular'; src: url("../lib/ionic/fonts/bariol_regular

android - Youtube Leaked Service Connection when setRaetainInstance(true) -

i have problems following error: 04-26 11:41:58.662: e/activitythread(10933): activity myactivity has leaked serviceconnection com.google.android.youtube.player.internal.r$e@2cf388d bound here i have fragment , set following in oncreate: /** * */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.setretaininstance(true); } i set because have list of youtubevideos thumbnails , dont want these thumbnails reloaded everytime user rotates screen. thats unnecessary traffic. the following adapter listview: public class youtubelistadapter extends baseadapter { private list<tutorialentry> entries = null; private list<view> entryviews = null; private map<youtubethumbnailview, youtubethumbnailloader> thumbnailviewtoloadermap = null; private layoutinflater inflater = null; private tutorialthumbnaillistener thumbnaillistener = null; private boolean labelsvisible = false;; pub

apache - Change the icon for php files in directory -

how can change file icon of directory index? want change icon of php files whenever directory requested should display own icon. how can this? you can use addicon directive in .htaccess addicon (img,http://example.com/image.png) .php or image relative path , addicon (img,/image.png) .php

java - Why would jmap -permstat report more than MaxPermSize bytes used? -

i've taken jmap -permstat output of jvm (reported version 24.76-b04), reports following totals: total = 5190 76930 1031431696 n/a alive=1, dead=5189 n/a which should number of entries, classes using information, bytes used metadata , liveness information. now, wonder why report 1031431696 bytes , shy of gigabyte when startup vm -xx:maxpermsize=256m . can shed light on how number calculated? don't know if it's relevant using rhino ~3k entries being definingclassloader s. i have looked bit @ code jmap -permstat implementation. bytes used value estimation based on sizes different types of data classloader loads (methods, fields, interfaces etc). the top level method size calculation loaded class sun.jvm.hotspot.tools.permstat.computesize : private long computesize(instanceklass k) { long size = 0l; // instanceklass object size += k.getobjectsize(); // constant pool constantpool cp = k.getconstants(); size += cp.g

java - JSON null Object Reference Error {Android} -

i have made application tutorial http://javatechig.com/android/json-feed-reader-in-android but when run app in android studio there following errors caused by: java.lang.nullpointerexception: attempt invoke virtual method 'int java.lang.string.length()' on null object reference @ org.json.jsontokener.nextcleaninternal(jsontokener.java:116) @ org.json.jsontokener.nextvalue(jsontokener.java:94) @ org.json.jsonobject.<init>(jsonobject.java:156) @ org.json.jsonobject.<init>(jsonobject.java:173) @ com.example.administrator.myapplication5.feedlistactivity.getjsonfromurl(feedlistactivity.java:127) @ com.example.administrator.myapplication5.feedlistactivity$downloadfilestask.doinbackground(feedlistactivity.java:85) @ com.example.administrator.myapplication5.feedlistactivity$downloadfilestask.doinbackground(feedlistactivity.java:67) @ android.os.asynctask$2.call(asynctask.

Calculating type Haskell -

how calculate type of (.)(.) in haskell? know should be (.)(.) :: (a -> b -> c) -> -> (a1 -> b) -> a1 -> c but how calculate without computer? (.) :: (b -> c ) -> ((a -> b) -> (a -> c)) (.) :: ((e -> f) -> ((d -> e) -> (d -> f))) (.)(.) :: ((a -> (e -> f)) -> (a -> ((d -> e) -> (d -> f)))) (.)(.) :: (a -> (e -> f)) -> (a -> ((d -> e) -> (d -> f))) (.)(.) :: (a -> e -> f) -> -> ((d -> e) -> (d -> f)) (.)(.) :: (a -> e -> f) -> -> (d -> e) -> (d -> f) (.)(.) :: (a -> e -> f) -> -> (d -> e) -> d -> f

eclipse - Where should I specify the native libraries for my Java application? -

Image
i know jvm use java.library.path property locate native libraries @ run time. trying configure eclipse native dependency location. but there many places in eclipse->project properties->build path can specify location. the source tab -> native library location the libraries tab -> jre system library -> native library location. and each external jars, there's native library location entry. as tried, seems no matter configure it , put in java.library.path before application starts. which 1 should use? if goes same destination, why many config entries? so far, guess is, designer of eclipse hope way can programmers organize native libraries more logically . that tab within eclipse put onto buildpath @ runtime , going organized based on library putting onto path not in eclipse ui designate it. as mentioned more logical easier use ui opposed actual change located. prefer using "native library" in source tab out of prefer

javascript - JSON data into html table -

i have json response { "result_ok": "true", "info_message": "2015-04-24 - recharge - 2.8 \n 2015-04-23 - transfer - 15.0 \n 2015-04-21 - recharge - 3.5 \n 2015-04-15 - recharge - 27.7 \n 2015-04-14 - recharge - 5.0 \n", "client_currency":"eur", "balance_account":109.5 } and need put "info_message" data html table below. don't know how go through data of field? <p class="text-right big"><span class="accountcredit">+ 109.5 eur</span></p> <table class="table cblue5"> <tbody> <tr> <td>2015-04-24</td> <td>recharge</td> <td>2.8</td> </tr> <tr> <td>2015-04-23</td> <td>transfer</td> <td>15.0</td> </tr> ...

don't getting correct volume of a sphere from my C code? -

Image
i have started learning c programming.i have question. i wanna calculate volume of sphere radius.my code is: but not giving me correct ans 1523.result 14797486080.000 correct ans 14797486501.627.where problem? i found problem here https://www.urionlinejudge.com.br/judge/en/problems/view/1011 your computation performed in double , converted on assignment float , loose precision. should declare q double . also if concerned precision, should use better approximation of π.

How can i make this code loop in Python -

this code supposed turn decimals binary, figured out part need code go previous question of asking type in integer instead of closing program when calculations done. here have far def binary(n): if n > 1: binary(n//2) print(n % 2,end = '') dec = int(input("enter integer: ")) binary(dec) input("\n\npress enter key exit.") both for loop , while loop achieve required outcome, depending on how many times want statement loop. if know amount of times, use loop, if comparing condition, while loop best. find syntax for loops in python here

rust - Unable to build Hyper - invalid character `-` in crate name -

i trying run hyper example listed on github readme. extern crate hyper; use std::io::write; use hyper::server; use hyper::server::request; use hyper::server::response; use hyper::net::fresh; fn hello(_: request, res: response<fresh>) { let mut res = res.start().unwrap(); res.write_all(b"hello world!").unwrap(); res.end().unwrap(); } fn main() { server::http(hello).listen("127.0.0.1:3000").unwrap(); } and cargo.toml looks this: [package] name = <crate_name> version = <version> authors = <authors> [dependencies] hyper = "0.3" however, when attempt build using cargo run following error: error: invalid character `-` in crate name: `build-script-build` error: invalid character `-` in crate name: `pkg-config` error: invalid character `-` in crate name: `rustc-serialize` i looked through these different crates trying see if maybe change "rustc-serialize" "rustc_serialize" because th

Is there a way to use a memoryview with regexes in Python 2? -

in python 3, re module can used memoryview : ~$ python3 python 3.2.3 (default, feb 20 2013, 14:44:27) [gcc 4.7.2] on linux2 type "help", "copyright", "credits" or "license" more information. >>> x = b"abc" >>> import re >>> re.search(b"b", memoryview(x)) <_sre.sre_match object @ 0x7f14b5fb8988> however, in python 2, not seem case: ~$ python python 2.7.3 (default, mar 13 2014, 11:03:55) [gcc 4.7.2] on linux2 type "help", "copyright", "credits" or "license" more information. >>> x = "abc" >>> import re >>> re.search(b"b", memoryview(x)) traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/re.py", line 142, in search return _compile(pattern, flags).search(string) typeerror: expected string or buffer i can cast string

css - Why minimizing the window causing the HTML elements to disappear from the parent container itself? -

i have following html code me. have duly tried centrally align parent container div #header , childs within #header1 , #header2 respectively. when try minimize window parent container seems not centrally aligned , child headers seems collapsed after setting width explicitly width:50%; of parent container. why so? please explain , me fix this. note horizontal navigation bar below seems associated same bug mentioned above. <!doctype html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> <style> *{ margin:0px; padding:0px; } <!--resetter rules browsers--> #bodycontainer { } body { border:black 2px solid; background-color : grey; padding:5px; } #header { margin:10px auto; background-color : red; width:70%; height:80px; -webkit-border-

php - Laravel's ORM sync with timestamps doesn't update timestamps -

given following model relationship definition: public function receiptants() { return $this->belongstomany(user::class)->withtimestamps(); } and point in controller updated: $invite->messages()->get()->each(function($item) use ($auth) { $item->receiptants()->sync([$auth->user()->id]); }); however timestamps remain unaltered when inspect tables directly. expect updated_at @ least updated.. you can call touch() method manually , update timestamps you. $invite->messages()->get()->each(function($item) use ($auth) { $item->receiptants()->sync([$auth->user()->id]); $item->touch(); });

c# - What will happen to some connection with same connect string? -

this question has answer here: how share 1 mysql connection between multiple threads? 1 answer let have 4 mysql connection , connectstring (i leave connection pooling enabled, i'm using mysql .net connector mysql itself) protected internal mysqlconnection connection; protected internal mysqlconnection cnnct1,cnnct2,cnnct3; protected internal string connectstring = "server=" + addressbox.text + ";database=" + dbnamebox.text + ";uid=" + userbox.text + ";password=" + passbox.text + ";"; then assign connections protected internal void connectionmaker() { connection = new mysqlconnection(connectstring); cnnct1 = new mysqlconnection(connectstring); cnnct2 = new mysqlconnection(connectstring); cnnct3 = new mysqlconnection(connectstring); } what connections is, since app multi-threaded , thread req

java - What is the best runtime exception to use when mandatory input is missing -

i have service, simple class need take input , run business logic. before executing service, user must set data. in general, this: public class testservice extends innerservicebase { /** * mandatory input */ private object inputobj; @override protected errorcode executeimpl() { //some business logic on inputobj return null; } public void setinputobj(object inputobj) { this.inputobj = inputobj; } } what best runtime exception throw in case inputobj null ? illegalstateexception seems best fit. object not in correct state have executeimpl() called on it. whatever exception use, make sure error message helpful. whether should using unchecked exception @ whole other question...

android - How do I put generic type for Gson's TypeToken? -

edit after experimenting while, know problem is. can't put generic type inside typetoken ( type type = new typetoken<customresponse<t>>(){}.gettype(); ). when change t pojoa , can run app fine deserialize json pojoa , not pojob , pojoc . how put generic type typetoken? or, possible this: if (t == pojoa) { type type = new typetoken<customresponse<pojoa>>(){}.gettype(); } else if (t == pojob) { type type = new typetoken<customresponse<pojob>>(){}.gettype(); } else if (t == pojoc) { type type = new typetoken<customresponse<pojoc>>(){}.gettype(); }; previous question: why parsenetworkresponse return nothing when using parametrized type? i suspect error in return (response<t>) response.success(gson.fromjson(json, typeoft), httpheaderparser.parsecacheheaders(response)); part, because print log.d("customrequest", json); on previous line. (please @ my gsonrequest ) my pojo public class customrespon

android - startActivityForResult always return 0 when restore sms -

this code working on lollypop version, but, when use on kitkat, returns 0 when choose "yes/no" option dialog. btnsmsrestore.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { if (currentapiversion >= android.os.build.version_codes.kitkat){ defaultsmsapp = telephony.sms.getdefaultsmspackage(smsactivity.this); if (!getpackagename().equals(defaultsmsapp)) { intent intent = new intent(telephony.sms.intents.action_change_default); intent.putextra(telephony.sms.intents.extra_package_name, getpackagename()); //startactivity(intent); startactivityforresult(intent, def_sms_req); } } else { new restoresms().execute(); } }); @override protected void on

javascript - How to use zombie to test <input type="hidden"> -

this view, want test. <h1>request group rate</h1> <form> <input type="hidden" name="referrer"> name: <input type="text" id="fieldname" name="name"><br> group size: <input type="text" name="groupsize"><br> email: <input type="email" name="email"><br> <input type="submit" value="submit"> </form> <script> $(document).ready(function() { /* document.referrer: returns uri of page links page */ $('input[name="referrer"]').val(document.referrer); }); </script> i wrote test this: var browser = require('zombie'), assert = require('chai').assert; var browser; suite('cross-page tests', function() { setup(function() { browser = new browser(); }); test('requesting group rate quote hood river to

casting - Is it possible to create an android app which can cast device screen including "negative colors" accessibility feature instead of true colors? -

i have low vision , use "negative colors" accessibility feature of android on devices. got google chromecast cast screen tv, streaming in true colors, not negative colors, no matter application use. is possible create android app can cast device screen including "negative colors" accessibility feature instead of true colors? or technically impossible? by "negative colors", referring "color inversion" or else? apps don't have control on mirroring/cast screening; done @ framework level. if not honored mirroring, please file bug.

java - update UI from BroadCastReceiver -

how can update main thread broadcastreceiver. have broadcastreceiver receives string , need set text textview on mainactivity, when findviewbyid(r.id.textview); on onreceive method returns null. here oncreate mainactivity. public class mainactivity extends activity { ...... @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); intentfilter broadcastfilter = new intentfilter(responsereceiver.local_action); receiver = new responsereceiver(); localbroadcastmanager localbroadcastmanager = localbroadcastmanager.getinstance(this); localbroadcastmanager.registerreceiver(receiver, broadcastfilter); intent msgintent = new intent(mainactivity.this, intentservice.class); msgintent.putextra(stockdataintentservice.param_in_msg, getresources().getstring(r.string.url)); startservice(msgintent); } public class responsereceiver extends broadcastreceiver { public static final string local_action = "com.mypackage.all_done&q

c# - Unity 5 object collision not detecting -

so i've started using unity , new c#. i'm running problem sphere (player) wont detect collision touches other objects (runs right through). i wanted have player move units units corresponding left, right, up, down keyboard inputs instead of physics. heres code: public float distance; void fixedupdate(){ if (input.getbuttondown("horizontal") && input.getaxisraw("horizontal") > 0) { transform.translate (distance, 0.0f, 0); } else if (input.getbuttondown("horizontal") && input.getaxisraw("horizontal") < 0) { transform.translate (-distance, 0.0f, 0); } else if (input.getbuttondown("vertical") && input.getaxisraw("vertical") > 0) { transform.translate(0, 0, distance); }else if(input.getbuttondown("vertical") && input.getaxisraw("vertical") < 0){ transform.translate(0, 0, -distance);

java - Why is Android Studio not opening for me? -

i have jdk downloaded well, , every forum i've seen question asked on says add variable jdk_home or java_home , i've tried both still doesn't open. i've reinstalled android studio , restarted computer isn't opening. i'm getting loading icon this it's stuck on that. i'm running windows 8.1 , have installed recent version of jdk. excited start coding , or suggestions appreciated. try download android studio bundle version has want including sdk. set environmental variable , go!

osx - Install the AWS CLI Using the Bundled Installer (Linux, OS X, or Unix) -

when following install aws cli using bundled installer (linux, os x, or unix) directions i'm getting error caused looks incorrect file path file:///users/jspooner/downloads/awscli-bundle/packages awscli-1.7.24.tar.gz . believe should packages/awscli . there python script broken or missing something? ➜ downloads python --version python 2.7.7 ➜ downloads sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws password: running cmd: /usr/local/opt/python/bin/python2.7 virtualenv.py --python /usr/local/opt/python/bin/python2.7 /usr/local/aws running cmd: /usr/local/aws/bin/pip install --no-index --find-links file:///users/jspooner/downloads/awscli-bundle/packages awscli-1.7.24.tar.gz traceback (most recent call last): file "./awscli-bundle/install", line 138, in <module> main() file "./awscli-bundle/install", line 129, in main pip_install_packages(opts.install_dir) file "./awscli-bundle/install", line 98, in pi

parsing - Python: How to turn two for-statements into one? -

Image
i'm trying parse web table , export data csv file. i'm ignorant forming 2 xpaths followed single for-statement (or maybe 2 correct?). current spider: class myspider(basespider): symbols = ["scmp"] name = "dozen" allowed_domains = ["yahoo.com"] start_urls = ["http://finance.yahoo.com/q/is?s=scmp&annual"] def parse(self, response): hxs = htmlxpathselector(response) revenue = response.xpath('//td[@align="right"]/strong/text()') date = response.xpath('//tr[@class="yfnc_modtitle1"]/th/text()') items = [] rev in revenue: item = dozenitem() item["revenue"] = rev.re('\d*,\d*') items.append(item) return items[:3] days = [] day in dates: item = dozenitem() item["date"] = day.re('\d*') days.append(item)

html - Navbar above the content (like in an above layer) -

Image
i'm trying put navbar under big header, going in front of it, isn't above kinda in front in code navbar it's under "debugando" showing above it, want stay under not working can't find why. think position or float. code( first css html ): body { margin: 0 0 0 0; padding: 0 0 0 0; font-family: josefin sans, sans-serif; } .navbar { background: #428f48; height: 40px; border-radius: 0px; margin: 0 0 0 0; padding: 0 0 0 0; } .nav { margin-top: 5px; margin-left: 50px; } .nav-pills>li { font-size: 24px; margin-left: 20px; } .jumbotron { background: #27b032; width: 100%; margin: 0 0 0 0; padding: 0 0 0 0; position: absolute; } .title { font-size: 80px; margin-left: 10%; padding: 40px 0 40px 0; float: left; } .description { font-size: 20px; margin-left: 5%; padding-left: 3%; border-left: 1px solid black; height: 60px; margin-top: 65px; float: left;

Dropbox Core API Java - cannot get folder size in metadata -

i using dropbox core api in java create app. when try metadata folder, field's name, iconname , mighthavethumbnail, contrary python, lists details. missing or java api expose limited information? i'm trying print metadata via code: dbxentry listing = client.getmetadata("/testfolder");<br> system.out.println(listing.tostringmultiline()); to rest of metadata, you'll want cast dbxentry.folder : dbxentry entry = client.getmetadata("/testfolder"); if (entry instanceof dbxentry.folder) { dbxentry.folder folder = (dbxentry.folder)entry; system.out.println(folder.tostringmultiline()); } but olivier pointed out, folders not have sizes in dropbox. if you're interested in how big files within folder are, you'll have sum sizes yourself.

reflection - how do you log function call return values in golang -

i want know return values @ time of exit golang function. golang defer mechanism helpful, evaluates arguments @ time defer statement registered rather when executed. can work using anonymous function accesses return values: func try() (int i) { defer func() {fmt.printf("%d", i)}() = 10 return i+1 } func main() { try() } this work ok, think, handle in generic manner, perhaps like: func try(in string) (out int) { enter("%s", in);exit("%d", out) } or, better, use reflection output arguments/return values @ time of entry/exit. i'm assuming runtime performance isn't critical :). is there way this? shaba abhiram's handy tracey lib go long way towards stops short of printing return values. you correct in assesing arguments deferred function evaluated @ point defer queued, not when executed. your method of making anonymous function refers named returns valid. approach pass in address of return values: func try()

python - How do I blit specific indexes of text to the screen in pygame -

import pygame import math def storyline(): pygame.init() width = 1104 height = 644 white = 255,255,255 red = 255,0,0 color = 255,0,0 black = 0,0,0 cyan = 0,255,255 gamedisplay = pygame.display.set_mode((width,height)) pygame.display.set_caption('war games 3') map = pygame.image.load('map3cut.png') map = pygame.transform.scale(map, (1104,644)) stop = false while not stop: gamedisplay.blit(map, (0,0)) storytext = pygame.font.sysfont("monospace",25) storyfont = storytext.render('click enter continue...',5,(red)) gamedisplay.blit(storyfont,(50,500)) event in pygame.event.get(): if event.type == pygame.keydown: if event.key == pygame.k_return: maingame() if event.type == pygame.quit: pygame.quit() quit() pygame.display.update() here have text

android - How to build a modular app -

i have app has 10 different components (chat, feed, profile, settings, etc'). i need ability create multiple apps each 1 of them have number of components. example: app1 - have chat settings , profile. app2 - have feed , settings. how should approach this? i thinking of building each component library , each app need build connect pieces puzzle. would correct way? or have better suggestions? thanks you can develop "sdk" project (like facebook sdk) includes components (chat, feeds, profiles, users etc.) , can use "sdk" library in other projects. use whichever components want particular app. this approach make "sdk" project maintainable , upgradable. when adding new feature (say, albums) can integrate "sdk" project , use existing applications.

dom - PHP XPath Child Concat And New Line Issues -

i using domxpath query nodes in html document content extract. i have following html document: <p class="data"> immediate text <br> text in second line <br> e-mail: <script>some script tag</script> <a href="#"> <script>another script tag</script> link in third line </a> <br> text in last line </p> i receive following result: immediate text\r\ntext in second line\r\ne-mail: link in third line\r\ntext in last line so far have following php code: #... libxml_use_internal_errors(true); $dom = new \domdocument(); if(!$dom->loadhtml($html)) { #... } $xpath = \domxpath($dom); $result = $xpath->query("(//p[@class='data'])[1]/text()[not(parent::script)]"); problems: it not include child nodes' texts. it not include line breaks. by using child axis / in /text() you'll direct child o

java - Getting indexes from two-dimensional array -

how can int = 400; int b = 100; 2-dimensional array 1000 x 1000 in java, example, mass[400][100] (row 400, column 100)? found element in array , need numbers of row/line , column. how can numbers? thanks. if need find position in array based on value , have no other option brute-force loop through whole array, breaking out when find first match: int[][] massivearray = new int[1000][1000]; final int valuetofind = 27; // assign value find @ position (400, 100) massivearray[400][100] = valuetofind; int i_value = -1; int j_value = -1; // find first occurrance of valuetofind looping through array outer: (int = 0; < massivearray.length; i++) { (int j = 0; j < massivearray[0].length; j++) { if (massivearray[i][j] == valuetofind) { i_value = i; j_value = j; break outer; } } } system.out.println(string.format("first position %d @ (%d, %d)", valuetofind, i_value, j_value));

remote datasource in jquery autocomplete -

i have show searched text in jquery autocomplete list. have function adding search text in list have remote datasource. have url returning array . working demo static array list fiddle i have add same functionality remote data source. how can add search text in response. $(document).ready(function() { var tagselem = $("#tags"); tagselem.autocomplete({ source : "search.php", search : function( event, ui ){ if(check(response,tagselem.val())) response[response.length]=tagselem.val() tagselem.autocomplete( "option", "source", response); }, open: function( event, ui ) { if(check(response,tagselem.val())){ tagselem.next().find('li:last a').append(' <span style="color:red;">new</span>'); } } }); function check(arraytag,value){ for(i=0;i<len;i++

go - How to exclude multiple directories from bee pack -

how exclude multiple directories bee pack tool? bee pack -ba "-tags prod" -exr=^userfiles$ this excludes particular directory. want exclude directories named userfiles, deploy, docs. tried -exr=[^userfiles$,^deploy$,^docs$] -exr=["^userfiles$","^deploy$","^docs$"] both of these didn't work. since exr regexp, try , use (using re2 syntax ) composite: -exr=^(?:userfile|deploy|docs)$ the op joseph confirms idea in comments : goop exec bee pack -ba "-tags prod" -exr="^(?:userfiles|deploy|tests|docs)$"

mysql - php form submit isnt inserting into the database -

right, should basic php, cannot life of me figure out why not working. i have form when submit should grab fields insert data database. have on index.php section pulls info database , works fine cant see being connection problem. db_connection.php have hashed out info here database, correct <?php define("db_server","**********"); define("db_user","*************"); define("db_pass","*********"); define("db_name","reviews"); $connection = mysqli_connect(db_server,db_user,db_pass,db_name); if(mysqli_connect_errno()){ die("database connection failed"); } ?> functions.php <?php function redirect_to($new_location) { header("location: " . $new_location); exit; } function confirm_query($result){ if(!$result){ die("database query failed"); } } function find_reviews($connection){ $query = "select * ";

windows mobile 6.5 - How to create menu & sub Menu in smart device app in visual studio 2008 -

i new smart device application in visual studio 2008. have create smart device app have menu & sub menu @ top (similar desktop application). once user clicks on sub menu navigate form. please let me know find resource/study material learn more building smart device application using visual studio 2008. thanks in advance. windows mobile supports 1 menu line (your main menu) due limitted space on screen. may switch between different main menus code. good books cf programming starters paul yao's programming compact framework , mor background: douglas boling's programming windows ce .net. , not forget basic , read charles petzold's windows programming book. always keep in mind windows mobile device has less resources , smaller screen desktop windows. api subset of full framework, same natice c/c++ api.

android - Visual Studio Cordova Tools signed Release apk 'app not installed' -

my debug apk's install fine, signed release (or distribution) config apk's start install , give me 'app not installed' message on device. guess not signing properly? appears to. tips appreciated. you welcome, ps: sorry! can't comment (not enough reputation!) took, somehow, previous answer comment, :)) put here again: answer: if 2 .apks have different signatures (eclipse uses debug certificate), not able install/update new .apk without removing previous one. you can find more information here . found here .

ios - Trouble creating a color in swift on Xcode using variables in a different class -

what wrong code? created variables in different class random values rgb color. import uikit class graphics: viewcontroller { class color: uiview { override func drawrect(rect: cgrect) { let swiftcolor = uicolor(red: 1, green: 165/255, blue: 0, alpha: 1); let context = uigraphicsgetcurrentcontext() cgcontextsetlinewidth(context, 5.0) cgcontextsetstrokecolorwithcolor(context, uicolor(red: red1, green: green1, blue: blue1, alpha: 1.0))//.bluecolor().cgcolor) let rectangle = cgrectmake(60,170,200,80) cgcontextaddrect(context, rectangle) cgcontextstrokepath(context) cgcontextsetfillcolorwithcolor(context, uicolor(red: red, green: green, blue: blue, alpha: 1.0))//.redcolor().cgcolor) cgcontextfillrect(context, rectangle) } /* // override drawrect: if perform custom drawing. // empty implementation adversely affects performance during animation.

Inserting SQLite primary key in python -

i trying sqlite insert python script. i getting error: table history has 4 columns 3 values supplied the reason there 3 not 4, first 1 id. assumed declared primary key auto-increment value. how go inserting id .py: c.execute("insert history values (?,?,?)", (q[0],t,in)) .db create table history (id integer primary key, employeeid integer, time datetime, inout varchar); you either have provide values all columns, or name columns inserting explicitly. sqlite not go , guess columns provided values for, need explicit them. you can use null have sqlite insert auto-generated id you: c.execute("insert history values (null,?,?,?)", (q[0],t,in)) or can name 3 columns inserting explicitly: c.execute("insert history (employeeid, time, inout) values (?,?,?)", (q[0],t,in))

css - Full screen 7x5 grid with Foundation SCSS -

hope there's here have done i'm trying accomplish. i'm learning new js frameworks , i've got idea make full screen calendar topbar fixed homepage. calendar should take full width , full height available on normal monitors. i've managed make full width using foundation scss changing in _settings.scss: $row-width: 100%; $total-columns: 7; my main question - what's optimal way creating 5 rows (it's 5 rows single month) take full remaining height of screen? (remaining because of topbar navigation fixed). i'm ok scss suggestions welcome. thanks! ok, solution works is: // client height (screen height) var maxheight = window.innerheight; var topbarheight = $('div.fixed').height(); var columnheight = (maxheight - topbarheight - 10) / 5; $('.calendar-row .column').height(columnheight); i think there must more "elegant" solution maybe i'm wrong. if find better solution please reply. thanks.

ruby on rails - How top pop last element of ActiveRelation? -

say have query: red_houses = user.houses.where(color: 'red') how can pop last element of red_houses ? i know can red_houses[1..-2] , not red_houses.pop , there way missing? basically want delete last element , remaining relation without last element on it. you have 2 methods remove records association: delete , destroy . both of them can called object want remove or id. (also can use list of object or list of ids parameters). since :delete works according strategy specified :dependent option (with default of nullify), :destroy remove records database, ignoring :dependent option. but, if don't want persist @ db action. before remove, need working variable (calling :to_a ), , can call pop : red_houses = user.houses.where(color: 'red').to_a red_houses.pop

DynamoDB “OR” conditional Range query -

let's assume table looks like: code |startdate |enddate |additional attributes... abc |11-24-2015 |11-26-2015 | .... abc |12-12-2015 |12-15-2015 | .... abc |10-05-2015 |10-10-2015 | .... pqr |03-24-2015 |03-27-2015 | .... pqr |05-04-2015 |05-08-2015 | .... provided code (c) , date range (x, y), need able query items like: query => (code = c) , ((startdate between x , y) or (enddate between x , y)) i planning use primary key hash , range key (code, startdate) additional lsi (enddate) , query on it. not sure if there way achieve this. don't want use scan operation seems scan entire table costly. also, achieve in single query. one option using query , filterexpression . no need define lsi on case. have query hash key eq operator , narrow results filter expression. here example java sdk: table table = dynamodb.gettable(tablename); map<string, object> expressionattributevalues = new hashmap<string, object>