Posts

Showing posts from May, 2010

excel - Create matrix from multiple values in a single cell -

Image
i have data in excel: that want convert (5*7) matrix this: sara jone shery jack joe peter beti book1 1 0 0 0 0 0 0 book2 1 0 0 1 0 0 1 book3 0 0 0 0 0 1 0 book4 0 1 1 1 0 0 0 book5 0 0 1 0 1 0 0 what can do? my choice rearrange data suit pivottable. copy columnc , paste special values columnd. replace blanks in columnd nothing (to remove space book1, book2 ). select columnd, data > data tools - text columns, delimited, comma filter columne select non blank rows , copy visible part of columnb (excluding header) b9 (or suit) , visible part of columne (excluding header) d9 (or suit). create pivottable b1:d11 (or suit) shown (using columnd belong - ie belong2 ):

java - Superclass' fields: private+accessors vs protected -

snippet #1: public abstract class superclass { protected int i; } public class subclass extends superclass { public void method() { = doanythingwithi(i); // example } } snippet #2: public abstract class superclass { private int i; protected int geti() { return i; } protected int seti(int i) { this.i = i; } } public class subclass extends superclass { public void method() { seti(doanythingwithi(geti())); // example } } any reason why using 1 snippet instead of other one? common way process? one of more common uses of abstract class have abstract methods not implemented in abstract class, implemented in subclasses in java program. not use case. however, abstract class can used way of preventing instantiating class supposed extended first. assuming desire. furthermore, assume trivial nature of example illustration. having 2 classes "manage" single primitive 'int

c# - Issues Debugging MVVM Bindings in Visual Studio 2010? -

Image
i'm developing application in visual studio using mvvm light , ninject. unfortunately, when try debug application , there's problem in 1 of viewmodels, instead of debugging code, this: this rather useless , impossible debug. now, if know error or have idea, can insert breakpoints there in code , visual studio show correct info, don't know error is. can't breakpoint every line of code in application. there way force visual studio past ui , debug actual code? there no need set owner of application main window. the correct way set owner of window in xaml follows <object> <object.owner> <window .../> </object.owner> </object> alternatively can set code behind // create window , make window owner window ownedwindow = new window(); ownedwindow.owner = this; ownedwindow.show(); the way have done wpf tries convert string "auto_calibrator_v0._05.mainwindow" window object not possible unless have type conv

Android LocationManager is it more resource intensive to get the longitude and latitude from NETWORK_PROVIDER or GPS_PROVIDER? -

which method of retrieving longitude , latitude locationmanager resource intensive, network_provider or gps_provider? gps consume more resources network provider. take @ answer more details. android location providers - gps or network provider?

java - JavaFX: how do I use concurrency to read the output of an external process and display it in an FXML TextArea? -

here simple example of problem. let's have java app displays gui using javafx. when user hits start button, app pings external server 15 seconds. idea during 15 seconds, output of ping process should appear in gui of app. have far: 1) mypackage/app.fxml file use build javafx layout. 2) mypackage/appcontroller.java file 3) mypackage/app.java file in fxml file specify controller in appcontroller.java file when start button pushed. controller looks this: @fxml private void handlestartaction(actionevent event) { try { string ping_command = "ping -c 15 google.com"; console.println("\ncommand> "+ping_command); process p=runtime.getruntime().exec(ping_command); p.waitfor(); bufferedreader reader=new bufferedreader(new inputstreamreader(p.getinputstream()) ); string line=null; while((line=reader.readline())!=null) { console.println(line); } } catch(excepti

tmux with vim command output margins way off -

when run commands such !ls or !rspec in vim while using tmux output of screen seems have margin of 50 , jacks results, making impossible read. if strictly use vim , try commands output fine appears issue tmux or configuration option need set. anyone have ideas?

android - How to download an encrypted png file without loosing data? -

i'm new android. i'm doing application can download encrypted png image file sd card displaying after decryption. notice i'm getting " javax.crypto.illegalblocksizeexception: last block incomplete in decryption image decryption " when decrypting downloaded image. found downloaded image size 0kb (original - 150kb). downloaded encrypted image browser , checked. i'm getting original image size. i'm sure there wrong in image downloading class. cant figure out. please me. in advance. image downloading asynctask class public class downloadimagestask extends asynctask<string, void, bitmap> { private string filename; @override protected bitmap doinbackground(string... urls) { //thread.currentthread().setpriority(thread.max_priority); return download_image(urls[0]); } @override protected void onpostexecute(bitmap result) { storeimage(result); } private bitmap download_image(string url

sas - transpose efficiently with proc sql -

