Posts

Showing posts from April, 2014

android - MenuItem showing up on a bottom bar -

when inflate menu, of item showing in bottom bar, while others show in usual options menu of android 2. tried android:uioptions="none" in manifest, bottom bar disappear , options menu remain. what want add menu item action bar! here menu layout <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_support" android:icon="@drawable/icon_close" android:showasaction="always" android:title="@string/menu_support" android:visible="true"/> <item android:id="@+id/menu_feedback" android:orderincategory="100" android:showasaction="never" android:title="@string/menu_feedback"/> <item android:id="@+id/menu_settings" android:orderincategory="100" android:showasaction="never" android:title="@string/menu_settings"/>

emulation - android emulator root access -

i need execute c program in app adding executable android project , building .apk. try execute program in application this: process result = runtime.getruntime().exec("su"); string cmd = "program_name"; dataoutputstream dos = new dataoutputstream(result.getoutputstream()); datainputstreamdis = new datainputstream(result.getinputstream()); dos.writebytes(cmd + "\n"); dos.writebytes("exit\n"); dos.flush(); i know need root access installed superuser.apk didn't work. there possible way this? btw code not extended should give @ way program should executed i'm running emulator android 4.2.1 edit: checking root permission first with process suprocess = runtime.getruntime().exec("su"); dataoutputstream os = new dataoutputstream(suprocess.getoutputstream()); datainputstream osres = new datainputstream(suprocess.getinputstream()); if (null != os && nu

css - Can't align <div> to center -

i'm trying align 'div' attribute center of page (horizontally). problem whatever attributes i've used, 'div' continues aligned left. 'div' reffering to, page 'div' of webpage, inside 'html' , 'body' attributes. here's css code: #page{ margin-top:20px; margin-bottom:20px; margin-left: auto; margin-right:auto; border-color: black; border-style: solid; border-width: thin; overflow:auto; padding-bottom: 10px; padding-top: 0px; width:1200px; background-color:#ffffff; font-family:arial, helvetica, sans-serif; color:black; font-size:12px; height:700px; } and 'html', 'body' css code following: html,body { background-color:#ffffff; margin-left: auto; margin-right: auto; } note if remove "overflow" property, div aligned center of page (although, overlays menu on top of it) need "overflow" property automatic

c++ - Alglib: solving A * x = b in a least squares sense -

i have complicated algorithm requires fitting of quadric set of points. quadric given parametrization (u, v, f(u,v)) , f(u,v) = au^2+bv^2+cuv+du+ev+f . coefficients of f(u,v) function need found since have set of 6 constraints function should obey. problem set of constraints, although yielding problem a*x = b , not behaved guarantee unique solution. thus, cut short, i'd use alglib's facilities somehow either determine a 's pseudoinverse or directly find best fit x vector. apart computing svd, there more direct algorithm implemented in library can solve system in least squares sense (again, apart svd or using naive inv(transpose(a)*a)*transpose(a)*b formula general least squares problems not square matrix? found answer through careful documentation browsing: rmatrixsolvels( a, norows, nocols, b, singularvaluethreshold, info, solverreport, x) the documentation states the singular value threshold clamping threshold sets singular value svd decomposition

c# - IoC and Unity, where do I call the method that registers the types -

i try learn , use ioc unity in web services can't figure out how or should call method calls registertype methods. in pseudo code try clarify question. [webmethod] public void dosomething() { var obj = ioc.resolve<isomeinterface>(); obj.container.dosomething(); } interface isomeinterface { void dosomething(); } public class someclass : isomeinterface { pulic void dosomething() { //do here } } public static class ioc { public static iunitycontainer container = new unitycontainer(); public static void init() { container.registertype<isomeinterface, someclass>(); } } i can't figure out how or should call method init() in example above. try in project created following next steps. create new empty asp.net web application in visual studio 2012. add web service item , in .asmx.cs file webmethod. webservice called ajax in javascript. what need webservice call init method when starts? you can p

mysql - Replacing SHA1 with BCRYPT -

this question has answer here: how use bcrypt hashing passwords in php? 9 answers i have been looking replacing sha1 encryption of passwords possibly bcrypt or similar, , cant seem find step-by-step, easy follow tutorial implementing this. did quick tutorial on youtube produced following code: $username = 'myusername'; $password = 'pa55w0rd'; $str = substr($username, 0, 6); $salt = '$2a$12$ru8e3fsi9rskh3v2'.$str.'$'; $pass = crypt($password, $salt); echo $salt . '<br>' . $pass; and when run code in browser, output: $2a$12$ru8e3fsi9rskh3v2myuser$ $2a$12$ru8e3fsi9rskh3v2myuseemsot1badlfs/ncqhx5ag2q953uqp.tu question 1: am correct in assuming both strings generated user, , both strings required stored in, example, users table columns "salt" , "pass"? question 2: why part of username visib

html - rails alternative to enum and view integration -

rails doesn't offer enum types, need data member can accept 5 values. moreover, want integrated automatically rails forms helper: select_tag . what's right solution situation? p.s, i'd rather not use external plugins, if built-in , neat solution exist. i keep functionality close it's used possible. if values used single model, keep them in model, e.g., if users have possible types, , types, might like: class user < activerecord::base types = %w{guest, paid, admin} # plus validation on `type` field. # maybe plus setter override validates. end when need refer types elsewhere, allowable values in select: user::types there number of valuable tweaks around this, providing decorators make them "human readable" (capitalized, spaced, whatever) or metaprogramming methods allow things like: user.is_guest? # or... user.make_guest! # or... user.guest! i use own small gem functionality because it's case full-blown associ

How is dart VM's production mode faster when ignoring static types? Doesn't it need to do type inference at runtime? -

was watching introductory video - http://www.dartlang.org/dart-tips/dart-tips-ep-2.html , presenter memtioned: production mode gets speed boost ignoring static types, because can avoid many type checks. when static types introduced in actionscript 3.0, static types encouraged means increase execution speed. apparently dynamic types caused vm infer types during execution slow down, , static types, vm cruise through without additional work. why opposite in dart vm? thanks! i'm not sure actionscript i'm guessing in dart, types helpful tool programmers better understand program when shared other programmers (and dart editor provides lots of informative feedback using them). in checked mode (dart's other runtime) compiler slower because going check static types. then, when want use production runtime, skip step hiccup involving types should have been handled (by programmer) in checked mode.

utf 8 - Send utf-8 encoded strings in Android HTTP request -

i have made http-post inside android application. values sent strings app webserver. problem is, values not in utf-8 want them be. webserver has utf-8 encoding know there code inside app need change. see snippet below: private void sendpostrequest(string facebookid, string name, string email) { class sendpostreqasynctask extends asynctask<string, void, string>{ @override protected string doinbackground(string... bcs) { string bcfacebookid = bcs[0]; string bcname = bcs[1]; string bcemail = bcs[2]; httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("url"); basicnamevaluepair facebookidbasicnamevaluepair = new basicnamevaluepair("bcfacebookid", bcfacebookid); basicnamevaluepair namebasicnamevaluepair = new basicnamevaluepair("bcname", bcname); basicnam

javascript - How can i hide all the Series in highcharts at a time -

i want hide series's @ time , till use $.each hide series 1 one degrading performance want hide @ time..is there way..? had tried this.. $.each(series, function(index, series1) { series1.hide(); }); instead of .hide use .setvisible(false, false) . not trigger redraw after every hide operation. $(chart.series).each(function(){ //this.hide(); this.setvisible(false, false); }); chart.redraw(); see fiddle .

android - ADT 22 with actionbarsherlock -

i updated adt , when import actionbarsherlock project full of errors. before update working fine. how can fix this? right click actionbarsherlock project. go menu properties , "order , export" , check 'android private libraries' checkbox. click 'apply'. rebuild actionbarsherlock. make same project. rebuild project. enjoy.

multithreading - C# : What Will Be The Greatest? Multiple Task or Single for One Job? -

i have code: public async virtual void start(ipaddress ip, int port) { //start listening proccess listener = new tcplistener(ip, port); listener.start(); islistening = true; await task.run(async () => { while (islistening) { if (listener.pending()) { tcpclient client = await listener.accepttcpclientasync(); skyfilterclient sklient = new skyfilterclient(client); byte command = sklient.reader.readbyte(); if (command == (byte) skyfiltercommand.authenticate) { sklient = await authenticate(sklient); } else if(command == (byte)skyfiltercommand.register) { sklient = await register(sklient);

Reading data file with varying number of columns python -

i have data-file first 8 lines of this. (after substituting actual values letters clarity of question) a,b,c d e,f g,h i,j,k l m,n o,p these represent data transformers in electric network. first 4 lines information transformer 1, next 4 transformer 2 , on. the variables a-p can either integers, floating-point numbers or strings i need write script in python that instead of data 1 transformer being spread onto 4 lines, should on 1 line. more precisely, above 2 lines converted a,b,c,d,e,f,g,h i,j,k,l,m,n,o,p and write data-file. how do this? use grouper recipe itertools from itertools import izip_longest def grouper(iterable, n, fillvalue=none): "collect data fixed-length chunks or blocks" # grouper('abcdefg', 3, 'x') --> abc def gxx args = [iter(iterable)] * n return izip_longest(fillvalue=fillvalue, *args) open('z.t') f: d = grouper(f, 4) x in d:

database - Pull data from multiple records into one row -

Image
i want pull out data multiple records , insert them different fields of single record in table. work doing requires me pull cw_cat_total field(which sum of assignments corresponding particular category of assignment , put appropriate data fields of table. the cw_cat_total field calculated self-joined relationship. not figure out how individual component different columns of table in second picture. can filemaker programmers me out here? update: my database contains more tables. quite complicated (from point of view). below er graph. what try achieve pull component scores different columns of results table student's assignment score may computed different weightings different category. coursework score, student scores examination @ each quarter(term), displayed in reports table. as side note, teacher of school (not developer). hence, schema may not industry practiced. did read database normalisation , think understand (which may not, i'm not sure). tried

arrays - Javascript code-- What's wrong with function ToppingsWanted()? -

i'm having trouble part of javascript assignment. involves using couple of arrays: 1 elements, 1 without seen below. i've included code necessary arrays work you're not left in dark details , explain go. below 2 arrays. array 'toppings' filled elements appear in list box later on. array below it, 'selectedtoppings' empty array hold elements user selects list box. var toppings = [ "sausage" , "pepperoni" , "extra cheese" , "onions" , "black olives" , "anchovies" , "pineapple" , "canadian bacon" , "ground beef" ]; var selectedtoppings = []; the function below output of program. when first wrote it, didn't display because none of function calls right. i've been doing putting semi-colon after each function call , making sure appropriate function working correctly before moving on next one. right i'm stuck on function toppingswanted(). you'll notic

php - Cutting text in between destroys the design -

i'm having issue website. count 150 words , cut displaying intro text on website produces issue. when have in text: <div> ////text text text text text//// ----> reach 150 words here <------ ////text text text text text//// </div> it print in front-page: <div> ////text text text text text//// ----> reach 150 words here <------ and unclosed <div> tag destroys design expected. how can overcome issue? can proccess unclosed tags , close them in end? use php's strip_tags remove div copy, add in afterwards. for example; <?php $html = '<div>content goes here</div>'; $stripped = strip_tags($html); $excerpt_pos = strpos(' ', $stripped, 150); ?> <div><?php echo substr($stripped, 0, $excerpt_pos); ?></div>

vb.net - How to execute code in visual basic weekly -

i wanting know if example wanted ask user update software every week example if today friday next friday msgbox pop saying software out of date up-date? is possible????? yes possible. there many ways this. one way might check current date , if friday prompt update. once have prompted keep flag know prompted , friday. once saturday hits can clear asked flag , wait until friday again. method require program running time. store asked flag in configuration file (.ini example) when program updated reopened can check .ini flag no longer available since program updated. another way, many programs , run updater service in background , same thing above except updater updates other program, not (unless update required that). you run updater via windows task scheduler , set run on fridays. way can avoid need keep program running of time.

asp.net mvc 4 - So we've got MEF working with MVC4, how about the convention based model? -

after digging figured it's possible use mef di in mvc4, below link gives couple of examples: how integrate mef asp.net mvc 4 , asp.net web api they work fine, i'm wondering how eliminate need of explicitly "import" , "export" obvious controllers in mvc 4 app? there suggestions on web, top programming minds' blogs. had little success in replicating success stories. name couple: http://mef.codeplex.com/wikipage?title=standalone%20web%20api%20dependency%20resolver%20using%20microsoft.composition&referringtitle=documentation http://blog.longle.net/2013/05/17/generically-implementing-the-unit-of-work-repository-pattern-with-entity-framework-in-mvc-simplifying-entity-graphs-part-2-mvc-4-di-ioc-with-mef-attributeless-conventions/ any suggestions please? the version ships .net 4.0 has no built in way this. think mef 2 ships 4.5 , has more options including naming conventions . there version can download , use .net 4.0 somewhere on n

c++ - Template class constructor not working -

from other question here copying std container frm arbitrary source object managed template working under msvc. unfortunately compiler crashes newest addtion of adding constructor accept kind of std containers, , real project in gcc anyway. when use template in gcc, several errors don't know how resolve. template <class t> class readonlyiterator { public: template <typename v, typename u> struct is_same { enum { value = 0 }; }; template <typename v> struct is_same<v, v> { enum { value = 1 }; }; template <bool, typename> struct enable_if {}; template <typename v> struct enable_if<true, v> { typedef v type; }; template <typename container> typename enable_if< is_same<t, typename container::value_type>::value, readonlyiterator<t>&>::type operator= (const container &v) { return *this; } temp

nsmutabledictionary - What does this Objective-C code snippet mean, and what document details it? -

ok, i've done searches in xcode, on apple's developer's site, , on google, , have downloaded , searched pdf versions of key-value coding programming guide , collections programming topics, cannot find syntax listed anywhere. second line of following snippet do, , can find details on it? nsmutabledictionary *change = [nsmutabledictionary new]; change[@(somevariable)] = @(someothervariable); i don't know if i'm having brain fart, or if i've never seen before, bugs me can't find documentation it. there 2 things going on here: dictionary (and array) subscripting change[key] this new syntactic sugar for [change objectforkey:key] or, if used lvalue, syntactic sugar for [change setobject:value forkey:key] for what's going on here ( objectforkeyedsubscript: , setobject:forkeyedsubscript: ) see http://www.apeth.com/iosbook/ch10.html#_nsdictionary_and_nsmutabledictionary number literals @(somevariable) this new compiler direc

c# - Generate Database from model creates empty edmx sql script -

i playing around code first, have created entities , trying generate database model. have gone through wizard, connected server, selected name of new database , exited. edmx.sql script automatically generated me run, except it's empty when open , massively slows down vs 2010 point have kill process. when in server database has been created (as expected since wizard asked me create it) there not tables in (obviously because haven't run script). any ideas going wrong here? i found out caused this. apparently sp1 upgrade on vs2010 torches sort of thing. following files need re-installed manually dvd: dacframework_enu.msi dacprojectsystemsetup_enu.msi tsqllanguageservice_enu.msi now can see full script, ran it, sorted!

java - Catch action events from a JPanel component in a JFrame parent window -

how catch action events jpanel component in jframe parent window in java swing? i'm having hard time trying make custom component in swing. the idea got making custom jpanel in swing contains jbutton , , catching action events on buttons in jframe parent window. i implement method addactionlistener() custom jpanel if button. do have extend jcomponent instead of jpanel ? i appreciate , time. package pizzeria.interfaz; import java.awt.borderlayout; import java.awt.component; import java.awt.container; import java.awt.dimension; import java.awt.toolkit; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.box; import javax.swing.boxlayout; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.event.ancestorevent; import javax.swing.event.ancestorlistener; public class aplicacioncliente extends jframe{ public aplicacioncliente() { container contentpane = getcontentpane(); contentpane

vb.net save in Word 2010 -

platform: windows , microsoft visual basic 2010 express the problem: have word template made in word 2007. when application run in machine word 2010, saveas-command doesn't work. works fine open template , add data , photo bookmarks in template. here statement doesn't work( vpath contains path , filename.): odoc.saveas(vpath.tostring) i have tried different solution nothing works: odoc.saveas(vpath.tostring, wdsaveformat.wdformatdocument) odoc.saveas(vpath.tostring, 17) ' wdsaveformat.wdformatpdf odoc.saveas(vpath.tostring, 6) ' wdsaveformat.wdformatrtf references: microsoft office 12.0 object library microsoft word 12.0 object library import statements: imports microsoft.office.interop imports microsoft.office.interop.word i using office 14 , downloaded 2007 template. following code works me. imports microsoft.office.interop .... dim objapp word.application dim objdoc word.document objapp = new word.application() objdoc = obj

sorting - Coq string sort lemmas -

i have string sort function defined below , want prove lemma sort_str_list_same below. not coq expert, tried solve using induction, not solve it. please me solving it. thanks, require import ascii. require import string. notation "x :: l" := (cons x l) (at level 60, right associativity). notation "[ ]" := nil. notation "[ x , .. , y ]" := (cons x .. (cons y nil) ..). fixpoint ble_nat (n m : nat) : bool := match n | o => true | s n' => match m | o => false | s m' => ble_nat n' m' end end. definition ascii_eqb (a a': ascii) : bool := if ascii_dec a' true else false. (** true if s1 <= s2; s1 before/same s2 in alphabetical order *) fixpoint str_le_gt_dec (s1 s2 : string.string) : bool := match s1, s2 | emptystring, emptystring => true | string b, string a' b' => if ascii_eqb a' str_le_gt_dec b b' else if ble_nat (nat_of_ascii a) (nat

python - numpy array slicing unxpected results -

i don't understand behavior below. numpy arrays can accessed through indexing, [:,1] should equivalent [:][1], or thought. explain why not case? >>> = np.array([[1, 2, 3], [4, 5, 6]]) >>> a[:,1] array([2, 5]) >>> a[:][1] array([4, 5, 6]) thanks! those 2 forms of indexing not same. should use [i, j] , not [i][j] . both work, first faster (see this question ). using 2 indices [i][j] 2 operations. first index , second on result of first operation. [:] returns entire array, first 1 equivalent array[1] . since 1 index passed, assumed refer first dimension (rows), means "get row 1". using 1 compound index [i, j] single operation uses both indexing conditions @ once, array[:, 1] returns "all rows, column 1".

php - How to display XDebug errors only to my IP address? -

i'm in non-ideal situation have debug website live website running php5.4 on lamp stack. after enabling xdebug in php.ini , setting display_errors true, nicely formatter html output bugs. however, i'd person able see these bugs. i understand there sort of extension ides allow that, i'm bit confused whole thing. i looked xdebug.remote_host couldn't work. is there way make errors show requests coming ip address? thanks! the main thing want has nothing xdebug... turn display_errors off. sounds counter-intuitive display_errors configure whether or not errors should sent stdout or stderr php. if turn off display_errors , can configure php log them instead. then, ssh box , tail log file while track down problem.

android - App keeps stopping when i press a button -

i have save button loads dialog interface asking save name. when click done it's supposed created sharedpreferences strings in it, instead says unfortunately program has stopped. how can fix this? oh , want put out there i'm new android. i'm learning of stuff make app. public void save(view view){ layoutinflater li = layoutinflater.from(calculate.this); view pview = li.inflate(r.layout.prompt, null); alertdialog.builder adb = new alertdialog.builder(calculate.this); adb.setview(pview); final edittext name = (edittext) findviewbyid(r.id.etprompt); adb.setcancelable(false); adb.setpositivebutton("done", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { n = name.gettext().tostring(); try { details = getsharedpreferences(n,mode_private); editor = details.edit(); editor.putstring("eb

How to print a vector in plain text in QT -

int b=0; qvector<int> z(5); for(int i=0;i<5;i++) z.push_back(i); for(int i=0;i<z.size();i++) { b=z.at(i); qstring str=qstring::number(b); ui->mbox->settext(str); } i wrote code print vector in plain text print first row want print whole vector not:mbox plain textedit now there problem qvector<int> z(5); for(int i=0;i<5;i++) z.push_back(i); qstring str; (int = 0; < z.size(); ++i) { if (i > 0) str += " "; str += qstring::number(z[i]); } ui->mbox->settext(str); } in first loop when wrote z.size() qt has caught exception thrown event handler. throwing exceptions event handler not supported in qt. must reimplement qapplication::notify() , catch exceptions there. and in second when wrote z.size 10 output size of z 5 can see .what wrog first 5 output 0 , rest normal

php - Add list item every time i click submit -

i want script echo text form div tag every time click submit button. i able in no time want text still displayed in div when submit another. want every new submitted text create list. adding previous list. may got database know every time click submit current text been submitted. example of such script <?php $text = $_post['text']; ?> <html> <div> <?php echo "<ul>"; echo "<li>".$text."</li>"; echo "</ul>"; ?> </div> <form method="post" action="<?php echo $_server['php_self'];?>"> name: <input type="text" name="text" /><br/> <input type="submit" value="submit"/> </form> </html> i want adding entries <li> list every time click submit. i'm happy you're having fun. here's quick "starter 10" :) <?php $items = array(); if(&

actionscript 3 - ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller -

i trying rid of object it's throwing error not sure problem. the error getting: argumenterror: error #2025: supplied displayobject must child of caller. @ flash.display::displayobjectcontainer/removechild() @ schoolbook_final_fla::maintimeline/garbage_cl_2()[schoolbook_final_fla.maintimeline::frame2:98] @ function/schoolbook_final_fla:maintimeline/choice_play_ev/schoolbook_final_fla:play_target()[schoolbook_final_fla.maintimeline::frame2:81] my code: import flash.display.sprite; import flash.ui.mouse; import flash.events.event; var week_pick:weekday_choice = new weekday_choice (); var weekdayarray: array = new array (); var monday:mon_d_but = new mon_d_but (); var tuesday:tues_d_but = new tues_d_but (); var wednesday:wed_d_but = new wed_d_but (); var thursday:thurs_d_but = new thurs_d_but (); var friday:fri_d_but = new fri_d_but (); var choice_play: array = new array (); choice_play.push(monday, tuesday, wednesday, thursday, friday); //adding week pick add

substring - PHP - variable using substr() cant be extended -

i'm creating account-system. user gives first name & last name. create record in database first letter of first name , full last name. to first letter in code: $first_letter = substr($voornaam, 0, 1); echo "eerste letter-variabele: "; var_dump($first_letter); echo "<br/>"; $gebruiker = $first_letter; echo "overgezet in gebruiker-variabele: "; var_dump($gebruiker); echo "<br/>"; the var_dumps return want, string containing first letter of given first name. to create 2nd part of username do: $gebruiker += $achternaam; echo "+achternaam: "; var_dump($gebruiker); echo "<br/>"; this returns int(0) (probably boolean saying false). have searched , found nothing. assume has sub_str() still functioning (?) please show me proper way solve problem (object-oriented welcome). use .= in stead of += , work. + adds (as in math) ... , . used concatenation. now make own huiswerk... ;)

java - primefaces creating a dynamic dashboard -

following example @ http://www.wobblycogs.co.uk/index.php/computing/jee/49-dynamic-dashboard-with-primefaces im trying create dynamic dashboard. copying code works 100% perfeclty, im trying use own implementation. when load index page dosnt show panels or dashboard @ all. when navigate differet page, , come elements appear! i have no idea why dashboard not displayed on initial page load. im working jboss 5.1, ejb 3.0, jsf 2.0 , primefaces 3.4. this top of controller class: @model @viewcontroller(viewid = "/pages/index.xhtml") public class monitorcontroller implements serializable, viewinitializer, viewfinalizer { @inject private transient monitorservice monitorservice; @inject private transient monitoruserservice monitoruserservice; @inject private transient monitorview view; @inject private transient conversation conversation; @override public void initializeview() { if (conversation.istransient()) { conversation.settimeout(1800000); con

c# - Access foreign key in LINQ Where? -

i have entity called driver , list of drivers, call: list<driver> drivers = _context.drivers.select(x=>x); driver can have details , foreign key between them, can't do: list<driver> drivers = _context.where(x=>x.id == id && x.detail.id == detailid); how can foreign key properties in clause? i using entity framework 3.5 . the statement works, although not sure (x=>x) necessary, haven't compiled it: list<driver> drivers = _context.drivers.select(x=>x); the problem driver entity has foreign relation detail , driver has detailid column foreign key detail table , since using entity framework 3.5, can't driver.detail.id or driver.detailid . don't come up. did read ef 3.5 not including foreign keys , having choice in ef 4 , on ef 3.5 now. i did try .include("detail") , gave me exception detail not being navigation property. use include method in case. ref msdn

jpa - advantage of select-before-update in hibernate -

to avoid update statement while reattaching object through setting select-before-update= “true”. if set, hibernates tries determine whether update needed, executing select statement. advantage of such feature, cause after hitting db either through select or through update.

big o - time complexity of the following algorithm -

suppose node (in bst) defined follows (ignore setters/getters/inits). class node { node parent; node leftchild; node rightchild; int value; // ... other stuff } given reference node in bst (called startnode ) , node (called target ), 1 check whether tree containing startnode has node value equal target.value . i have 2 algorithms this: algorithm #1: - `startnode`, trace way root node (using `node.parent` reference) : o(n) - root node, regular binary search target : o(log(n)) t(n) = o(log(n) + n) algorithm #2: perform dfs (psuedo-code only) current_node = startnode while root has not been reached go 1 level current_node perform binary-search node downward (excluding branch go up) what time-complexity of algorithm? the naive answer o(n * log(n)) , n while loop, there @ n nodes, , log(n) binary-search. obviously, way-overestimating! the best (partial) answer come was: suppose each sub-branch has m_i nodes , there

c++ - termios Arduino read/write failing -

hello having trouble trying program arduino take commands c++ program. using termios connect arduino. arduino in gateway mode (basically not executing code waiting input program interact hardware connect it). my termios set this: serialhandler::serialhandler(char* fpath, int brate) { filepath = fpath; baudrate = 0; //open file, file of type int file = open(filepath, o_rdwr | o_noctty); if(file<0) //if there error opening file { perror(filepath); exit(-1); } //save old port settings tcgetattr(file, &oldtio); bzero(&newtio, sizeof(newtio)); //now load baudrate getbaudrate(brate, baudrate); newtio.c_cflag = baudrate | crtscts | cs8 | clocal | cread; //ignpar ignore bits parity errors //icrnl map cr nl ..may have change raw input processing newtio.c_iflag = ignpar; //raw output newtio.c_oflag = 0; //icanon - enable canonical input //disables echo functionality, doesnt send signals calling program newtio.c_lflag = icanon; //clean , activate port tcflush(file

php - Magento - migrating orders from 1.4 to 1.7 manually from DB -

ok i’m in trouble, viewed dozens of topics on stackoverflow , magento forum , still have no solution. happened migrating magento 1.4.2 latest 1.7. made backup of everything, did upgrade overnight , perfect. 1,5 days later notices 1 plugin not working - it’s not not working charging people wrong price! biig trouble. try fix it’s nightmare, it’s middle of day , quick decision - bring backup. again backup current 1.7 db , swap systems 1.4.2. backup there live, we’re working in background, fix , 2 days later put 1.7 happily live without troubles. here’s trick! 2 days orders landed in backup 1.4.2 db. have 1.7 , 100 orders missing. tried millions of solutions out there they’re migrating db. trick have on 10k orders , need transfer 100 (with connected users of course). any clues? ideas? found soap api not sure how deal that. appreciated. you can use soap api. create script this: $client = new soapclient('http://magentohost/api/soap/?wsdl'); $session = $client-&

actionscript 3 - AS3 FDT How to instantiate an fla asset with a custom class? -

i jsut started working @ company uses flash builder, using fdt @ moment. hvaing trouble getting fdt instantiate sprite in fla project along custom class goes it. also, reasont people here instantiating sprite wrong: var mc:movieclip = new moviclip() and right: var _someclass:class = getdfinitionbyname("linkage") class; var _mc:sprite = new _someclass() sprite i cannot figure out how instantiate movieclip in fla , class @ same time method. is asset 'sprite' or 'movieclip'? although can create sprite assets in flash professional (fla) it's asset movieclip. please confirm this. alao, 'movieclip' 'sprite' since inherits 'sprite'. that way of linking quite verbose , not typical. linking asset @ compile or runtime? most people export assets swc. if want asset @ runtime it's different thing bit... look @ post.

CSS: new line above first line? -

in horizontal menu (done ul + floated li) li elements shown in next line (below first line) if many fit in current width. example: first | second | third fourth | fifth that´s normal. how can accomplish have next line above first one? example: fourth | fifth first | second | third since doing responsive layout, cannot define order statically should happen automatically in case window width small fit items in 1 row. thanks in advance, dirk if browser compatibility isn't absolute requirement, try flex : ul { display:flex; display:-ms-flexbox; flex-flow: row wrap-reverse; -ms-flex-flow: row wrap-reverse; } the above work in ie10. you'll have -moz- , -webkit- versions, keep changing on me...

scala - Pattern match on manifest instances of sealed class -

given classes sealed abstract class case class b(param: string) extends case class c(param: int) extends trait z {} class z1 extends z {} class z2 extends z {} def zfor[t <: : manifest]: option[z] = { val z = manifest[t].erasure if (z == classof[b]) { some(new z1) } else if (z == classof[c]) { some(new z2) } else { none } } i think problem pattern matching here impossibility build pattern matching table in bytecode. there workaround on problem? may can use int generated in manifest compiler? the way you've written there isn't robust if have more complicated class hierarchy since if have class d <: c , classof[d] != classof[c] . don't want pattern-match anyway. could; can't call classof[x] in middle of pattern-match, can def zfor[t <: : manifest]: option[z] = { val classb = classof[b] val classc = classof[c] manifest[t].erasure match { case classb => some(new z1) case classc => some(new z2)

scala - type inference and string literals, how to do it? -

how compile? code object playground2 { trait client[s,a] { def wrap[s,a](v: a): (s,a) } class testclient extends client[string, int] { override def wrap[string,int](v: int): (string, int) = ("cache 2.00", v) } } error type mismatch; found : java.lang.string("cache 2.00") required: string here's version of code compiles: object playground2 { trait client[s,a] { def wrap(v: a): (s,a) } class testclient extends client[string, int] { override def wrap(v: int) = ("cache 2.00", v) } } you duplicated types again in wrap function , did not need defined on trait itself.

backbone.js - Manage global Backbone events while writing Qunit unit tests -

i writing unit tests backbone app. tests trigger events, causing interference among different tests. here tests test('user setting company should update departmentslists url', function() { var acme = new company({ id:274, name: "acme solutions" }); var companies = new companylist; var departments = new departmentlist; new companyselectorview({ el: '#company-input', collection: companies }); events.trigger('userset:company', acme); equal(_.result(departments, 'url'), 'http://'+document.location.host+'/data/companies/274/departments'); }); asynctest('user setting company should retrieve companys departments', function() { var acme = new company({ id:274, name: "acme solutions" }); var companies = new companylist; var departments = new departmentlist; new companyselectorview({ el: '#company-input', collection: companies }); events.trigger('userset

C Programming. Comparing an array's contents. -

i have array result of program's input: //1. int i, numberofoccurances; for(i = 0; < numofoccurrances; i++) { printf("%d",printoccurrances[i]); } and example output: 121 now want compare array can print additional statement, example: //2. if (printoccurrances == 121) { printf("this means blah"); } else if (printoccurrances == 232) { printf("this means else"); } //what type of variable should set , how should set @ point 1? //what type of string statement should have @ point 2. thanks assistance. make comparison function , use compound literals @ call site: #include <stdbool.h> bool int_arr_cmp_n(int const * a, int const * b, size_t len) { while (len--) if (*a++ != *b++) return false; return true; } usage: if (int_arr_cmp_n(printoccurrances, (int[]){1,2,1}, 3)) { /* ... */ }

python - Doing threading with sqlalchemy properly? -

i have multi threaded application treads work on objects fetched using sqlalchemy. objects put in thread queue threads poll from. in main thread doing this: feeds = db_session.query(feed).filter(feed.last_checked <= int(update_time)).all() feed in feeds: self.feed_q.put(feed) and in threads updates feed objects, , keep getting these exceptions when doing updates: programmingerror: (programmingerror) (2014, "commands out of sync; can't run command now") statementerror: can't reconnect until invalid transaction rolled (original cause: invalidrequesterror: can't reconnect until invalid transaction rolled back) i understand has todo threads sharing same db session, don't know how fix this. each thread should have separate database session. you're creating object that's stored in db_session somewhere, perhaps this: db_session = session() essentially, need each thread have own db_session .

Chaining SSH commands via PHP -

i running ssh2 command via php , trying chain commands answer password prompts bash script run. wget url-to-bash-script bash name-of-file.sh after prompt for mysql password: and: retype password: it proceed install packages lamp i have tried no luck; $ssh->exec( "wget url;bash installlamp.sh; password; password"); thanks! what might want use expect here examples on how use it: http://www.thegeekstuff.com/2010/10/expect-examples/

lisp - What Racket function can I use to insert a value into an arbitrary position within a list? -

i know trivial implement, want racket live it's "batteries included" promise. looking function works this: > (define (between lst item spot) (append (take lst spot) (cons item (drop lst spot)))) > (between '(1 3) 2 1) '(1 2 3) does racket include such builtin? here implementation based on stephen chang's comment (i swapped argument order little , renamed function too): (define (insert-at lst pos x) (define-values (before after) (split-at lst pos)) (append before (cons x after)))

Why can getCheckedItemCount() run correctly when I set android:minSdkVersion="10"? -

when set android:minsdkversion="8", following code can't run,and system prompt me set android:minsdkversion="11" set android:minsdkversion="10", code can run correctly, why? thanks! lv.setonitemclicklistener(new onitemclicklistener(){ @override public void onitemclick(adapterview<?> arg0, view arg1, int arg2,long arg3) { selectedandtotal.settext(lv.getcheckeditemcount()+"/"+ lv.getcount()); }}); that method guaranteed work when run on api level 11+ device. normally, method call crash on api level 10 or lower device, throwing verifyerror . if find seems work on api level 10 or lower, indicates getcheckeditemcount() existed on abslistview prior api level 11, had been excluded android sdk (via @hide attribute in android source code). relying upon such methods risky, insofar there no guarantee abslistview on pre-api level 11 devices have method, or method behave on newer devices.

javascript - Isotope.js sort by href? -

i'm building wordpress site , using isotope.js thumbnails on home page, these thumbnails link posts, i'm trying button on click toggle between masonry layout , layout groups these thumbnails href, possible? thank in advance. here's html: <a class="thumbnail large-img" href="http://wordpresssite.com/post/post-title/"> <img width="624" height="352" src="http://wordpresssite.com/wp-content/uploads/2013/03/postimage.jpg" class="attachment-full"/> </a> <a class="thumbnail med-img" href="http://wordpresssite.com/post/post-title/"> <img width="500" height="357" src="http://wordpresssite.com/wp-content/uploads/2013/03/postimage2.jpg" class="attachment-full"/> </a> <a class="thumbnail med-img" href="http://wordpresssite.com/post/another-post-title/"> <img width="500" height=&q

javascript - issue with carousel image gallery -

i making simple carousel image gallery. have 2 images , gallery loop first image after last , cannot figure out how functionality working plus previous , next button have stopped working reason. jq/js skills lacking , appreciate working. here jsfiddle of code [1]: http://jsfiddle.net/jsavage/kgaxa/39/ $(document).ready(function () { if (jquery("#gallery").length) { // declare variables var totalimages = jquery("#gallery > li").length, imagewidth = jquery("#gallery > li:first").outerwidth(true), totalwidth = imagewidth * totalimages, visibleimages = math.round(jquery("#gallery-wrapper").width() / imagewidth), visiblewidth = visibleimages * imagewidth, stopposition = (visiblewidth - totalwidth); jquery("#gallery").width(totalwidth); jquery("#gallery-prev").click(function () { if (jquery("#gallery&quo

jquery - Trying to hide the document until it's updated with JavaScript -

this ready handling: $(document).ready(function() { $(document).hide(); $('.foo').each(function(elem, i) { $(elem).text('so long , fish'); }); $(document).show(); }}; what i'm trying hiding document until ready on terms, seems show() function doesn't wait elements iteration. by way, tried changing show() , hide() css('display', 'hide') , css('display', 'block') still, can text changing in eyes. how make sure code ran before calling show()? let's suppose fix hiding body or container element. won't trick, , here's why: what happens during time after document (mostly) loaded before hide document? that's right, document may displayed during time despite best efforts. so instead use css class hides, say, body without javascript intervention. example: <!doctype html> <html> <head> <title>test</title> <style

php - Complicated MySQL Query for MLM Business -

i've got confused @ moment. i've got 1 database developed mlm (multi level marketing) company . so, there's 1 members database.. each member have unique id called membercode.. , members have members under them.. every member have 3 members under him/her.. , 3 members can have same under them.. members added in same database table named "tbmembers" , each member there's "parentid" add member's membercode under whome member is?.. right? now question .. want sql query can go under , under.. 'john doe' having 3 members under him named 'suzan' , 'ellie' , 'smith'. , 'suzan' having 3 members under her.. , same ellie . , example.. 'john doe' having 300 members in down line? , gets paid member adds 3 members under downline, member adds 3 members paid , upline members paid amount of money. can downline level number of member under 1 particular member?? , can calculate earnings based on 3 members joi