Posts

Showing posts from May, 2013

javascript - Amcharts Pie Chart show country only on hover -

in demo http://www.amcharts.com/demos/simple-pie-chart/#theme-light shows country , percent both @ first view , on hover. percent shown @ first view, , show country: percent on hover. is possible? many help! you can use chart property labeltext specify being shown slice labels. to show percents, need set "[[percents]]%" . var chart = amcharts.makechart("chartdiv", { "type": "pie", "theme": "light", "dataprovider": [{ "country": "lithuania", "litres": 501.9 }, { "country": "czech republic", "litres": 301.9 }, { "country": "ireland", "litres": 201.1 }, { "country": "germany", "litres": 165.8 }, { "country": "australia", "litres": 139.9 }, { "country": "a...

java - How to sort a linked list of Polynomials by degree? -

currently i've written method adds 2 polynomials together. poly1 , poly2. logic of method follows, first adds matching degree terms poly1 , poly2, adds non-matching terms poly1, , adds non-matching terms poly2. because of this, terms out of order. polynomial answer = new polynomial(); (node firstpoly = poly; firstpoly != null; firstpoly = firstpoly.next){ boolean polyadded = false; (node secondpoly = p.poly; secondpoly != null; secondpoly = secondpoly.next){ if (firstpoly.term.degree == secondpoly.term.degree){ answer = addtorear(answer, (firstpoly.term.coeff + secondpoly.term.coeff), firstpoly.term.degree, null); if (answer.poly.term.coeff == 0){ answer.poly = null; } polyadded = true; } } if (polyadded == false){ answer = addtorear(answer, firstpoly.term.coeff, firstpoly.term.degree, null); ...

How does the LLVM InstVisitor traverse IR? -

i have working instvisitor, answer prior question . llvm make these instvisitors traverse ir using dfs or bfs? dfs. check source here (relevant lines 88 108): http://llvm.org/docs/doxygen/html/instvisitor_8h_source.html#l00088

java - ClassCastException when reading OUT parameters from EclipseLink PLSQLStoredProcedureCall -

i need call oracle stored procedure using eclipselink (2.3.1.v20111018-r10243). procedure have in , out parameters, , need read out parameter. i found this example , code pretty copy of example, instead of receiving list api, throwing exception because value integer of value "1", , can't figure out why. the procedure being called properly, in parameter ok, code fails read response "should" list according example. import java.util.arraylist; import java.util.list; import javax.ejb.stateless; import javax.persistence.entitymanager; import javax.persistence.persistencecontext; import org.eclipse.persistence.jpa.jpaentitymanager; import org.eclipse.persistence.platform.database.jdbc.jdbctypes; import org.eclipse.persistence.platform.database.oracle.plsql.oracleplsqltypes; import org.eclipse.persistence.platform.database.oracle.plsql.plsqlstoredprocedurecall; import org.eclipse.persistence.queries.datamodifyquery; import org.eclipse.persistence.sessions....

python classes defined dynamically with `type` disappear -

i'm using python's type dynamically declare classes. like: class parentclass(object): pass class_name in ['a', 'b', 'c', 'd', 'e']: type(class_name, (parentclass,), {}) print('subclasses of parentclass:', parentclass.__subclasses__()) usually, print line prints 1, 2, 3, 4, , 5 subclasses. but sometimes, prints 1, 2, 3, 1, 2 subclasses: classes d , e . , parentclass.__subclasses__() anywhere else array [d, e] . and weirdest part changing other, unrelated code in other places in project affects it. is possible that, because i'm not assigning classes name, they're being garbage collected? , that's why parentclass.__subclasses__() can't find class objects anymore? is possible that, because i'm not assigning classes name, they're being garbage collected? , that's why parentclass.__subclasses__() can't find class objects anymore? yes, it. see the documen...

python - Elif unexpected indentation when trying to print out single line with total count -

