Posts

Showing posts from June, 2012

Python int() to the nearest value -

the way python int() function works rounds number smallest value. such 4.99 = 4 what can if want 4.99 equal 5? int() truncates float values, removing non-integral portion of number. looking rounding instead. you can use round() function that: >>> round(4.99) 5

embedded linux - how to add libselinux into the openwrt build system? -

i building openwrt system selinux support. first meet bug cannot find , during busybox compiling. , know there libselinux library needed build busybox selinux support. not familiar openwrt makefile, want know how add library in it? there guide? further more, have find code in selinux github( https://github.com/selinuxproject/selinux ) different code have find in local linux source in openwrt ("/linux/security/selinux/*"). why? know selinux supported in linux2.6. seems still have port selinux linux self? this problem has blocked me long time. soft of appreciated, thanks! i know selinux on debian, since mix different things, answer "why?" part: the linux-kernel offers interface via linux security modules (lsm) selinux , other security modules (that see in "local linux source"). to manage selinux , policies there userland tools (that github link). selinux policies compiled .pp files consist of .te/if/fc files , there ready-to-use rules c...

objective c - Cocoa/objectiveC UI design issue -

i'm trying build app on macosx - objectivec. don't not find ressource understand how can create view need , steps made it. i'm looking create 3 sections. section 1: few buttons , 1 image section 2: treeview have file browser/finder section 3: progress bar show disk usage. i'm creating app read android device , manage file transfer. such android file transfer. first , foremost need on tutorial apple provides on creating first mac app . second can use nsoutlineview create treeview, here's tutorial on this. then need nsprogressindicator progress bar, here's tutorial. i suggest on @ ray's tutorials started xcode , interface builder tools.

python - How do I quantize data in pandas? -

i have dataframe a = pd.dataframe(a.random.random(5, 10), columns=['col1','col2','col3','col4','col5']) i'd quantize specific column, col4 , according set of thresholds (the corresponding output integer 0 number of levels). there api that? most pandas objects compatible numpy functions. use numpy.digitize : import pandas pd = pd.dataframe(pd.np.random.random((5, 5)), columns=['col1','col2','col3','col4','col5']) # col1 col2 col3 col4 col5 #0 0.523311 0.266401 0.939214 0.487241 0.582323 #1 0.274436 0.761046 0.155482 0.630622 0.044595 #2 0.505696 0.953183 0.643918 0.894726 0.466916 #3 0.281888 0.621781 0.900743 0.339057 0.427644 #4 0.927478 0.442643 0.541234 0.450761 0.191215 pd.np.digitize( a.col4, bins = [0.3,0.6,0.9 ] ) #array([1, 2, 2, 1, 1])

javascript - Enable datetime selection in ruby on rails -

i new ruby on rails. want display date format yyyy-mm-dd hh:mm:ss . on using calendar_date_select method :time=>true in view, able display format yyyy-mm-dd hh:mm . there method overwrite current diplaying format format need? you can use 'strftime' method on dates format desire. ex. time = time.now time.strftime('%y-%m-%d %i:%m:%s %p') #this gives 2015-07-15 08:28:38 pm

Combining four tables in SQL Server -

i have 4 tables table a , table b , table c , table d . schema of 4 tables identical. need union these 4 tables in following way: if record present in table a considered in output table. if record present in table b considered in output table if not present in table a . if record present in table c considered if not present in table a , table b . if record present in table d considered if not present in table a , table b , , table c . note - every table has column identifies table every record (i don't know if of importance) records identified based on particular column - column x not unique within each table you (only 2 cases shown should see how extend this) with cte1 ( select 't1' source, x, y t1 union select 't2' source, x, y t2 ), cte2 ( select *, rank() on (partition x order case source when 't1' 1 when 't2' 2 ...

java - How to parse HttpServletRequest for curl / wget options? -

when request done in curl user parameter like: curl -u <user> http://url... how can user? since curl uses http basic authentication default, user , password combined using : separator , encoded using rfc2045-mime variant of base64. can base64-encoded value authorization header. header may looks authorization: basic qwxhzgrpbjpvcgvuihnlc2ftzq== . see this wiki , rfc 2617 more information.

javascript - HTML input output -

user enters name here part of form. <p>name <font color="red">(required) </font> <input name="flname" required="required" placeholder="your name" </p> this solution provides way of providing sample text can edited, , php can run inside it, unlike <textarea> . however, problem unlike <textarea> , cannot seem <div contenteditable... submit information email php file have set on server. have idea how i'd implement this. <div contenteditable="true" name="message" required="" placeholder="your message" >dear <?php echo "$mptitle $mpsecondname" ?>, <p> please support us... </p> <p> kind regards, </p> <script type="text/javascript"> document.write(document.getelementbyid('flname').id);</script> </div> <div align="center"> # update 2: hi, thank both ...

php - image upload in codeigniter -

i trying upload image in following code: controller: public function do_register() { $this->load->library('form_validation'); $this->form_validation->set_rules('uname', 'username', 'required|min_length[4]|max_length[15]'); $this->form_validation->set_rules('email', 'email', 'required|valid_email'); $this->form_validation->set_rules('pass', 'password', 'required|min_length[4]'); $this->form_validation->set_rules('address', 'details', 'required|min_length[4]'); if($this->form_validation->run() == false) { $this->load->view('login_view'); } else { $path = $_files['image']['name']; $imgext=strtolower(strrchr($path,'.')); $imgname= $this->generaterandomstring().$imgext; ...

libgdx - Detect collision between Actors -

Image
i'm trying implement collision detector between player (actor) , obstacle (actor too), , wonder what's best way perform collision detection between them. see users saying create rectangle object in class , update bounds every frame, don't know if best way perform (i'm trying make this, collision detector method triggers before player touches obstacle). this i'm trying check: public boolean touchedwall() { // loop obstacles (obstacle obstacle : this.world.getobstacles()) { // check if player collided wall if (this.bounds.overlaps(obstacle.getbounds())) { gdx.app.log(configuration.tag, "collided " + obstacle.getname()); return true; } } return false; } and method triggers (it should trigger when player bounds hit wall): i figured out! instead of using this.bounds.set(x, y, width, height) , using this.bounds.set(x, y, height, width) this: this.bounds.s...

python - unstruct wikipedia synonym bracket -

i want unstruct wikipedia synonym bracket. here's easy 1 do. he [[korean]]. i can remove bracket. here's difficult one. he lives in [[gimhae city|gimhae]]. the first one(gimhae city) wikipedia document title. so have second 1 in bracket. any suggestion welcome. you can use following regex: \[{2}(?:[^|\]]*\|)?([^]]*)]{2} and relace \1 . see demo here regex matches: \[{2} - 2 opening square brackets (?:[^|\]]*\|)? - 0 or 1 sequence of characters other | , ] (with [^|\]]* ) , literal | \| (note escaped outside of character class) ([^]]*) - matches , captures group 1 we'll reference later \1 0 or more characters other closing square bracket ]{2} - 2 closing square brackets (note not have escape them here since first [ escaped). the python snippet : import re p = re.compile(r'\[{2}(?:[^|\]]*\|)?([^]]*)]{2}') test_str = "he lives in [[gimhae city|gimhae]]. lives in [[gimhae]]. " result = re.sub(p, r"...