i know if possible transpose efficiently wide long using proc sql in sas. i'm aware proc transpose quicker method suggest below. 1 of objective avoid storing transposed table. let's example, have table1 id| a| b| c| d _____________________ 1| 100|3500|6900| 10300 2| 200| 250| 300| 350 3| 150| 32| 400| 204 4| 200| 800|1400| 2000 and want turn into id|col1| col2| ______________ 1| a| 100| 1| b| 3500| 1| c| 6900| 1| d| 10300| 2| a| 200| 2| b| 250| 2| c| 300| 2| d| 350| 3| a| 150| 3| b| 32| 3| c| 400| 3| d| 204| 4| a| 200| 4| b| 800| 4| c| 1400| 4| d| 2000| i this; select id, 'a' col1, col2 table1 ~="" union select id, 'b' col1, b col2 table1 b ~="" etc but highly inefficient. any idea? thanks. if you're in sas , use proc transpose option. there no particularly way in proc sql; while many sql variants

sql - Limit a table's cell's values to two values? -

i have two-column table want values in first table either x or y, , no other input should allowed. how can enforce this? you can use validation rule. restrict data input using validation rule a validation rule on column follows work. ="x" or ="y"

regex - How do I use a custom Tooltip Text for Invalid Input Pattern instead of "You must use this format: [blank]" -

when input not match pattern specified pattern attribute, firefox says, "please match requested format", okay; however, when validation fails internet explorer 10 displays "you must use format:" in tooltip nothing else. may simple, searching has not yielded me clue how supply text tooltip telling pattern should used. example below 1 4 digit number: <input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" /> try using title attribute describe want say: <input id="institution_threshold_days" type="text" placeholder="0-9999" pattern="^[0-9]{1,4}$" title="please enter number less 10000." /> should work major browsers... from microsoft the content of title attribute both shown tooltip text field , appended generic pattern mismatch error message. from mozilla use title attribute describe pattern

directx - Overlapping registers in Hull shader? -

i doing hardware tessellation , managed basic subdivision effect, tried move on phong tessellation (which rounding edges). when want add outputs in patch constant function , write them, 1 of throws error. struct constantoutputtype { float edges[3] : sv_tessfactor; float inside : sv_insidetessfactor; float3 f3b0 : position0; float3 f3b1 : position1; float3 f3b2 : position2; float3 f3n0 : normal0; float3 f3n1 : normal1; float3 f3n2 : normal2; }; constantoutputtype patchconstantfunction(inputpatch<hullinputtype, 3> inputpatch, uint patchid : sv_primitiveid) { constantoutputtype output = (constantoutputtype)0; // set tessellation factors 3 edges of triangle. output.edges[0] = inputpatch[0].dep; output.edges[1] = inputpatch[1].dep; output.edges[2] = inputpatch[2].dep; // set tessellation factor tessallating inside triangle. output.inside = (inputpatch[0].dep + inputpatch[1].dep + inputpatch[2].dep)/3.0f;

java - SharedPreferences error when updating app -

when updating application error, sometimes. java.lang.stackoverflowerror @ android.app.contextimpl.getsharedpreferences(contextimpl.java:354) @ android.content.contextwrapper.getsharedpreferences(contextwrapper.java:146) @ it.veneto.arpa.controller.controller.verifybulletin(controller.java:377) @ it.veneto.arpa.controller.controller.retrievebulletin(controller.java:509) @ it.veneto.arpa.controller.controller.verifybulletin(controller.java:394) @ it.veneto.arpa.controller.controller.retrievebulletin(controller.java:509) @ it.veneto.arpa.controller.controller.verifybulletin(controller.java:394) @ it.veneto.arpa.controller.controller.retrievebulletin(controller.java:509) @ it.veneto.arpa.controller.controller.verifybulletin(controller.java:394) on line 377 there is: sharedpreferences prefs = context.getsharedpreferences(preferences, context.mode_private); if connecting server (i assuming because of retrievebulletin method) again

php - Does google have an api that I can use to form a world database? -

i'm developing cms used insert places / venues , need world database connect places to. data presented on mobile application. i've looked free world databases, i'd have google-compatible , date. for example, i'd able list of countries , cities in world coordinates, area coordinates etc , store in database. sample request: http://code.google.com/worldapi/getcountries http://code.google.com/worldapi/getcities?countrycode=ru something that. while can't store data directly, can link google's information places using google places api . for example, storing reference: cmryaaaaciqgstrx1mxrvuxsh2erww-jcine1aliwp64mcwdn5vkxvxoqgpkldmfmdgyqwspm7beycgdm-iv7kc2pf7qa7brmawbbacqmr5i1f4pwtpaovizjysceztry8ez30wpehcncxpynextcld2ebsdkrksghslayuryfsex6ja6nph9dyupoth3g you can details http get : https://maps.googleapis.com/maps/api/place/details/json?reference=cmryaaaaciqgstrx1mxrvuxsh2erww-jcine1aliwp64mcwdn5vkxvxoqgpkldmfmdgyqwspm7beycgdm-iv7kc2p

Lex reports error because of ambiguous priority -

identifier [\._a-za-z0-9\/]+ comment "//" <*>{comment} { cout<<"comment\n"; char c; while((c= yyinput()) != '\n') { } } <initial>{s}{e}{t} { begin(sample_state); return set; } <sample_state>{identifier} { strncpy(yylval.str, yytext,1023); yylval.str[1023] = '\0'; return identifier; } in above lex code, there no error when "// set name" parsed. please notice space after "//" in sentence parsed. however, when "//set name" parsed, there error reported. believe has forward slash appears in both identifier , comment. point going wrong? thanks. the error caught yyerror lex matches longest match in context. when input //set , match {identifier} pattern. since never set lex state other sample_state in above code, it's hit problem when in state sample_state , lexer returns identifier, rather matching {comment} rule , skipping rest of line. the

Using JavaFX and Java 1.6 on Intellij -

how can configure intellij ide point javafx sdk ? recommendation - use later java version (7u6+) , idea's native javafx support at minimum, use intellij idea version includes javafx support (e.g. intellij idea 12.1 +), javafx distribution intellij idea javafx plugin supports (i believe that's java 7u6+). using latest stable versions of both of these tools provide best results. setup , use documentation intellij idea javafx 2.x+ plugin provided jetbrains . as java7u6+ includes javafx, don't need install , use separate javafx sdk such java 1.6 javafx sdk linked in question. if must use java 6 this approach not recommended. install javafx sdk , use javafx ant tasks build , deploy application. search jfxrt.jar file in distribution , create library added idea module's compile classpath. makes idea aware of javafx classes. some things consider: unlike later javafx releases, javafx 2.x sdk java 6 works on windows. after february 2013,

