Posts

Showing posts from July, 2013

java - How to use log4j2 JMSAppender with ActiveMQ -

i struggling write simple poc program logs messages queue. tutorials , q&as find ( here , here ) use log4j version 1.2 , put messages onto topic , not onto queue. requirement log queue. i followed documentation mentioned on official site , not able working. i have log4j2 , activemq jars on classpath, have created queue "logqueue", able see queue in activemq web console , when try execute program write logs, following error: error error creating jmsmanager using connectionfactory [connectionfactory] , destination [logqueue]. javax.naming.noinitialcontextexception: need specify class name in environment or system property, or applet parameter, or in application resource file: java.naming.factory.initial @ javax.naming.spi.namingmanager.getinitialcontext(namingmanager.java:662) @ javax.naming.initialcontext.getdefaultinitctx(initialcontext.java:313) it looks jndi issue, not able figure out what. per log4j 1.2 tutorials, added jndi.properties file classp

Inheritance and template in C++: Why doesn't the following piece of code compile? -

i have simple c++ program , not able compile , although tried search in google , try read template , inheritance , vector , didn't got clue mistake doing, can please me!! following code: template <class t> class base { public: int entries; }; template <class t> class derive : public base<t *> { public: int j; void pankaj(){j = entries;} void clear(); }; template <class t> void derive<t>::clear() { int i; int j=entries; }; int main() { derive b1; } and getting following error: pankajkk> g++ sample.cpp sample.cpp: in member function 'void derive<t>::pankaj()': sample.cpp:14: error: 'entries' not declared in scope sample.cpp: in member function 'void derive<t>::clear()': sample.cpp:22: error: 'entries' not declared in scope sample.cpp: in function 'int main()': sample.cpp:26: error: missing template arguments before 'b1' sample.cpp:26: error: expected `;' befor

Escape characters in bash -

i have line in script here: "echo 'conf_dir="$( cd "$( dirname "${bash_source[0]}" )" && pwd )"' >> /home/$user/tachyon-0.5.0/conf/tachyon-env.sh" the portion conf_dir="$( cd "$( dirname "${bash_source[0]}" )" && pwd )" has written onto tachyon-env.sh file. have tried many combinations of escape characters, either "cd" , "pwd" commands getting executed, or there syntax error. know how might print line literally onto file? in advance the full line: ssh -i "/home/$user/$key" "$user"@"$worker1ip" "echo 'conf_dir="$( cd "$( dirname "${bash_source[0]}" )" && pwd )"' >> /home/$user/tachyon-0.5.0/conf/tachyon-env.sh" this should work: 'echo "conf_dir=\"\$( cd \"\$( dirname \"\${bash_source[0]}\" )\" && pwd )\""

sql - how to get a datatable to display it's data in a textbox -

everyone, i trying textbox display result of "avg" select command sql server. dim querystring string = "select avg(pumpnum) petrol_table" using adapter new sqldataadapter(querystring, connectionstring) dim table new datatable adapter.fill(table) dim row datarow = table.rows(0) textbox5.text = row("pumpnum").tostring if put column name in , error column name not exist. if leave out column name, in textbox "system.data.datarow." thanks reading while searching net answer, found this.... textbox5.text = table.rows(0).item(0) works charm. :-)

python - GroupBy results to dictionary of lists -

i have excel sheet looks so: column1 column2 column3 0 23 1 1 5 2 1 2 3 1 19 5 2 56 1 2 22 2 3 2 4 3 14 5 4 59 1 5 44 1 5 1 2 5 87 3 and i'm looking extract data, group column 1, , add dictionary appears this: {0: [1], 1: [2,3,5], 2: [1,2], 3: [4,5], 4: [1], 5: [1,2,3]} this code far excel = pandas.read_excel(r"e:\test_data.xlsx", sheetname='mysheet', parse_cols'a,c') mytable = excel.groupby("column1").groups print mytable however, output looks this: {0: [0l], 1: [1l, 2l, 3l], 2: [4l, 5l], 3: [6l, 7l], 4: [8l], 5: [9l, 10l, 11l]} thanks! you groupby on column1 , take column3 apply(list) , call to_dict ? in [81]: df.groupby('column1')['column3'].apply(list).to_dict() out[81]: {0: [1], 1: [2, 3, 5], 2: [1, 2], 3: [4, 5], 4: [1], 5: [1, 2, 3]}