i have created simple function counts number of occurrences in list, however, cannot 1 single line print out total number of occurrences because elif part of if statement creates unexpected indentation error in code. i'm using elif part check whether code entered part of list or not. so example, instead of getting: 2 entries(s) uk found i get: 1 entries(s) uk found 2 entries(s) uk found can please me out suggestion on how correct this? lot ! ps: third week coding, please take easy on me guys. def mylist(list): countoccurrence = 0 code in list: if code == countrycode: countoccurrence += 1 print str(countoccurrence) + ' entrie(s) ' + str(countrycode) + ' found' elif countrycode not in list: print 'invalid country code' break list = ['ec','us','uk','ur','br','ur', 'ur', 'uk...

php - START a proccess in background in WINDOWS -

i have problem running command php script. command trying run is echo y | plink -ssh -n -d 9999 admin@1.2.3.4 -pw admin -v the thing command runs script freezes until execution of plink command, don't want. tried (running in background) : start /min "cmd.exe" /c "plink -ssh -n -d 9999 admin@1.2.3.4 -pw admin" and see minimized plink running, , close it, script continues. i tried: start /b /min "cmd.exe" /c "plink -ssh -n -d 9999 admin@1.2.3.4 -pw admin" and same thing, showing output in php script. this function : function create_tunnel($ip,$user,$pass,$port) { exec('start /min cmd /c "echo y | plink -ssh -n -d '.$port.' '.$user.'@'.$ip.' -pw '.$pass.' -v" > nul'); } what must run command , let php script continue execution? in linux simple, use screen command. thanks. try symfony process component: $process = new process('ls -lsa'); $pr...

ios - Save the value in UIpickerview once done editing -