Perforce P4CONFIG not being set? -

firstly i'm total beginer perforce, , i'm learning through documentations mostly. so, migrate cvs perforce, , learned way avoid changing p4client each workspace, creating p4config file inside workspace root. so have used command: p4 set p4config=p4config (and current directory workspace root, , p4config.txt located there) in p4config file have following: p4port=host:port p4user=user p4client=myworkspace i have created 'myworkspace' command 'p4 client' mapping myworkspace root , alright. however when try command p4 info it shows 'client name:' hostname, showing variable haven't been set. and when try 'p4 set p4config' prints: p4config=p4config.txt (set) (config 'noconfig') i've tried p4config.txt full path, , still gets same... does have idea problem is? by way, it's running on windows. if file 'p4config.txt', should do p4 set p4config=p4config.txt not p4 set p4config=p4c

Is there a way to remove a folder that are add but not commit in cvs -

i have use cvs add on folder have not use cvs commit on yet. want remove it. possible? or same here removal impossible. unfortunately suspicions right. cvs not offer way remove directories. when comes directories, add important thing. fact haven't done commit doesn't matter add create directory in repository. refer answer linked ways remove or ignore empty directory. (as aside, hope incident gentle encouragement start using more modern/better version control systems such git)

python - Encode a dataframe after in import in sql -

i have imported table pandas read_frame . my dataframe has special characters é , à , on. when want display have strange characters. i wold know can encode html output : import pandas import pandas.io.sql ipython.display import html df = pandas.io.sql.read_frame('a valid sql query') html(df.to_html()) i need use html output display columns ( have 90 columns) , encoding works, 'cp1252' , when import in csv post edited : i wanted edit post image need 10 reputation ... in fact didn't put enconding in connection . possible sql.read_frame ? used pyodbc : import pyodbc cnxn = pyodbc.connect('driver={teradata};dbcname=prd;uid=***;pwd=***;quietmode=yes;') df = pandas.io.sql.read_frame("""select * *""", cnxn ) try adding connection creation next thing: cnxn = pyodbc.connect('driver={teradata};dbcname=prd;uid=*;pwd=*;quietmode=yes;', unicode_results=true) that should mak

embedded - What is the logic behind the radiotimer_start() C function? -

lines 50 - 69 in radiotimer.c represent function called "radiotimer_start()". this function, if understand correctly, written msp430 x26x hardware. at abstract level, function starts timer (i believe) executes periodically (the parameter passed in). not able understand @ how works. i wondering if 1 of experts community please explain me going on in each line of function. for example on line 61: tacctl2 = cap+scs+ccis1+cm_1; why adding many values, , "capture mode"? to honest entire function means nothing me. i appreciate if 1 of experts community @ least shed light on how figure out of these lines of code doing, , possibly relate how timer started. that register setting bunch of bits in it. + or in case. statement can rewritten as: tacctl2 = cap | scs | ccis1 | cm_1; the info each #define (cap, scs, ccis1, , cm_1) should in libraries using. bits set shown on page 372 of doc linked. cm_1 example indicates capturing on ris

visual c++ - How does this snippet of Makefile code work? (For using more than 1 compiler) -