python - string replace using a list with a for loop -

i new python , want replace characters in string with characters list example. tagfinder = ['<', '>','&'] safetag = ['&lt;','&gt','&amp'] in content: return content.replace(tagfinder[i],safetag[i] i keep getting following error typeerror: list indices must integers, not str could please brother out in advance! you intended for in range(len(tagfinder)): content = content.replace(tagfinder[i],safetag[i]) .......... return content instead of for in content: return content.replace(tagfinder[i],safetag[i]) and prematurely exiting loop because of return statement. return statement should last statement in function, assuming these statements in function but better use built-in zip here for src, dest in zip(tagfinder , safetag ): content = content.replace(src, dest) .......... return content but then, unless part of homework, should use standard library escape html string.

Scheme programming I/O and remove -

i doing scheme project , having issues coding. project have keep class roster(implemented list) , able perform different operations. have 2 questions: my write roster function opens file name passed through not write list file , im not sure why? can find function in perform task function , when n = 2. and remove function... when go test it, error: ;the procedure #[compiled-procedure 13 ("list" #x3) #x14 #x11a2714] has been called 4 arguments; requires 2 arguments. remove function called removestu here code: (define performtask (lambda (n roster) (cond ((= n 0) (begin (display "\n\tresetting roster...\n\n") (menu '()) )) ((= n 1) (begin (display "\n\tload roster file: ") (read (open-input-file (read-line))) (menu roster) )) ((= n 2) (begin (display "\n\tstore

php - How to show dropdowns with selected options if form is submitted and have validation errors -

i have form radio buttons first. when choose radio button, shown different dropdowns different radio buttons. dependent dropdowns. first hide them all. it's working, when click submit button , there fields or options have not filled, these dropdowns hide , have select them again. want make if click submit button , there validation errors, show these dropdowns radio, have chosen, , choices selected. here's code: $(document).ready(function(){ $(":radio").click(function(){ $('#region').val('choose region'); $('#school').val('choose region'); $('#teacher').val('choose school'); $('#class').val('choose class'); $('#class_divisions').val('choose division'); }); }); function showhide(self, show){ $(".all_teac

sorting - Sort java map by value (which contains a set) -

i have map looks map<word, set<word>> tuplemap = new hashmap<word, set<word>>(); the word class nothing special, contains few strings value , on. trying sort map number of elements of associated set. word has words associated first/last in map. i did manage sort map key using code: wordmapcomparator bvc = new wordmapcomparator(tuplemap); treemap<word, set<word>> sortedtuplemap = new treemap<word, set<word>>(bvc); sortedtuplemap.putall(tuplemap); ` where comparator is class wordmapcomparator implements comparator<word> { map<word, set<word>> base; public wordmapcomparator(map<word, set<word>> tuplemap) { this.base = tuplemap; } public int compare(word a, word b) { return a.getvalue().compareto(b.getvalue()); } } now works fine, map gets sorted based on words value. however, tried comparator: class wordmapcomparator implements comparator<word&

java - Multiple Data Binding Objects in Eclipse Jface MVC -

i'm facint problems regarding jface tableviewer , bindings. i'm using following example code tableviewer: public class apppersonviewer extends tableviewer { public table table; public apppersonviewer(composite parent, int style) { super(parent, style); table = gettable(); griddata griddata = new griddata(swt.fill, swt.fill, true, true); table.setlayoutdata(griddata); createcolumns(); table.setheadervisible(true); table.setlinesvisible(true); setcontentprovider(new appcontentprovider()); } private void createcolumns() { string[] titles = { "first name", "second name", "age", "country", "likes so" }; int[] bounds = { 150, 150, 100, 150, 100 }; tableviewercolumn column = createtableviewercolumn(titles[0], bounds[0], 0); column.setlabelprovider(new columnlabelprovider(){ public string gettext(

How do I split a string by character position in c -

i'm using c read in external text file. input not great , like; 0paul 22 acacia avenue 02/07/1986rn666 as can see have no obvious delimeter, , values have no space between them. know how long in character length each value should when split. follows, id = 1 name = 20 house number = 5 street name = 40 date of birth = 10 reference = 5 i've set structure want hold information in, , have tried using fscanf read in file. find along lines of isn't doing need, fscanf(file_in, "%1d, %20s", person.id[i], person.name[i]); (the actual line use attempts grab input should see i'm going...) the long term intention reformat input file output file made little easier on eye. i appreciate i'm going wrong way, hugely appreciate if set me on right path. if you're able take easy on me in regard obvious lack of understanding, i'd appreciate also. thanks reading if have fixed column widths, can

c++ - increment pointer within if (pointer) condition -

i'm reading c++ code, developer uses kind of pattern: float *_array; //... while (expression) { if (_array) { // ... _array += 1; } else { // ... } } the outer while loop terminate independently _array points to. question if (_array) condition , incrementation within clause. i first thought should check if pointer "ran out of" array, not seem case. tested simple snippet: float *p = new float[5]; int = 0; (i = 0; < 10; i++) { if (p) { std::cout << "ok\n"; } else { std::cout << "no\n"; } p += 1; } this print 10 times "ok". if (pointer) evaluates true if pointer exceeded defined array length. but else purpose of if (pointer) in context? its purpose check whether pointer _array pointing null or not, i.e. check if null pointer. new throws std::bad_alloc exception , therefore no need check null . in case of malloc, calloc, re

spring - JDO class persistence for DB connection -

i new org.datanucleus.store.rdbms.query.jdoqlquery.compilequeryfull query candidates of com.titas.model.user_login , subclasses resulted in no possible candidates persistent class "com.titas.model.user_login" has no table in database, operation requires it. please check specification of metadata class. org.datanucleus.store.rdbms.exceptions.notablemanagedexception: persistent class "com.titas.model.user_login" has no table in database, operation requires it. please check specification of metadata class. @ org.datanucleus.store.rdbms.rdbmsstoremanager.getdatastoreclass (rdbmsstoremanager.java:693) @ org.datanucleus.store.rdbms.query.rdbmsqueryutils.getstatementfor candidates(rdbmsqueryutils.java:425) my dispatcher servlet is: <!-- pmf bean --> <bean id="mypmf" class="org.springframework.orm.jdo.localpersistencemanagerfactorybean"> <property name="jdopropertymap"> <props>

.net - ASP.NET MVC 4 WebAPI PostAsJsonAsync Newtonsoft.Json error -

in mvc 4 web api project stops working. it's can't find newtonsoft.json. after running code : dim response httpresponsemessage = myhttpclient.postasjsonasync("api/test", myobject).result i message error : an unhandled exception of type 'system.io.fileloadexception' occurred in system.net.http.formatting.dll additional information: not load file or assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040) i know ms using default json serializer - , it’s referenced. tried update newtonsoft.json nuget can't find it; find "json.net". used package manager console reinstall update-package newtonsoft.json –reinstall but still doesn’t work. have idea why going wrong? it seems using outdated library depends on old version of json.net. try install specifi

php - How to select greatest record (semester) of each id -

Image
how select greatest semester of each student linked picture. http://i.stack.imgur.com/ka97x.jpg select s1.* student s1 inner join ( select student_id,max(semester) semester student group student_id ) s2 on s1.student_id=s2.student_id , s1.semester=s2.semester

dicom - using single AE title to more than one Ipaddress -

i using dcmtk pacs server process. here using dcmqrscp exe . in exe dcmqrscp.cfg file contain detail hosttable , aetitle table , vendor table. in hostable create 1 ae title . question shall use single aetitle different ipaddress ? see part 8 , page 46 of dicom standard, network communication support message exchange . link document a single application entity title can associated multiple network addresses assigned single system (e.g., multi-homed host). a single application entity title can associated multiple tcp ports using same or different ip addresses. a single network access point (ip address , tcp port) can support multiple application entity titles.

android - How do I create an audio file (wav/mp3) given a midi file with my own soundbank? -

i tried looking android library deals creating audio files given midi file (and using own sound files) had hard time finding any. i found this question , checked out links provided, still, no luck. understanding process called soft synthesis. isn't there way programmatically?

ruby - Rails ActiveJob for infinite loop -

the application developing needs have infinite loop handle business logic separate user input (they view it). since break tradition mvc, thought active job place put it. the logic in loop poll microcontrollers on same network. have little no ability change code on these have adapt unique protocol using. when microcontrollers respond, server need calculations , store in database. the job launched when server application is. 1 instance of should exist don't want put in models or controllers. have tried launching couple of places in config folder cause initialized constant nameerror. what correct way launch job when server initialized? there approach take? i webdev newb using ruby 2.2.0 , rails 4.2.0. how using scheduled jobs? example schedule every minute job scheduled run poll whatever need polling for? have @ gem: https://github.com/javan/whenever

Inserting tuples in a list Ocaml -

i have declared list l=[];; , trying append tuples list using '@'. not able so. can please me sorting out. let l = [] x = 1 10 l <- l@[(x,x+10)] done;; and want final answer as: l=[(1,10),(2,20),(3,30).....] your definition of l means l immutable. define value [] , , can never changed. if want able change l , need define mutable value. 1 simple way make "ref": # let l = ref [];; val l : '_a list ref = {contents = []} after can value of l ! operator , change value using := operator: # !l;; - : '_a list = [] # l := !l @ [3];; - : unit = () # !l;; - : int list = [3] however, code not idiomatic ocaml. if you're studying ocaml academically, might better learn work immutable values. update here hints on writing recursive functions. don't want spoil exercise writing code you. the way solve problem recursively answer questions this: what general problem trying solve? in case, you're trying create list of pair

android - How to arrange some images verticaly and horizontaly -

in app have 10 images ,i arranged 2 images row wise using linear layout,i want arrange remaining images row wise (group of 2 images)under first row.i tried code ,i dont know how arrange remaining images under first row,i want add scroll view same ,is possible add single scroll view linear layouts?.i tried code not working.can me?i new android layouts. <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context="com.cozyne.user.picimagetest.gridviewactivity"> <linearlayout android:layout_width="fill_parent&

ios - iAd UITableViewController Swift -

i'm trying implement iad uitableviewcontroller , can't figure out how iad banner @ bottom of uitableviewcontroller . i can find tutorials/info iad in swift on uiviewcontroller , , stuff found iad on uitableviewcontroller in objective-c. it has in swift , uitableviewcontroller has in swift class, not objective-c. i've tried different types of swift iad tutorials none have worked uitableviewcontroller . its should not matter type of controller long link , import iad framework. import uikit import iad class tableviewcontroller: uitableviewcontroller { override func viewdidload() { super.viewdidload() self.candisplaybannerads = true } this code should display ads. take @ example ios app money making machine using iad app monetization technique

c# - How to properly add new items to a collection? -

here trying store loads of datapoints of custom winddatapoint type. however, found out whole time, code has been creating tens of thousands of duplicate data points. data points change latest value, yes, instead of adding new datapoint, sets datapoints value well. here code of concern: private void timer_data_tick(object sender) { if (!timer_data_enabled) return; (int = 0; (itsdaq.getstreamcount() > 0) && (i < 6); i++) { winddaq.winddatapoint thisdatapoint = new winddaq.winddatapoint(); thisdatapoint = itsdaq.getvalue(recording); datapointcollection.add(thisdatapoint); newchartpoint = true; } } here code getvalue() , getvalue(bool record) //get real-world values public winddatapoint getvalue() { holddequeuevalue = daqstream.dequeue(); holdwinddatapoint.lift = lift_sensor.getforce(holddequeuevalue[channeloutorder[0]]);

javascript - How to use jQuery :not selector for more than one element at a time -

i want use jquery :not selector in such way when bunch of elements don't have specified class, want add class 1 of them. what want achieve is: 'when design-preview1, design-preview2 design-preview 3 , design-preview 4 not have class "selected", add class "selected" "design-preview1" '. i tried not working: $(".design-preview1, .design-preview2, .design-preview3, .design-preview4").not(".selected").$(".design-preview1").addclass('selected'); }); any highly appreciated new this full jquery code: $('.pop-design1').click(function(){ $(".design-preview li:not(.design-preview2).selected").removeclass('selected'); $(".design-list li:not(.design-list2).selected").removeclass('selected'); $(".design-preview2").toggleclass('selected'); $(".design-list2").toggleclass('sel

coordinates - pygame.mouse.get_pos()..... the x/y co-oridinates not updating -

trying box change color when mouse goes over. problem i'm having mouse co-ordinates not updating. program doesn't know mouse on specific location. how keep updated mouse co-ordinates? def start_screen(): game_display.blit(selection_screen,(0,0)) #buttons mouse = pygame.mouse.get_pos() print(mouse) if 200 + 100 > mouse[0] > 200 , 550 + 50 > mouse[1] > 550: pygame.draw.rect(game_display,black,(200,550,100,50)) else: pygame.draw.rect(game_display,white,(200,550,100,50)) pygame.draw.rect(game_display,white,(700,550,100,50)) pygame.display.update() start_screen() fixed it... def start_screen(): intro = true while intro: event in pygame.event.get(): game_display.blit(selection_screen,(0,0)) #buttons mouse = pygame.mouse.get_pos() if 200 + 100 > mouse[0] > 200 , 550 + 50 > mouse[1] > 550: pygame.draw.rect(gam

groovy - how do i create derived required properties for maven archetypes during generation -

i need provide derivative custom required properties during archetype:generation when using archetype. maven supports custom required properties derive buit-in properties artifactid , rootartifactid. due long-standing evaluation ordering issues, not possible reliably derive custom properties. i found solution might work, using groovy maven plug-in here . the problem proposed solution initialization phase not apply non-pom uses archetype generation. question how can use groovy maven plugin during archetype:generate? cannot seem invoked. cannot figure out phase value use.

java - MyBatis 3 + PostgreSQL - get primary key value on insertion -

i have maven project uses java spring, mybatis, , mybatis-spring map objects postgresql database. want able query value of primary key @ same time insert new record, , have yet find method works. current implementation not return correct value; appears returning 1. this mapper's xml configuration query: <insert id="registernewuser" parametertype="com.hunter.databasejar.user"> <selectkey keyproperty="id" resulttype="int"> select currval('"users_id_seq"') </selectkey> insert "users" ("username", "firstname", "lastname") values (#{username}, #{firstname}, #{lastname}) </insert> in java, write following, , value of 1. int = sqlsession.insert("usermapper.registernewuser", user); i have tried altering xml config try "returning" syntax sql, got value of -1. <insert id="registernewuser" parametertype

java - No Line found? reading file error? -

i no line found error reading while loop. when print input.nextline() says countt == 0. means, while loop not working? public class readerfile { public static scanner input; try-catch of input. try{ input = new scanner(new file(filelocation)).usedelimiter(","); } catch (ioexception ioexception) { system.out.print("problem"); } this code i'm having problems with. int countt = 0; input.nextline(); while(input.hasnext()) { system.out.print("teamstart\n"); int id = input.nextint(); string teamname = input.next(); string coachfirst = input.next(); string coachlast = input.next(); string mentorfirst = input.next(); string mentorlast = input.next(); string teamfs = input.next();

ios - Swift: Problems printing out UILabel.text -

so have routine sets different text uilabel.text values self.addresslabel.text = firstobject["address"] as? string self.phonelabel.text = firstobject["phonenums"] as? string self.latitude.text = firstobject["lat"] as? string self.longitude.text = firstobject["lon"] as? string but when try print out println("\(latitude.text!)") it outputs: label how can make println statement prints string "38.1848392". thanks! you can set string variable, , print that. so: var latitudestring : string = self.latitude.text println(latitudestring) edit: seems casting latitude string not happening. following: var lat : float = firstobject["lat"] as! float var latstring = string(lat) self.latitude.text = latstring println(latstring)

php - Changing the category list order in Wordpress -

i working on editing wordpress plugin file. the code below lists categories in alphabetical order. want list them category id, in ascending order. <?php foreach($categories $category){ $rand = rand(0,99); $catname = get_cat_name( $category ); $find = array("&", "/", " ","amp;","&#38;"); $replace = array("", "", "", "",""); $catname = str_replace($find,$replace,get_cat_name( $category )); ?> <li> <a href="#fragment-<?php echo $catname; ?>"><?php echo get_cat_name( $category ); ?></a> </li> <?php } ?> i tried working get_cat_id function, i'm not programmer got stuck. please help. rather querying categories inside theme file, better way register custom function in wordpress theme. googling "wordpress category order id" g

python - Installing Python3.4.3: 3 tests failed, 3 altered execution environment and 25 skipped -

i use lubuntu 14.04 guest os (using vmplayer). wanted install python3.4.3. downloaded .tar.xz file here: https://www.python.org/downloads/ i extracted file , followed instructions in readme: ./configure make make test when ran make test it returned this: 359 tests ok. 3 tests failed: test_urllib test_urllib2 test_urllib2net 3 tests altered execution environment: test___all__ test_site test_warnings 25 tests skipped: test_bz2 test_curses test_dbm_gnu test_dbm_ndbm test_devpoll test_gdb test_gzip test_idle test_kqueue test_lzma test_msilib test_ossaudiodev test_readline test_smtpnet test_sqlite test_ssl test_startfile test_tcl test_tk test_ttk_guionly test_ttk_textonly test_winreg test_winsound test_zipfile64 test_zlib re-running failed tests in verbose mode re-running test 'test_urllib' in verbose mode test test_urllib crashed -- traceback (most recent call last): file "/home/ayman/downloads/python3.4.3/python-3.4.3/lib/test/reg

java - OpenCV HoughLines only ever returning one line -

i've shifted opencv development python java, work on android device. first step port straightforward canny/houghlines algorithm. research, wound with: mat lines = inputframe.gray(); mat cny=new mat(); imgproc.canny(lines,cny,100,150); mat lns = new mat(); imgproc.houghlinesp(cny, lns, 1, math.pi/180, 50, 20, 20); log.w("mainactivity",string.valueof(lns.cols())); return cny; the problem code prints '1' or '0' lines. same angle python code, returned 100s of lines same threshold , other values, code returns one. i've tried tuning of parameters, no luck. returned mat canny shows reasonable edges, houghlines (both standard, , probabilistic) return 1 line. what missing? the rows , columns different in java wrapper. instead of .cols use .rows , when want data instead of lines.get(0, i) use lines.get(i, 0)

javascript - Why is my jQuery Function in a function not starting? -

i learning javascript/jquery today, , having trouble stopwatch trying make. here code: $(document).ready(function () { var value = 0.0; $("#startstop").click(function () { $(this).css("value", "stop"); while (true) { value += 0.1; $("#time").delay(100).html(value); $(this).click(function () { $(this).css("value", "start"); break; }); } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <!doctype html> <html> <head> <title>jquery testing facilities</title> </head> <body> <input id="startstop" type="button" value="start"></input> <br> <p id="time">0.0</p>

php - Better approach to get result of answers -

i have multiple questions answerable yes or no this: question 1: yes no question 2: yes no question 3: yes no question 4: yes no question 5: yes no question 6: yes no i need results of combination of "yes" answers, did traditional if else this; if($_post[q1] && $_post[q2] && $_post[q5]){ echo 'something'; }elseif($_post[q3] && $_post[q5]){ echo 'something again'; }elseif($_post[q3] && $_post[q5]){ echo 'something again again'; } , on... although correct, still produces hundreds of lines of code because there's many questions , possible combinations. is there better approach? ty guys.. edit: ah sorry second copy>paste haha, anyway... there's 37 questions, , there's many combinations if 1 , 2 yes this... if 2 , 3 , 4 yes this... don't need every combination. i read somewhere can use 2,4,8,16,32,64,128 etc... (i don't know called haha) a

javascript - How to convert to D3's JSON format? -

while following numerous d3 examples, data gets formatted in format given in flare.json : { "name": "flare", "children": [ { "name": "analytics", "children": [ { "name": "cluster", "children": [ {"name": "agglomerativecluster", "size": 3938}, : i have adjacency list follows: a1 a2 a2 a3 a2 a4 which want convert above format. currently, doing on server-side there way achieve using d3's functions? found 1 here , approach seems require modification of d3 core library not in favor due maintainability. suggestions? there's no prescribed format, can redefine data through various accessor functions (such hierarchy.children ) , array.map . format quoted convenient representation trees because works default accessors. the first question whether intend display graph or tree . graphs, data structure defined in t

arrays - Parsing strings in C++ by multiple delimiters -

i have string object like: string test = " [3, 4, 8, 10, 10]\n[12]\n[12, 10,\n 20] " and trying parse 3 separate arrays equaling [3, 4, 8, 10, 10], [12], , [12,10, 20]. have parsed comma separated integers array before how go parsing one. unfortunately data have can have newlines mid array otherwise use "getline" function(when reading file string) , ignore brackets. it seems need first each array own string delimited brackets, , parse each of comma delimination array of integers. work? if so, how split string brackets unknown number of other strings? you can use streams , std::getline() std::getline() takes delimiter parameter: int main() { std::string test = "[3, 4, 8, 10, 10]\n[12]\n[12, 10,\n 20]"; // make data stream (could std::ifstream) std::istringstream iss(test); // working vars std::string skip, item; // between square braces // skip opening '[' getline item closing ']'

How do you change orientation in iOS -

i have made ios project don't know how lock orientation. how do that? edit: tried adding programmatically didn't work you can go project settings , below have 4 options remove or add checkmarks change orientations.

c - Why doesn't this function properly toggle an LED on and off? -

i using atmel sam3x8e micro-controller , trying simple led toggle when press button. using pull-up configuration button trigger interrupt routine. this initialization interrupt: // set button pins pull-up inputs pio_set_input(pioc, button_1, pio_pullup); pio_set_input(pioc, button_2, pio_pullup); // configure button input pin interrupt mode , handler (rising edge) pio_handler_set(pioc, id_pioc, button_1, pio_it_rise_edge, button_press_handler); pio_handler_set(pioc, id_pioc, button_2, pio_it_rise_edge, button_press_handler); // enable interrupts pio_enable_interrupt(pioc, button_1); pio_enable_interrupt(pioc, button_2); nvic_enableirq(pioc_irqn); nvic_enableirq(pioc_irqn); then interrupt routine: // interrupt handler button press void button_press_handler(uint32_t a, uint32_t b) { pio_toggle_pin_group(pioc, blue_led4); // not toggling led (only turns on) } yet when run it, cannot led toggle. turns on , stays on. function pio_toggle_pin_group calls following:

c++ - Is there a way to have a Qt QProgressBar that shows a percentage over 100% without needing to use a label? -

i use label it, wondering if there simpler way. i make color of progress bar red when exceeds 100% of value i'm comparing , green again when value below that, bar won't show number larger 100%. for example if 40 , b 80, b 200% of a, progress bar should display number 200%. change number format percent of total value, leaving '%' suffix: qprogressbar *progressbar = new qprogressbar; progressbar->setrange(0, 200); progressbar->setformat("%v%"); progressbar->setvalue(150); this should display "150%" next progress bar.

javascript - Is it possible to draw on the canvas from inside an object function? -

i've created object in javascript holds data needed context.drawimage(). possible call values , run context.drawimage() inside object function? world = new sprite(0, 0, 100, 100, 0.4, 0, 0, 0); world.draw(); function sprite(spritex, spritey, spritew, spriteh, scale, positionx, positiony, direction) { this.imagepath = world_sprite; this.spritex = spritex; this.spritey = spritey; this.spritew = spritew; this.spriteh = spriteh; this.scale = scale; this.positionx = positionx; this.positiony = positiony; this.direction = direction; this.speed = 5; this.nogravity = false; this.direction = 0; //physics stuff this.velx = 0; this.vely = 0; this.friction = 0.98; }; sprite.prototype.draw = function()