php - how to check yii2 relation is exist show controller -

i have user , agency models user have agency model , can access whit $user->agency now want check in accessrule when relation is exist show controller if relation null show alert 'user->agency null pealse create agency' , pass user agency controller in user model have relation : public function getagency(){ return $this->hasone(agency::classname(),['id'=>'agency_id']) ->viatable(self::map_table,['user_id'=>'id']); } and have accessrule components : namespace common\components; use common\models\user; class accessrule extends \yii\filters\accessrule { /** * @inheritdoc */ protected function matchrole($user) { if (empty($this->roles)) { return true; } foreach ($this->roles $role) { if ($role == '?') { if ($user->getisguest()) { return true; } } ...

node.js - Do I have to rewrite an html header everytime I want to use it? -

i'm trying develop site using node.js. i'm having trouble due unfamiliarity html , node.js. there mechanism in either node.js or html don't have recreate header & footer every single web page (eg: copy paste html code each time)? not sure answer question it's 1 way add header , footer in html pages without repeating code. <script> $(function(){ $("#header").load("header.html"); $("#footer").load("footer.html"); }); </script> and in main index.html file be <div id="header"></div> <div id="content"> main content </div> <div id="footer"></div> so complete index.html this <html> <head> <title></title> <script src="//code.jquery.com/jquery.min.js"></script> <script> $(function(){ $("#header").load("header.html"); ...

process - How can I use java code to compile java file in other folder? -

i trying use java's process p = runtime.getruntime().exec(command); to compile .java files in other folder, not work. main.class in folder a , , .java files in folder a/test . main.class : public class main{ public static void main( string[] args ) throws ioexception,interruptedexception{ string line =""; string command = "javac test/*.java"; process pro = runtime.getruntime().exec(command); bufferedreader in = new bufferedreader( new inputstreamreader( pro.getinputstream())); while ((line = in.readline()) != null) { system.out.println(line); } bufferedreader er = new bufferedreader( new inputstreamreader( pro.geterrorstream())); while ((line = er.readline()) != null) { system.out.println(line); } } } and error stream shows: javac: file not found: test/*.java why happen? there java file in...

Mesos, Marathon, Docker, Wildfly -

i have 3 node mesos cluster marathon framework. on slaves have docker , want deploy few wildfly instances on 1 node. how can deploy few instances of wildfly docker containers on 1 slave mesos node marathon? deploying docker container using marathon straight forward. understand correctly want deploy several containers onto single slave? in case should @ marathon's contraints .

Method of Runge-Kutta in Python -

i wrote code runge-kutta method in python, every time when program realizes calculus program require differential equation. this code: from math import * import numpy np #initial values n=input("enter number of equations n:") n=int(n) x=np.array([]) in range(0,n): x0=input("enter initial value of x{}:".format(i)) x=np.append(x,[x0]) t=input("enter initial value of t:") tf=input("enter final value of t:") h=input("enter time interval h:") m=int((tf-t)/float(h)) #definition of differential equations def f(t,x): f=np.array([]) in range(0,n): f0=input("enter equation f{}:".format(i)) f=np.append(f,[f0]) return f a=1.0/6 in range(0,m): k1=f(t,x) k2=f(t+0.5*h,x+0.5*h*k1) k3=f(t+0.5*h,x+0.5*h*k2) k4=f(t+h,x+h*k3) x=x+a*h*(k1+2*(k2+k3)+k4) t=t+h print t, x example using equation dx/dt=x, x(0)=1, xf=1, h=0.1: enter number of equations n:1 enter initial value ...

Display Joomla component within a module -

i'm trying display joomla 2.5 component in module. in module entrypoint have: jloader::import('joomla.application.component.model'); jloader::import( 'quizzes', jpath_site . '/components/com_questions/models' ); jloader::import('joomla.application.component.controller'); if (!class_exists('questionscontrollerquizzes')) { require_once (jpath_site . ds . 'components' . ds . 'com_questions/controllers' . ds . 'quizzes.php'); } $quiz_controller = new questionscontrollerquizzes(false, $params->get('poll')); $quiz_controller->execute( jrequest::getvar('task','load') ); i tried debug , seems can't load correct view. seems looking generic com_content in $this->basepath. the strange thing if load module in page component loaded, display correctly. any idea how succesfully display component output in module? try this: how display joomla component in module and re...

xcode - How to convert PFObject array in image view? -

Image
sorry guys want try again reword understandable. imagefiles array of pfobjects, 10 images let randomnumber = imagefiles[int(arc4random_uniform(uint32(imagefiles.count)))] println(randomnumber) and println gives me random image file array. how put image view? meaning want random element of array viewable in uiimage view. let image = uiimage(data: randomnumber anyobject as! nsdata) closest i've got... no syntax error runtime could not cast value of type 'pfobject' (0x105639070) 'nsdata' (0x106c97a48). an actual image stored in parse not of format pfobject , of type pffile . reference pffile stored within pfobject . i can imagine code/pseudocode end looking following: let myrandomimagemetadata = imagefiles[int(arc4random_uniform(uint32(imagefiles.count)))] let imagefilereference: pffile = myrandomimagemetadata["imglink"] the actual code depend on database structure i've asked here , never provided. now have f...

opengl - Shader execution after writing to gl_FragDepth -

given fragment shader modifies original depth of fragment , writes gl_fragdepth . code after writing gl_fragdepth still executed if depth test fails @ point? example: in float depth; layout(depth_less) out float gl_fragdepth; void main() { float newdepth = depth - somemodification; gl_fragdepth = newdepth; a(); } will a executed if newdepth greater current value in gl_fragdepth ? if so, alternative stop shader doing unneccessary computations in a - without using custom depth buffer? in example, a() executed long contributes output value, e.g. color (otherwise, compiler remove optimization). depth test per-sample operation performed after fragment shader. under special circumstances , possible test before fragment shader, requires fragment shader not write gl_fragdepth. is modification uniform 1 or different each fragment? if uniform, in geometry shader - apply depth modification whole primitive. use early-z. if it's on per-fragment basis, try bindin...

java - Which layer in RMI performs marshalling and unmarshalling? -

my question theoretical. actually, in rmi among stub , skeleton layer layer performs marshalling , unmarshalling. both layers performs both function or what??? both layers perform both functions. explained in rmi architecture documentation . the stub marshals request, , unmarshals reply. the skeleton unmarshals request , marshals reply.

arrays - Create every possible combination in PHP -

so, trying list of every possible combination of set of words. with input text "1, 2" , values being ("1" => "a", "b", "c") , ("2" => "d", "e"), like: a, d b, d c, d a, e b, e c, e with code have right now, get: a, d b, d c, d how can around this? code: foreach ($words $word) { ($i = 0; $i < count($array); $i++) //for every value { $key = array_keys($array[$i])[0]; if ($word === $key) { $syn = explode("|", $array[$i][$key]); //get synonyms foreach ($syn $s) //for each synonym within { $potential[] = implode(" ", str_replace($key, $s, $words)); } } } } the procedure every word in input text, want go through our entire array of values. in there, have other arrays ("original" => "synonyms"). there, loop through every synonym , add l...

c++ - How to have Eclipse console show the same GoogleTests output as in the terminal? -

Image
i use googletest extensively , output in cosole looks this: when run same within eclipse (using eclipse mars latest of today) following output no colors , junk characters (are not visible pasting output here): running main() gtest_main.cc [0;32m[==========] [mrunning 3 tests 1 test case. [0;32m[----------] [mglobal test environment set-up. [0;32m[----------] [m3 tests nloptadaptersuite [0;32m[ run ] [mnloptadaptersuite.testquadraticfunction1 [0;32m[ ok ] [mnloptadaptersuite.testquadraticfunction1 (1 ms) [0;32m[ run ] [mnloptadaptersuite.testquadraticfunction1withnoise [0;32m[ ok ] [mnloptadaptersuite.testquadraticfunction1withnoise (1 ms) [0;32m[ run ] [mnloptadaptersuite.testquadraticfunction2 [0;32m[ ok ] [mnloptadaptersuite.testquadraticfunction2 (1 ms) [0;32m[----------] [m3 tests nloptadaptersuite (3 ms total) [0;32m[----------] [mglobal test environment tear-down [0;32m[==========] [m3 tests 1 test case ran. (3 ms total) [0;32m[ p...

r - issues with groupedData() -

i'm following tutorial on mixed effects models. tutorial uses egsingle dataset mlmrev package. part of tutorial, author uses groupeddata() as: egsingle <- groupeddata(math ~ year | schoolid/childid, data = egsingle) could me understand "schoolid/childid" refers to? please note schoolid , childid both factors! also, later in tutorial, author takes sample of size 50 , uses lmlist() fit ols regression each subject using: egsingle <- groupeddata(math ~ year | schoolid/childid, data = egsingle) samp <- sample(levels(egsingle$childid), 50) level2.subgroup <- subset(egsingle, childid %in% samp) # fitting separate ols regression line each student level2 <- lmlist(math ~ year | childid, data = level2.subgroup) plot(augpred(level2)) when run lmlist command above, these errors: error in eval(expr, envir, enclos) : object 'childid' not found in addition: warning messages: 1: in lmlist(math ~ year | childid, data = level2.subgroup) : lmlist no...

php - How to find out on what framework or in which language was the website created? -

this question has answer here: how determine technology website built on? [closed] 18 answers how can find out on framework or in language website created? for example, if person sends me link own website has created , claims website build (for example) ruby on rails (or codeigniter (or whatever)), how can sure, used framework or language create website? why asking... on websites elance clients ask freelancers show them examples of previous projects. so, if client, how can sure, person sends me project, created in language , framework need? because can have (for example) lot of codeigniter projects, tell me created via rails hired. it can own server, free domain name , free hosting, (i don't care). mean how know information need, not using different internet tools can put url , description of website. because can have own server, free domain name , free hos...

javascript - Center columns using Foundation 5 -

i have problem center columns using zurb foundation 5. on test page it's not work correctly http://rsketchbook.o12.pl/test/ on snippet looks good. don't know what's difference, what's missing in code. tell me why doesn't work on test page? $(document).foundation(); @font-face { font-family: 'roboto light'; src: url('../fonts/robotolight.woff2') format('woff2'); } @font-face { font-family: 'roboto regular'; src: url('../fonts/robotoregular.woff2') format('woff2'); } h1, h2, h3, h4, h5, h6 { font-family: 'roboto regular', sans-serif !important; } p, em, { font-family: 'roboto light', sans-serif !important; } @media screen , (min-width: 58.75em) { body > header { background-image: url("https://static.pexels.com/photos/7217/landscape-mountains-clouds-trees.jpg"); background-position: center center; height: 600px; } #nav-bar ...

php - How to search in MySQL in a 60G table containing 330M rows? -

i have table 60g , has 330m entries. i must display on front-end web-app. on web-app there search function searches string pattern in every row of database table. the problem search takes 10 min , makes mysql process freeze. looked solutions haven't found suitable one. in-memory database: database big (it goes 200 gb - 60gb @ moment) split table table each month put these on 6 ssds (i need data half year) it's possible search parallel on 6 ssd reduce data amount (?) image here: http://i.stack.imgur.com/q2tyd.png if using implicit cursor search threw db consider closing after every 50 rows reopening @ row stopped at.

winforms - Create a custom UserControl using c# -

Image
i created custom usercontrol using windows form control library.and want create property of usercontrol which can add item it, can select item combobox. winforms allows create rich design-time environment providing customised editors @ runtime properties define. for example, if plonk messagequeue component onto winforms form , view properties window, can see property named formatter . clicking on formatter property displays drop-down box showing preset list of values. example of ui type editor . one way define enum supported values (it dynamic list if wish). public enum muppets { kermit, misspiggy, fozzie } ...then after defining own editor derived uitypeeditor (see msdn link below) class mymuppeteditor : uitypeeditor { ... } ...you attach control's property wish have drop-down so: [category("marquee")] [browsable(true)] [editorattribute(typeof(mymuppeteditor), typeof(system.drawing.design.uitypeeditor))]...

How do you split a integer by a digits and put into a list in java? -

this question has answer here: convert integer array of digits 15 answers how split binary number each individual digit , put java list front. for example: binary number: 01111101 after split like int[] binary = {0,1,1,1,1,1,0,1} after array flipped like int[] binaryflipped={1,0,1,1,1,1,1,0} i doing can convert binary number denary number in java. take flipped list each binary digit work out it's denary value. example of ruffle how it. (note: lengthoflist not write method there example of how work) for(x=0;lengthoflist(binary);x++){ sum=binary[x]*pow(2,x)+sum; } system.out.println(sum); assuming input int , not string : int number = 2; int[] binaryflipped = new int[8]; (int = 0; < binaryflipped.length; i++) { binaryflipped[i] = number % 2; number = number >> 1; }

java - How to search the ManagedEntity by regular expression in ViJava -

i'm using vijava 5.5-beta. example want find vms names contains "sql". search managedentities of "virtalmachine" type , iterate them. can tell me, there fast search method that? serviceinstance = new serviceinstance(new url(vcenter), constants.username, constants.password, true); folder rootfolder = serviceinstance.getrootfolder(); managedentity[] mes = new inventorynavigator(rootfolder).searchmanagedentities("virtualmachine"); (managedentity me : mes) { // ....if (name.contains("sql"))...... } what doing going best way it. there no way pass filter in server filtering happens server side, , method using property collector , gets "name" property efficient. just suggestion: yavijava open source drop in replacement vijava full support vsphere 6.0 have active community , many enhanced features vijava lacking.

php - How do I install PHP7 + MariaDB + nginx + Apache on Debian 7 Wheezy? -

i plan on keeping question updated set new vps up. have seen apache httpd setup , installation , https://httpd.apache.org/docs/2.2/dso.html , seems between pcre-config, mariadb, , lack of mysql_config, isn't working right. how install it?! install mariadb sudo apt-get update sudo apt-get install python-software-properties sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db sudo add-apt-repository 'deb http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/debian wheezy main' sudo apt-get update; sudo apt-get install mariadb-server uninstall php5 , apache2, building source. sudo apt-get remove php5 sudo apt-get remove php5-common sudo apt-get remove apache2-common sudo apt-get remove apache2 sudo apt-get remove apache2.2-bin download , prepare apache2 building mkdir apache cd apache wget -nd http://ftp.wayne.edu/apache//httpd/httpd-2.4.16.tar.gz tar xzf httpd-2.4.16.tar.gz wget -nd #brokenlink /apache//apr/apr-1.5.2.tar....

php - How can I give the opportunity to choose weather I want to overwrite an existing upload file or not? -

i searched everywhere find tutorial simple need have, until couldn't find answer , cannot script work. my script should following: user chooses file upload , click submit script checks if file exists if file not exist upload file destination if file exists ask user: "overwrite?" if user clicks "overwrite?" overwrite file index.php <form action="check.php" method="post" enctype="multipart/form-data"> <input type="file" name="file"> <button type="submit" value="upload">upload</button> </form> check.php <?php if(isset($_files['file'])) { $file = $_files['file']; $upload = $_files["file"]["tmp_name"]; $target_file = 'files/'.basename($_files["file"]["name"]); if (file_exists($target_file)) { echo "file exist"; echo "...

r - Writing latex matrices from Rmarkdown to word -

i'm migrating rmarkdown provided work msword users. when try write matrix using latex syntaxis inside rmarkdown using following code: $$a = \begin{bmatrix} 1 & 0 & 0 & 0\\ a_{21} & 1 & 0 & 0\\ a_{31} & a_{32} & 1 & 0\\ a_{41} & a_{42} & a_{43} & 1 \end{bmatrix}$$ i obtain in word matrix not formatted. if render pdf outpud works ok. i wonder if there way of improving msword matrix format. supose must done pandoc or pander not have expertise in area.

flash - How can I get the dynamic created movieclip size in createjs? -

i've created dynamic movieclip in flash canvas animation project(cc2015), couldn't size, return null. i've enabled multiframebounds in publish setting, still gets nothing. ps: if there's textfield in slide, can bounds of textfield, not whole size. code below: var root = this; root.name = "root"; (function(){ var maxmcnum = 4; var wrapper = new createjs.movieclip(); for(var i=1; i<=maxmcnum; i++){ eval("var slide"+ +"=new lib.mc"+ +"()"); eval("wrapper.addchild(slide"+ +")"); eval("slide"+ +".y = "+ (i-1) +"*slide"+ +".nominalbounds.height"); } root.addchild(wrapper); stage.on("click", function(){ //alert(wrapper.framebounds[wrapper.currentframe]); alert(wrapper.getbounds()); }); })(); this issue how flash exports single frame movieclip symbols. attempts optimize outpu...

c# - WPF DataGridTemplateColumn Width="*" Header too wide -

i trying assign width of each of datagridtemplatecolumn in datagrid using "*". <datagrid name="mapping" horizontalalignment="stretch" verticalalignment="stretch" margin="1" itemssource="{binding information.signals}" selectionmode="single" autogeneratecolumns="false" virtualizingpanel.isvirtualizing="true" fontsize="10" rowdetailsvisibilitymode="visiblewhenselected" borderthickness="1" enablecolumnvirtualization="true" enablerowvirtualization="true" scrollviewer.verticalscrollbarvisibility="auto" scrollviewer.isdeferredscrollingenabled="true" scrollviewer.cancontentscroll ="true" virtualizingpanel.virtualizationmode="recycling" canuseraddrows="true" canuserresizerows="false" canuserdelet...

audio - Soundpool or MediaPlayer ? - Android -

i confused of 2 classes. i have problem have 1000 of .wav files, depends on user load different sounds. as as, user can play many sounds in row, 4 sounds sequentially. so should use? soundpool better wav files not loads , keep files loaded. any recommendation situation? i have done on way using mediaplayer , @blipinsk, after read answer stackoverflow suggested him in comment above. my files bit larger soundpool can tolerate, as, want play many files sequentially. had implement myself using threads in soundpool. on contrary, ready in mediaplayer using oncompletionlistener. that, used mediaplayer. actually tried soundpool threads, works since not support large media files, used media player. i wrote class wrap mediaplayer run playlist, can add playlist , media player run them 1 after another. here class: import android.media.mediaplayer; import android.os.environment; import java.util.concurrent.executorservice; import java.util.concurrent.executors; impo...

mysql - understand table flow -

today got db dump understand table flow structure; uploaded dump on mysql. there 3 databases 1st db has 10 tables every table has primary key, , multi key 2nd db has 3 every table has primary key, , multi key 3rd db has 101 every table has primary key, , multi key but there no foreign key. how can understand table data flow . if don't have relationship defined can query tables find common columns/fields can used define relations. can try mysql workbench gives option reverse engineer database: http://dev.mysql.com/workbench/ it create database diagram selected tables based on relationships.

sql - JOIN two table to themselves and calculate a value based on the two -

using sql server 2012 i have 2 tables joined. [apxfirm].[advapp].[vmarketindexrate] [apxfirm].[advapp].[vmarketindex] joining these 2 able indexname, asofdate , rate however want calculate weighted sum of 2 indexes. s&p500 weighted .4 , dj average weighted .6. tried query below , result not blended rate. first indexes rate. for example if on given date sp = 100 , dj = 200 blend rate should 40 + 120 = 160 here query use apxfirm select 'blend' 'indexname', ir1.asofdate, sum(ir1.rate*.4+ir2.rate*.6) 'blendrate' [apxfirm].[advapp].[vmarketindexrate] ir1 inner join [apxfirm].[advapp].[vmarketindex] mi1 on ir1.indexid = mi1.indexid inner join [apxfirm].[advapp].[vmarketindexrate] ir2 on ir2.indexid = ir1.indexid , ir2.asofdate = ir1.asofdate inner join [apxfirm].[advapp].[vmarketindex] mi2 on ir2.indexid = ir1.indexid , ir2.asofdate = ir1.asofdate mi1.indexname = 'sp' , mi2.indexname = 'djind' ...

How can I simulate datas from Heart Rate sensor on Android Wear Emulator? -

as title, how can "simulate" values emulated heart rate sensor emulator? possible on official emulator or know alternative emulators this? no, can't, android emulator can't simulate sensors. android wear emulators can't too

ssh - Unable to login with Net_SSH2 in PHP -

i attempting ssh php can not login when include in other file created ssh.php , place "root/include" directory of server: include 'net/ssh2.php'; //initialize ssh object $ssh = new net_ssh2('my_linux_address','ssh_port'); //login linux host provided root username , password if (!$ssh->login('username', 'pass')) { exit('login failed'); } echo $ssh->exec("ls -al"); and execute calling browser: http://myserver/include/ssh.php work fine created second file: ssh2.php, place "root" directory ssh2.php file simply: include 'include/ssh.php'; finally run ssh2.php brower: http://myserver/ssh2.php -> "login failed"

android - Get sms address from intent data -

i need retrieve phone number different type of intents. cases intents as: intent smsintent = new intent(android.content.intent.action_view); smsintent.settype("vnd.android-dir/mms-sms"); smsintent.putextra("address","phonenumber"); smsintent.putextra("sms_body","message"); startactivity(smsintent); or: intent sms_intent = new intent(intent.action_sendto, uri.parse("smsto:xxxxxxxxxx"); sms_intent.putextra("sms_body", "this message!"); startactivity(sms_intent); when start new activity, bundle extras with: bundle extras = getintent().getextras(); if (extras != null) { //some code } specifically, first case intent explicitly bind key "address" do: extra_phonenumber = extras.getstring("address"); but i'm having trouble trying retrieve value after smsto: second intent case. i tried iterate through bundle extras with: for (string key : b...

java - Android: Repeat tasks in background. Does my approach is correct? -

i read several threads repeat asynchronous tasks in background, first used way: https://stackoverflow.com/a/6532298 reasons, seems after sometime (several hours), stopped. so, using way, don't know if way proceed: broadcastreceiver public class retrievedatataskbroadcast extends broadcastreceiver { @override public void onreceive(context context, intent intent) { sharedpreferences msharedpreferences = context.getsharedpreferences(my_pref, 0); int delayinms = msharedpreferences.getint("set_delay_refresh", 20)*60*1000; alarmmanager = (alarmmanager) context.getsystemservice(context.alarm_service); intent = new intent(context, retrievedataservice.class); pendingintent pi = pendingintent.getservice(context, 0, i, 0); am.cancel(pi); if (delayinms > 0) { am.setinexactrepeating(alarmmanager.elapsed_realtime_wakeup, systemclock.elapsedrealtime() + delayinms, ...

c++ - constexpr const vs constexpr variables? -

this question has answer here: difference between `constexpr` , `const` 5 answers it seems obvious constexpr implies const , common see: constexpr int foo = 42; // no const here however if write: constexpr char *const str = "foo"; then gcc spawn "warning: deprecated conversion string constant ‘char*’" if -wwrite-string flag passed. writing: constexpr const char *const str = "foo"; solves issue. so constexpr const , constexpr same? the issue in variable declaration, constexpr applies const -ness object declared; const on other hand can apply different type, depending on placement. thus constexpr const int = 3; constexpr int = 3; are equivalent; constexpr char* p = nullptr; constexpr char* const p = nullptr; are equivalent; both make p const pointer char . constexpr const char* p = nullptr; constexp...

Multiple or Malformed new lines error with PHP email -

i'm getting error warning: mail() multiple or malformed new lines found in additional header ... have tried giving $message variables different variable name, nothing works. there error coming last line posted in this.. mail($to,$subject,$message,$headers); full code $to = $approved_email; $subject = 'there new user request join '; $message = ' <html> <head> <title>new user request</title> </head> <body> <p>hi '.$approved_firstname.',</p><br> <p>your account has been accepted. have been added group. sign in, click link http://example.com . </p><br> <p>thank you,</p> <p>administration</p> </body> </html> '; $from = "user-requests@example.com"; $bcc = "user-requests-co...

Texturing backgrounds in Java Swing everywhere, not just in panels -

Image
i want make gui java swing/jpanel textured background. found few tutorials on topic texture within boundaries of control being applied to, this: that's easy enough. can't figure out how apply textures, (not same texture) elsewhere, on tabs title bar, background, scroll bars... everywhere that's still yellow. how do this? require making own 'look , feel'? components have variety of functions named paint___ control drawing of various parts. overrode these , tiled graphics.drawimage() in parts responsible background.

javascript - How to change elements(img's) position via radio buttons? -

i got image positioned in container , 3 radio buttons. add images appear on container main image when of radio buttons chosen. each of buttons have different positions of images shown when active. so far got that: <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default"> <input type="radio" id="q156" name="quality[25]" value="1" /> 1 </label> <label class="btn btn-default"> <input type="radio" id="q157" name="quality[25]" value="2" /> 2 </label> <label class="btn btn-default"> <input type="radio" id="q158" name="quality[25]" value="3" /> 3 </label> </div> </div> </div> <div class="col-md-8 col-fl"> <div id="img_box"> <...

javascript - Php variable from php file to php file using jquery -

i have small problem. need send php variable php file second php file using setinterval. dont know how can write php variable in jquery code. first.php <?php $phpvariable=1; ?> in javascript setinterval(function odswiez(id) { $('#chat').load('second.php?id=<here php variable how?>'); }, 3000); }); second.php <?php $w=$_get['id']; echo $w; ?> you need echo value $('#chat').load('second.php?id=<?php echo $variable ?>'); }, 3000); alternative be.. $('#chat').load('second.php?id=<?php echo "id-{$variable}" ?>'); }, 3000);

excel - VBA Sort not working -

i made vba code macro used excel file calculation. requires sorting excel sheet 2 columns 1 one. sorting first column not able sort other although code both same except column number. here code snippet sheet's calculation: sheets("restock clusters").select range("b1").select selection.pastespecial paste:=xlpastevaluesandnumberformats, operation:= _ xlnone, skipblanks:=false, transpose:=false lastrow = range("b:c").find("*", searchorder:=xlbyrows, searchdirection:=xlprevious).row range("a3").select range(selection, selection.end(xldown)).select selection.clearcontents range("a2").select selection.autofill destination:=range("a2:a" & lastrow) range("d3:f3").select range(selection, selection.end(xldown)).select selection.clearcontents range("d2:f2").select selection.autofill destination:=range("d2:f" & lastrow) range("c1").select application.cutcopymode = fal...

php - Codeigniter initialize() function not working -

i have moved codeigniter website development sever live server(vps). working in server. in live sever showing blank page nothing else neither error nor kind of warning. i have break code , controller file of system folder, , have echo code on every line , find system break $this->load->initialize(); function in main constructor. i have configured config file such database.php , config.php , route.php , still didn't find going wrong.

display nothing after sort array in php -

this question has answer here: sort multi-dimensional array value [duplicate] 5 answers i want sort in ascending order field available_price in array, how can sort. following code array ( [available_price] => 770 [category] => fashion design & theory [mrp] => 770 [source] => rediffbooks [title] => shoes [url] => http://books.rediff.com/book/five-point-someone/9781851775378 ) array ( [available_price] => 797 [mrp] => 938 [source] => uread-in [title] => shoes [url] => http://www.uread.com/search-books/9781851775378 ) ... on... you can use usort() sort array based on available_price : $array = array( array( available_price => 770, category => "fashion design & theory", mrp => 770, source => "rediffbooks", title...