so i've got piece of code: sourcefile.$(obj_suffix): sourcefile.cpp $(global_deps) $(report_build) @$(make_deps_auto_cxx) $(elog) $(ccc:icl=cl) $(outoption)$@ -c $(compile_cxxflags:o3=o2) $(compile_cxxflags:arch:sse3=arch:sse2) $(_vpath_srcs) so see compiles specific file vc opposed icl, , changes of flags vc compatible. thing can't find makefile documentation how switch compilers mid-compile. i'm not sure searching let lone being able find documentation it. also, used header files? @ moment i'm encountering error icl won't compile header file, vc will. thanks! this using string substitution hack in 'cl' in place of intel compiler ('icl'). actions in makefile typically defined based on extension of file process; example, how resource compiler gets involved .rc files. in case looks singling out specific file, , modifying variables. since .h file isn't 'compiled' separate entity, won't able use different co

oracle - REGEXP_SUBSTR to update a table -

i trying use regexp_substr update column in table , getting error, missing expression. update p_table set f_name = select regexp_substr ( (select user_name user_info rowid = r_id ('user_info')), '[^ ]{1,15}', 1, 1) dual; when add parentheses before first select , after dual works sets rows in column same value. not need them unique cannot have them same. advice give me. update p_table set f_name = (select regexp_substr ( (select user_name user_info rowid = r_id ('user_info')), '[^ ]{1,15}', 1, 1) dual); as mentioned in @patrickmarchand comment oracle optimizes query, function called once. asktom article makes clear. to workaround must introduce linked p_table rows function parameters force oracle call every row. example rowid p_table : update p_table set f_name = ( select regexp_subst

c# - Send data from website to windows application -

i want know best method send data website windows application. want make video encoder , it'll work this: customer upload videos , when uploading progressed finished website send signal , data (like: video resolution , bit-rate) windows application start encoding videos. want vb.net or c#.net. have .net program listen http requests outside world. when request received, that's signal start encoding. can data (bitrate, ...) query portion of request. example workflow of pure html/.net implementation: create simple html form posts data address encoder hosted. in .net program, create instance of httplistener (see msdn ) act simple web server. when httplistener receives request, send simple "thank you" page (or whatever) , start encoding. somehow notify user when encoding has finished (email?).

javascript - window.opener.location.href permission denied. Possible cross domain issue? -

i have page opens page. the first page has url https://site1.myapplication.net/page2 the second page has url https://site2.myapplication.net/page5 i'm guessing cross domain, didn't think caused subdomains (site1, site2) in same domain. my question : cross domain issue , how fix it? last checked cors not supported browsers. edit: setting document.domain "myapplication.net" seems work have not tested in more 1 browser yet.

javascript - JSON.stringify() fails to work -

Image
this question has answer here: json.stringify serializes [[]] 4 answers javascript json stringify no numeric index include in data 7 answers when trying use json.stringify() method turn array of strings json object can pass through php script, stringify() method fails return of significance. this code input being passed through. not being tampered else. function submititem() { try { var item = []; item.name = $('.itemtext').val(); item.type = $('.itemtype').val(); item.price = $('.itemprice').val(); item.color = $('.itemcolor').val(); item.desc = $('.itemdesc').val(); item.image = $('.itemimage').val(); item.gifttype = $('.itemgifttype').val(); item.avail = $('.itemavail')

c# - RowDataBound Object Not Set to an Instance of an Object -

i have gridview works fine, gives me error "object not set instance of object when edit clicked. i believed because labels in gridview null when in edit mode , causes problem , have no idea how solve this. <asp:boundfield datafield="received" headertext="received" sortexpression="received" readonly="true"> <itemstyle horizontalalign="center" /> </asp:boundfield> <asp:templatefield headertext="complete" sortexpression="complete"> <itemtemplate> <asp:label id="lblcomplete" runat="server" text='<%# bind("complete") %>'></asp:label> </itemtemplate> <itemstyle horizontalalign="center&q

java - Differnece between these tags in a wsdl file <wsdl:types> and <types> -

i trying understand flow of application. have 2 wsdl files, in 1 of wsdl has following representation <wsdl:types> <xsd:schema> <xsd:import> </xsd:schema> </wsdl:types> <wsdl:message> <wsdl:part> </wsdl:message> in wsdl file following specification. <types> <xsd:schema > <xsd:import> <xsd:element > </xsd:element> </xsd:schema> </types> <message name=""> <part /> </message> i know difference between these two. thanks venkat. most probably, in second wsdl default namespace same alias wsdl in first. confirm, post namespace references in both files.

sql - Why does this stored procedure not work? -

i'm not quite sure why stored not working. getting message saying "pl/sql statement not ended". create or replace procedure approveuser ( seuser in users_stock_exchanges.username%type, semanager in stock_exchanges.stock_exchange_manager%type ) begin update users_stock_exchanges set verify_status=1 users_stock_exchanges use inner join stock_exchanges se on use.stock_exchange_id = se.stock_exchange_id use.username = seuser , se.stock_exchange_manager = semanager; end approveuser; there no joins in update statement, see this question , oracle sql documentation . in case write this update users_stock_exchanges use set verify_status = 1 exists (select 1 stock_exchanges se use.stock_exchange_id = se.stock_exchange_id , use.username = seuser , se.stock_exchange_manager = semanager);

linux - Moving or shuffling the vsplit windows left and right -

i using vim editor , have split windows using vsplit . have 3 vertical split windows in a b c order. possible shuffle windows b a c order? use <ctrl-w> + h move selected window far left (upper case h) so if cursor in pane b <c-w>h move b left , take place in middle take @ :h window-moving other options in moving windows around. 5. moving windows around window-moving ctrl-w x ctrl-w_x ctrl-w_ctrl-x ctrl-w ctrl-x without count: exchange current window next one. if there no next window, exchange previous window. count: exchange current window nth window (first window 1). cursor put in other window. when vertical , horizontal window splits mixed, exchange done in row or column of windows current window in. ... ctrl-w_h ctrl-w h

java - JCheckBox does'nt trigger isselected -

i have jpanel, contains jpanel , jbuttons. in inner jpanel have jcheckboxes selected. have added actionlistener jbuttons check, if each of jcheckboxes changed unselected action performs. doesn't work. code, problem be? public limitpanel(string[] dates, int column) { gridlayout layout = new gridlayout(1 + dates.length, 0); setlayout(layout); setcomponentorientation(componentorientation.right_to_left); setvisible(true); this.dates = dates; checks = new jcheckbox[dates.length][column-1]; (int = 0; < dates.length; i++) { (int j = 0; j < column - 1; j++) { checks[i][j] = new jcheckbox(); checks[i][j].setselected(true); checks[i][j] .setcomponentorientation(componentorientation.right_to_left); add(checks[i][j]); } } } public jcheckbox[][] getchecks() { return checks; } in main clas, have method contains: resultset e = connect.select("invi

bigdata - 1 GB Data with key and value, what kind of data structure to store them? 1TB? 1 PB? -

there 1 gb data key , value, kind of data structure store them? if data increase 1tb? 1 pb? need access them every day. , how long need access them? true time? 1 minute? 1 hour? i answered using hashtable in 1gb , 1tb. few seconds take? i'm not sure how calculate true time. when coming 1 pb, can sort data , divide them several part , store them in hashtables . seems interviewer not satisfied answer. seems i'm totally wrong :( imho, choice of structure depends heavily on how memory have. ram totally out of question when 1tb or 1pb. when interviewers ask questions these, trying see how @ logical thinking rather expecting spot-on, exact solution(at least feel this). coming actual question, use distributed platform, hadoop, sreejith has said. in systems hadoop use multiple systems single system in order leverage combined power gain better performance. approach can reduce read/write time compared single machine, if powerful ram , processor. along hadoop provides

javascript - IE10 Video Tag suddenly stopped working -

iv'e got no idea why, ie10 stopped loading video tag on website i'm working on. here's code i've implemented: <video id="video_background" preload="auto" autoplay="autoplay" loop="loop" style="width: auto;height: 100%;"> <source src="video/background.mp4" type="video/mp4" /> <source src="video/background.ogv" type="video/ogg" /> <source src="video/background.webm" type="video/webm" /> <!--[if lt ie 9]> <object id="video_background_1" type="application/x-shockwave-flash" data="http://player.longtailvideo.com/player.swf" style="width: 100%;height: 100%;"> <param name="movie" value="http://player.longtailvideo.com/player.swf" /> <param name="allowfullscreen" value="true" /> <param name="wmode" value="transpa

javascript - Reference an element later in angular -

i have 2 images have select 1 or other , class changes depending on select using ng-click . on proceeding next step, make object , store references selected: $scope.cabinetdetails.cabinettype = { name: $scope.currentelement.obj.name, image: $scope.currentelement.obj.image, ref: $scope.currentelement }; $scope.currentelement whatever image had selected , think later access via: $scope.cabinetdetails.cabinettype.ref let's on step 2 , want make change step one. click breadcrumb go , see step 1 again (this works fine). what i'd happen class changes selected state. on loading step one, this: if ($scope.cabinetdetails.cabinettype != null) { $scope.currentelement = $scope.cabinetdetails.cabinettype.ref; } i imagine preselect image had before since ng-repeat simple check in ng-class portion: <div ng-repeat="obj in currentobject"> <div class="img-select" ng-click="setactive(this)" ng-class="{itemselecte

call php from ajax javascript -

i have php-based template website has been heavily modified. i in process of adding rss feeds, of easy "interpret" , display satisfactorily 1 in caps "pre" formatting well. i want modify content. @ mods make education , invariably able google satisfactory solutions problems come across but, despite earlier extensive programming background, without thorough grounding in javascript, ajax, php, css , html, there things frustrate hell out of me. all want pass block of text javascript code php code, massage , result back. @ point in ajax/jscript function where... items[i].content ...contains block of text want massaged , have piece of code got here, think, ostensibly calls php code... function compute() { var params="session=123"; $.post('wxspellch.php',params,function(data){ alert(data);//for testing if data being fetched var myobject = eval('(' + data + ')'); document.getelementbyid(&quo

java - How to embed c-span videos in my web page -

how can embed c-span videos in web page. c-span api java, or javascript exist. don't want put entire videos web page in iframe. want video embedded in web page, if embedded iframe it. want api can query links , images, , embed videos. thank you! i apologize if not being clear, speak better java english. go video , click on share... there can see "embed code" click on copy embed code , paste website.

Passing color as argument when using StdDraw in java -

having trouble passing color argument if @ possible when using stddraw in java. what passing color variable f.e. "red", "green", "blue" set pen color of drawing function different color each time run through loop. here code more details of trying accomplish. static void drawcirclesizecolor() { string[] mycolorarray = {"red","green","blue"}; double x = 20; double y = 20; double r = 20; int c = 0; (int = 0; <= 3.0; i++) { stddraw.setpencolor(color.getcolor(mycolorarray[c])); stddraw.circle(x, y, r); c++; r--; } hope understand going this thanks -ee import java.awt.color; declare array as: color[] mycolorarray = {color.red,color.green,color.blue}; and use them stddraw.setpencolor(mycolorarray[c)); class java.awt.color has static variables standard colors predefined

ruby - How do I remove backslashes from a JSON string? -

i have json string looks below '{\"test\":{\"test1\":{\"test1\":[{\"test2\":\"1\",\"test3\": \"foo\",\"test4\":\"bar\",\"test5\":\"test7\"}]}}}' i need change 1 below using ruby or rails: '{"test":{"test1":{"test1":[{"test2":"1","test3": "foo","test4":"bar","test5":"bar2"}]}}}' i need know how remove slashes. use ruby's string#delete! method. example: str = '{\"test\":{\"test1\":{\"test1\":[{\"test2\":\"1\",\"test3\": \"foo\",\"test4\":\"bar\",\"test5\":\"test7\"}]}}}' str.delete! '\\' puts str #=> {"test":{"test1":{"test1":[{"test2":"1","test3&q

Call function with arguments without parenthesis in C? -

when function not have argument, possible call without parenthesis define as #define test test() is possible call function argument without paranthesis? like #define test test(char *arg) test "argument 1"; that's not going possible in c way have it. §6.5.2 of standard (c99) describes postfix expressions, , has no syntax that. function calls (§6.5.2.2): a postfix expression followed parentheses () containing possibly empty, comma-separated list of expressions function call. postfix expression denotes called function. list of expressions specifies arguments function. parens not optional, , need wrap arguments need either function-like macro (which requires parens @ "call" site) or 2 separate things (one insert starting paren, 1 insert closing one). you do: #define test puts( #define end ); #define int_proc int #define proc_body { #define proc_end } #define no_args (void) #include <stdio.h> int_proc main no_args proc_body

jsf 2 - Shiro in Java EE 6 application -

i following balusc code manage user authentication in java ee 6 ( http://balusc.blogspot.com/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html ) works great if stay on same web container. i'm facing issue perhaps can me. when injecting ejb resides in web container, securityutils.getsubject() works ok method of ejb. the problem when try on injected ejb container (even ejb jar in same ear). error is: caused by: org.apache.shiro.unavailablesecuritymanagerexception: no securitymanager accessible calling code, either bound org.apache.shiro.util.threadcontext or vm static singleton. invalid application configuration. use case is: managed bean a injected stateless session bean b . class a resides in myapp.war, class b resides in myapp.ejb, both inside myapp.ear. calling securityutils class b . do have clues on how solve this? i running jsf 2, java ee 6, jboss 7.1. well, shiro bind securitymanager threadlocal via shirofilter . @ dofilterinternal me

scala - Instantiating Case Class with Trait -

how can instantiate tree per below trait , case classes? sealed trait tree[+a] case class leaf[a](value: a) extends tree[a] case class branch[a](left: tree[a], right: tree[a]) extends tree[a] source: functional programming in scala example: how code following tree of type string ? "top" / \ "middle-left" "middle-right" / \ "bottom-left" "bottom-right" with class hierarchy have given wouldn't able create resembling example tree want, because branch can accept left , right sub-trees, not value (the text "top"). if want branch nodes have value, modify class hierarchy follows: sealed trait tree[+a] case class leaf[a](value: a) extends tree[a] case class branch[a](value: a, left: option[tree[a]] = none, right: option[tree[a]] = none) extends tree[a] note option-al nature of sub-trees, default of none, allowing missing left or right sub-trees without r

mysql - MAX with extra criteria -

i have following part of query i'm working on in mysql. select max(cast(matchplayerbatting.batruns signed)) highestscore matchplayerbatting it returns correct result. there column need work off. that if maximum value finds has value of "not out" within "bathowout", should show result example 96* rather 96. how done? to make data concrete, consider 2 cases: batruns bathowout 96 not out 96 lbw batruns bathowout 96 not out 102 lbw for first data, answer should '96*' ; second, '102' . how ordering scores in descending order , selecting first record? select concat(batruns , case when bathowout = 'not out' '*' else '' end) mytable order cast(batruns signed) desc, (case when bathowout = 'not out' 1 else 2 end) limit 1; sample here . if want find highest score score each player, here solution may not elegant, quite effective. select playerid,

Convert String array to json in android -

i have problem. want pass string array javascript, impossible, want convert string array json , send java script. how can that? just convert use jsonarray, import java.util.arrays; import org.json.jsonarray; string[] inputs = new string[] {"foo", "bar"}; jsonarray jsonarray = new jsonarray(arrays.aslist(inputs));

c# - ListBox not correctly changing ContentControl's ViewModel -

i'm still pretty new wpf , decided change application developing start following mvvm pattern best could. running problem when try have list box dictate view model of content control. i've been stuck on while , searching internet not producing answers me. for reason new instance of view model list box contains being generated data context of content control. when debugging made sure list box contains view models should, , item select on list box indeed item list box selecting, content control changing based on selection. there view model populating content control, not in collection list box populates from. , can somehow delete view model in content control via remove button. when make selection change on list box, or add new item collection populates content control new view model once again not in collection. have no clue why doing this, or in code suggest behavior. i made simple application try , figure out i'm doing wrong. replicates problem perfectly. i'm p

JQuery UI Draggable & Droppable "Revert" and "Out" conflict -

i trying make multiple items draggable can dragged 1 droppable. if dropped outside of droppable revert. of code works except 1 bug: user drags item droppable. drags out (executes out function) fails drop in droppable (revert happens, drag goes previous droppable). has happened droppable can accept drag (since drag left, executing out) while drag never left due revert. i have been trying resolve several of hours , have gone through api. tried have callback function revert due confusion on how retrieve draggable's droppable, stuck. //revert if not dragged draggable. $( "[id|=drag]" ).draggable({ revert: 'invalid', revertduration: 350 }); $( ".dropzone" ).droppable({ drop: function(ev,ui) { $(this).droppable('option', 'accept', ui.draggable); //only accept current drag. }, out: function(ev, ui) { $(this).droppable('option', 'accept', '[id|=drag]');//now can accept drag. } })

php - insert into with 2 joins? -

i have 1 table auction_activity_notifications need insert id users table , column item_watch , need join email_templates table , need insert auction_activity_notifications i make query inserting id of user , item_watch column , need join email_templates , insert id email_templates auction_activity_notifications insert auction_activity_notifications (id_user, id_target) select id, item_watch users u left join auction_activity_notifications aa on u.id = aa.id_user , u.item_watch=aa.id_target i have these columns in auction_activity_notifications and in end need insert current date created_date_time id_email_templates, id_user , id_target , created_date_time add 1 more join in query insert auction_activity_notifications (id_email_templates,id_user, id_target,created_date_time) select et.id,u.id, u.item_watch ,now() users u left join auction_activity_notifications aa on u.id = aa.id_user left join email_templates et on (aa.id_email_template

Detect Hardware information in C++ application? -

i want determine hardware information cpu, ram, hard disk, gpu, etc. application in c++ built on qt. how information? thank you. edit: looks there no platform independent way this. please can list code prominent os windows, osx & ubuntu? edit: talking basic information processor speed, amount of ram available, hard disk speed, gpu speed & memory. ms provides functions these informations programmatically (include windows.h): bool winapi getphysicallyinstalledsystemmemory( _out_ pulonglong totalmemoryinkilobytes ); retrieves informations ram, see documentation . bool winapi getdiskfreespaceex( _in_opt_ lpctstr lpdirectoryname, _out_opt_ pularge_integer lpfreebytesavailable, _out_opt_ pularge_integer lptotalnumberofbytes, _out_opt_ pularge_integer lptotalnumberoffreebytes ); retrieves information amount of space available on disk volume, see documentation . system_info sisysinfo; // copy hardware information system_info structure. getsyst

Does Glassfish v4 support SSL SNI? -

i'd provide webhosting service on vps running glassfish v4. means many domains 1 shared ip address of vps. know there problems ssl certificates of many domains 1 ip , sni extension may solve problem (right?). question is, whether glassfish supports this. thanks according glassfish 4 security guide, https://glassfish.java.net/docs/4.0/security-guide.pdf , there not support sni. however, it's bad practice imo (though still debated many), expose glassfish directly internet. i solve problem running apache server mod_ajp_proxy , connected jk-listener on glassfish.

Javascript Objects (dynamic attribute names) -

if have object, this var o = { test : 1 } and have second object, 1 of it's keys should value of o.test. this: var o2 = { o.test : "bla" } i know not possible, there better (cleaner) way do now? currently dow this: var o2 = {}; o2[o.test] = "bla" i guess there better way this? i guess there better way this? assuming i've understood question correctly no, not really. way you've shown way it. there no way use dynamic key inside literal itself, have declare first , assign property separately: var o2 = {}; o2[o.test] = "bla"; o2; // { 1: "bla" } update the full details given in spec . here's grammar object literal property identifiers: propertyname :      identifiername      stringliteral      numericliteral the stringliteral production self-explanatory. here's identifiername production does: the production propertyname : identifiername evaluated follows:

xamarin.ios - call webservice using NSMutableURLRequest in monotouch -

i try save capture image iphone server. done xcode. code like nsmutableurlrequest *request= [nsmutableurlrequest requestwithurl:url]; [request sethttpmethod:@"post"]; nsstring *boundary = @"---------------------------14737809831466499882746641449"; nsstring *contenttype = [nsstring stringwithformat:@"multipart/form-data; boundary=%@",boundary]; [request addvalue:contenttype forhttpheaderfield: @"content-type"]; nsmutabledata *body = [nsmutabledata data]; [body appenddata:[[nsstring stringwithformat:@"--%@\r\n", boundary] datausingencoding:nsutf8stringencoding]]; [body appenddata:[[nsstring stringwithformat:@"content-disposition: attachment; name=\"%@\" filename=\"test.png\"\r\n", imgname] datausingencoding:nsutf8stringencoding]]; [body appenddata:[@"content-type: application/octet-stream\r\n\r\n" datausingencoding:nsutf8stringencoding]]; [body appenddata:[nsdata datawithdata:imagedat

java - Print out the entries from the map when the value gets changed -

i working on project in need print out data database in way. let's take example, suppose in database, have below entries only- framework 1.0.0 bundleb 1.0.0 bundlec 1.0.0 then java method make call database return me map of above data. my map have above data below- key framework, value 1.0.0 key bundleb, value 1.0.0 key bundlec, value 1.0.0 suppose, started program first time, print out below code have, fine. framework - 1.0.0 and running background thread every 2 seconds make call database , data again database. , every 2 seconds, print out same thing below- (which not want) framework - 1.0.0 i want print out framework - 1.0.0 first time when running program second time when background thread running, should print out when version gets changed framework, otherwise don't print out anything. meaning after time, if changes version information in database this- framework 1.0.1 bundleb 1.0.0 bundlec 1.0.0 then should print out this- framework - 1.0.1

mysql - SQL Limit + count -

i'm tracking visitors of site using table: visitors table in admin panel, have overview of countries visited site, came from, ..., because on 20+ different countries have visited site already, chart looks this: messed chart to solve this, want select top 5 countries, have no clue on how this. i've tried using limit & count no luck. maybe shoule use order by. exam:select * visitors order day limit 5; hope you

cocoa - NSView won't draw through bezierpath -

dear fellow cocoa programmers, what i'd accomplish: i have checkbox, popupbutton(which hidden) , nsview on canvas. if mycheckbox checked -> show popupbutton , draw line through bezierpath on nsview. if mycheckbox unchecked -> hide popupbutton again , "undraw" path the code: - (ibaction)ischecked:(id)sender { //if mychekcbox checked, show pop button if ([sender state]==nsonstate) { nslog(@"checked"); [mypopup sethidden:no]; } else { //if checkbox unchecked, hide popupbutton [mypopup sethidden:yes]; nslog(@"unchecked"); } //reload drawrect method (reload view) [self setneedsdisplay:yes]; } - (void)drawrect:(nsrect)dirtyrect { //if checkedbutton checked, draw line if ([mycheckbox state]==nsonstate) { nsbezierpath *mypath = [nsbezierpath bezierpath]; [mypath movetopoint:nsmakepoint(10, 20)]; [mypath linetopoint:nsmakepoint(50, 20)]; [mypath setlinewidth:2]; [mypath stroke];

html - Clear float last li element for ie6 and 7 -

i have following html menu <ul> <li id="btnhome"><a href="#">link one</a></li> <li id="btnabout"><a href="#">link two</a></li> <li id="btncontact"><a href="#">link three</a></li> <li id="btnlinks"><a href="#">link four</a></li> </ul> and following css it ul { margin: 0; padding: 0; } ul li { list-style-type: none; } #nav { background: #999; padding: 2%; } #nav ul li { float: left; margin-right: 2%; } i use above ie6 , 7 in order display links in single row. float: left displays menu items in row changes style #nav div , menu items not appear inside #nav div anymore. how can fix issue ie6 , 7? note: using display: inline-block modern browser , works fine. you use css declaration zoom: 1; #nav element trigger haslayout on ie