i need number 4. select uitextfield , show uipickerview (check) select value in uipickerview , display in uitextfield (check) click on screen , move focus uitextfield , uipickerview disappear (check) click on uitextfield , displays selected value in uitextfield uipickerview starting point (row 0). here code: @ibaction func textfieldediting(sender: uitextfield){ var numberpicker:uipickerview = uipickerview() var row:int = 0 numberpicker.delegate = self desiredtext?.inputview = numberpicker numberpicker.selectrow(79, incomponent: 0, animated: true) //desiredtext?.text = pickoption[79] } func numberofcomponentsinpickerview(pickerview: uipickerview) -> int{ return 1 } func pickerview(pickerview: uipickerview, numberofrowsincomponent component: int) -> int{ return pickoption.count } func pickerview(pickerview: uipickerview, titleforrow row: int, forcomponent component: int) -> string! { return pickoption[row] } func ...

Redis - Sorted set, find item by property value -

in redis store objects in sorted set. in solution, it's important able run ranged query dates, store items score being timestamp of each items, example: # score value 0 1443476076 {"id":"92","ref":"7adt","dtime":1443476076,"atime":1443901554,"extime":0,"spname":"7adt33cfsau6","stpname":"7adt33cfsau6"} 1 1443482969 {"id":"11","ref":"dajt","dtime":1443482969,"atime":1443901326,"extime":0,"spname":"dajtjtt4t02o","stpname":"dajtjtt4t02o"} however, in other situations need find single item in set based on it's id. know can't query data structure if nosql db, tried using zscan , didn't work. zscan myset 0 match id:92 count 1 it returns; "empty list or set" maybe need serialize different? have serialized using json.net. how, ...

functional programming - A "map" to only part of the elements in Javascript -

is there way, in javascript (es2015), map part of array? e.g.: let m = somearray.map(function(n){ if(n===0) return n+1; } that's it, return mapped array has less elements original one. is accomplish out of box functional programming technique? maps changing number of elements icky. it's better filter first, map: let arr2 = arr.filter(e => e === 0).map(e => e + 1);

php - Wordpress - Display "Custom Author Role Name" - WP Members Plugin Installed -

this question has answer here: wordpress role display name 3 answers i tried display custom author name created wp_members plugin. used function inside function.php of theme. function get_author_role_name(){ $role = get_the_author_meta('roles')['0']; echo esc_html($role); } it works fine, displays "slug" of role. display name! ex. name: "my custom role", function displays "my-custom-role". so, replace "-" space " " , use ucwords() function, but, there function real name directly? can't find it! thanks edit - solution here: function get_author_role_name(){ $get_role = get_the_author_meta('roles')['0']; global $wp_roles; $role = $wp_roles->roles[$get_role]['name']; echo esc_html($role); } based on above link, edited function so...

c# - Why does CopyToDataTable unsort the DataRow Array -

i've got datatable need sort , place datatable. on face of easy below: datatable sortme = getdata(); sortme.select("col1 = 'something'", "sortbyme asc").copytodatatable(); however, i've found pass datarow array created select() copytodatatable(), new datatable no longer sorted sortbyme . how fix without creating loop push each datarow datatable? , causing sorting lost? there question asked , solved how sort datatables row, please @ here, might you: sorting rows in data table

sql - "ORDER BY items must appear in the select list if SELECT DISTINCT" when selecting from aliased subquery -

getting error running query: select distinct top 100 t.number, t.lastname, t.firstname ( select top 1700 -- 100 * (mean avg # site per pi + 3sd) pi.number, pi.lastname, pi.firstname sites s inner join pi on s.pi = pi.number inner join protocol p on pi.protocolnumber = p.protocolnumber inner join productmaster pm on pa.productcode = pm.productcode -- predicates ) t order t.lastname collate latin1_general_ci_ai i'm not sure why isn't working. i've got last name in select list. missing? you need put collation in `select: select distinct top 100 t.number, t.lastname collate latin1_general_ci_ai, t.firstname this rather insignificant change unless have case sensitive collation , want see duplicates. if so, use group by , lower() (or upper() ): select top 100 t.number, t.lastname, t.firstname (sel...

Ubuntu 14.10 AMD graphics card driver -

Image
i'm having problems graphics cards driver , hoped guys me out. mispurposeadly changed x.org's driver propietary 1 , ended computer falling apart login loop problem, typical of thrusty thar. however, managed via console purge fglrx driver using sudo apt-get purge , managed access desktop graphically. after none of usb ports or sd slot worked, nor did graphics card, ethernet port, upgraded ubuntu thrusty thar utopical unicornwith hope fix driver's problem. didn't. can me find solution problem? in worst case scenario, can reinstall ubuntu should fix issue. alternatively, can upgrade latest ubuntu 16.04 lts version , should have bug fixes solve problem. i recommend using open source driver installed , in use when first install ubuntu. change open source driver proprietary 1 if there graphical glitches or other problems graphics. have never had problems open source graphics drivers. finally, make sure install available software updates since may fix iss...

generic scoring module using python pandas -

hi i'm trying develop generic scoring module grading students based on variety of attributes. i'm trying develop generic method using python pandas input: input data frame student id , ug major , attributes scoring (i called df_input) input ref. data frame contains scoring params process: based on variable type, developing process calculate scores each attribute output: input data frame added cols capture attribute score example: df_input + ------------+-----------+----+------------+-----+------+ | student_id | ug_major | c1 | c2 | c3 | c4 | +------------+-----------+----+------------+-----+------+ | 123 | math | | 8000-10000 | 12% | 9000 | | 234 | all_other | b | 1500-2000 | 10% | 1500 | | 345 | all_other | | 2800-3000 | 8% | 2300 | | 456 | all_other | | 8000-10000 | 12% | 3200 | | 980 | all_other | c | 1000-2500 | 15% | 2700 | +------------+-----------+----+------------+-----+------+ df_ref + ----...

node.js - Installing MongoExpress with npm -

i have hit error when running 'npm install ­-g mongo­express' on windows 10. c:\>npm install ­g mongo­express npm err! addlocal not install c:\­g npm err! addlocal not install c:\mongo­express npm err! windows_nt 10.0.10240 npm err! argv "c:\\program files (x86)\\nodejs\\node.exe" "c:\\users\\daniel\\appdata\\roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "­g" "mongo­express" npm err! node v4.0.0 npm err! npm v3.3.3 npm err! path c:\­g npm err! code enoent npm err! errno -4058 npm err! syscall open npm err! enoent enoent: no such file or directory, open 'c:\­g' npm err! enoent not problem npm npm err! enoent , related npm not being able find file. npm err! enoent npm err! please include following file support request: npm err! c:\npm-debug.log the contents of 'c:\npm-debug.log' are: 0 info worked if ends ok 1 verbose cli [ 'c:\\program files (x86)\\nodejs\\node.exe', 1 ver...

Can you run Windows batch file not in a command prompt? -

my programming teacher requiring participate in science fair year, , accept computer-related projects. so, knowing 1 language (windows batch), asked if make kind of text based game in batch code. said can write code, not execute it. she said if we're caught on command prompt, apparently in big trouble , never access school computer rest of time i'm @ high school, or that... if code contains bunch of echos , simple variables, won't let me , partner run it. said must work on project during school in class. so sum up, she's letting me write game/program, i'm not allowed test make sure works in school, when i'm writing most... so there way run/test batch script simple echo , set /p commands without "dangerous, black command prompt" showing up? i think has no idea she's talking about, because on board, wrote "back script" lol a batch file runs other executable file double-clicking file within windows. however, because bat...

AngularJS: Button click fired too early in tablet when visible on mouseover -

i have button inside div. button should visible when mouse on div. works on pc mouse. however, on tablet or phone, mouse on event triggered when first touch div. problem if touch place button (although invisible yet), make button visible , trigger click event @ same time. so, how can delay button click event? here sample code: <div ng-mouseenter="ismouseover=true" ng-mouseleave="ismouseover=false"> <div>other stuff</div> <button ng-show="ismouseover" ng-click="clicked()">click</button> </div> you can try unbind click event using jquery. try like: hml: <div ng-mouseenter="ismouseover=true" ng-mouseleave="ismouseover=false"> <div>other stuff</div> <button id="beingclicked" ng-show="ismouseover" ng-click="clicked()">click</button> </div> js (jquery) //if mobile device if(!!('on...

java - How can a singly-linked list have two heads, and what does it mean to find their "common node"? -

the javadocs methods below includes: the singly linked list in problem has 2 heads, n1 , n2 , merge @ common node. return first common node accessible both n1 , n2 . must run in o( n ) time. i don't understand purpose of code. how can singly-linked list have 2 heads? common list (or common node), , why returned? could provide examples of input list or lists, , or after findcommonlist method returns? the code is: public static<e> listnode<e> findcommonlist(listnode<e> n1, listnode<e> n2) { int length1 = getlength(n1); int length2 = getlength(n2); if (length1 > length2) n1 = advance(n1, length1 - length2); else n2 = advance(n2, length2 - length1); while (n1 != n2) { n1 = n1.next; n2 = n2.next; } return n1; } private static<e> listnode<e> advance(listnode<e> n, int k) { while (k > 0) { n = n.next; k--; } return n; } private static<e> int getlength(listnode<e> n) { int total = 0; while...

parentheses - Java - Efficient parenthesis matching method to group input -

edit: should have mentioned program required strictly non recursive. i'm trying make method assign groups matched parenthesis. example input: m (a (b c) (d (e (f g h) i) j) k) n output be: inputted text: m (a (b c) (d (e (f g h) i) j) k) n group 0 = m (a (b c) (d (e (f g h) i) j) k) n group 1 = (a (b c) (d (e (f g h) i) j) k) group 2 = (b c) group 3 = (d (e (f g h) i) j) group 4 = (e (f g h) i) group 5 = (f g h) i created following method, can see, matches first encountered left parenthesis first encountered right instead of each left parenthesis signifying start of new group. can't thing of simple way replicate above output without starting over. ideas? public class matching { public static string[] group(string s){ stack<integer> indexstack = new stack<integer>(); string[] grouparray = new string[15]; int count = 0; for(int = 0; != s.length(); i++){ /* * if character in index position...

c# - Add Rows In a empty dataGrid -

i building mvvm - wpf application. have few datagrids crud operations work fine. now, want datagrid empty @ beginning , of course can add rows. can fill when click save, nothing saved. why? viewmodel: public class invoiceviewmodel : viewmodelbase { public context ctx = new context(); public invoiceviewmodel() { this.collection = new observablecollection<invoice>(); } private observablecollection<invoice> collection; public observablecollection<invoice> collection { { return collection; } set { collection = value; onpropertychanged("collection"); } } private invoice _selected; public invoice selected { { return _selected; } set { _selected = value; onpropertychanged("selected"); } } private void get() { ...

c++ - Sorting a Binary Tree -

i have written simple binary tree using structures , couple of functions in order add, search, find minimum , maximum values, remove node destroy node, problem have been using recursion , dealing in same way , having hard time trying comprehend if function sorting algorithm efficient enough. the whole code is: #include<iostream> using namespace std; /* simple example demonstrating basic binary tree implemented using structurs, later on create using classes, now, structures , pointers suffice */ /* * node created in here, notice how pointer has ability * self reference 2 different positions, means there ability * store 2 different branches of memory * */ struct node{ int key_value; node * p_left; node * p_right; }; /* * * creation of add function add linked list * */ node* add(node * p_tree, int key) { //--the base case of recursive function placed in here //--since binary trees recursive in nature , linked data structures //--are whole i...

c++ - Selection of container to insert the multiple db recored -

in current task , need read read approximately 10,000 records (student data) database , need store same in container. need select container store records in order generate report. report generation option vendor specific 1 vendor wants dump records without sorting , other vendor wants generate report based on sorted name field. have selected vector end don't require kind of insertion in middle , no searching effort required first option (report without sorting fields) second option can suggest me if vector suitable option same introducing sorting based on name field. below useful pointers found in scott meyers book (effective stl) in item 23 . believe based on below information second option sorted vector needs used still want through light on before come conclusion , start coding. item 23. consider replacing associative containers sorted vectors "**the standard associative containers typically implemented balanced binary search trees. balanced binary search tree da...

mysql - Query rows using Order by A, if A values are the same, Order by B as the second standard -

i want query db rows using 2 standards: first, b second. is: order a, if values same, order b second standard how write sql? example: query table: id | | b _ _ _ _ _ _ 1 | 1 | 1 _ _ _ _ _ _ 2 | 2 | 2 _ _ _ _ _ _ 3 | 2 | 1 _ _ _ _ _ _ 4 | 3 | 1 query result: id 1 3 2 4 order used sort result table in asc | desc based on 1 or more column names. sorts asc in default. example: select * table1 order a, b in example results table1 sorted in asc b. if has same values, results sorted b in asc

python module imports issue -

here's picture of directory structure: parts.py machine/ __init__.py parts.py i have directory (a package) called machine in there __init__.py , parts.py at same level machine, there file named parts.py in parts.py, code looks this: #parts.py class parts(object): pass in machine.parts code looks this #machine.parts parts import parts class machineparts(parts): pass when try import machine.parts, import error. don't want change directory structure. how should fix , retain pep8 style? you should make package adding top-level __init__.py , giving meaningful name top-level directory: mypackage __init__.py parts.py machine/ __init__.py parts.py then, use absolute imports: #machine.parts mypackage.parts import parts class machineparts(parts): pass

java - Android studio crashing after Intent hit -

i want ask why intenting activity makes system crashed? i've created 2 layout, 1 of them named "mainactivity" , other 1 named "login". in main activity there button, want pop login activity after hitting button. because want view list view i've been created see if right or wrong. problem here whenever hit button crashed. me please. main activity public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } public void okay(view view) { intent = new intent(this, login.class); startactivity(i); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } login ### public class login extends actionbaractivity { ...

r - Generate a list of functions from a closure -

power <- function(exp) { function(x) { x ^ exp } } funlist <- lapply(2:3, power) now expect first element of 'funlist' square function , second cube function. seems repeats 'cubing'. > funlist[[1]](5) [1] 125 > funlist[[2]](5) [1] 125 is there way generate list of functions closure in way? or general best practices surrounding problem may want approach in way? the reason changed behavior in 3.2.0 announcement in news() file: higher order functions such apply functions , reduce() force arguments functions apply in order eliminate undesirable interactions between lazy evaluation , variable capture in closures. resolves pr#16093.

java - Output in other layout -

somebody please me problem. i'm developing mobile grocery app thesis. used make more buttons because i'm beginner, , using buttons simplest way make app. want here make output in other layout, summary of item bought. way used checkbox determined might item buy. here's code. baby_items (grocery category) serves parent button public class baby_items extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_baby__items); } public void baby_diaper (view view) { intent = new intent(this, baby_diaper.class); startactivity(i); } public void baby_food (view view) { intent = new intent(this, baby_food.class); startactivity(i); } public void baby_milk (view view) { intent = new intent(this, baby_milk.class); startactivity(i); } baby_diaper (children button) public class baby_diaper extends actionbaractivity { arraylist<string> sel...