Posts

Showing posts from January, 2013

c++ - Traversing a multi array with pointers -

for ( j = 0; j < d1; j++ ){ m += j; ( = 0; < d1*d2; +=d2){ cout << *(m+i); } cout << endl; } d1,d2 array dimensions and int* m = new int [d1*d2]; i want traverse on array , group , print columns.can't figure what's wrong code.seems working fine untill 3rd iteration in following example: let's input values 1 2 3 4 5 6 7 8 9 i get: 1 4 7 2 5 8 4 7 (something random) in m += j; you first incrementing m 0, one, 2. if took copy int *start = m; then in first iteration of outer loop, we'd have m == start in second, m == start + 1 in third m == start + 3 you'd want m == start + 2 there. except want keep m in order delete @ end, shouldn't change m @ use like for ( j = 0; j < d2; j++ ){ ( = j; < d1*d2; +=d2){ cout << *(m+i); } cout << endl; }

javascript - change selected option of dropDown using jQuery -

i have dropdown on change popup appears warning change value affects. when user select no dropdown selected index supposed return initial selected option. here do: function closedeletevariantspopup(){ parent.$.fn.colorbox.close(); var elementspecies= parent.document.getelementsbyclassname("speice"); for(var = 0;i<elementspecies[0].options.length; ++i) { alert(parent.document.getelementbyid("specieshiddenvalue").value); if(elementspecies[0].options[i].id === parent.document.getelementbyid("specieshiddenvalue").value) { alert(parent.document.getelementbyid("specieshiddenvalue").value); elementspecies[0].selectedindex = i; break; } } } html & freemarker: [@spring.bind "genomicreferencebean.specie.id"/] <select name="specie.id" id="specie.id" [#if !(genomicreferencebean.specie?has_c

d3.js - Donut chart with tick mark lines (d3) -

Image
i have 3 donut charts var data = [ { institution: [53245, 28479, 19697, 24037, 40245] }, { institution: [45, 9, 127, 37, 11] }, { institution: [3245, 88479, 45697, 1037, 77245] } ] var width = 100, height = 100, radius = math.min(width, height) / 2; var color = d3.scale.category20(); (index = 0; index < data.length; ++index) { var pie = d3.layout.pie() .sort(null); var arc = d3.svg.arc() .innerradius(radius - 30) .outerradius(radius - 5); var svg = d3.select("body").append("svg:svg") .attr("width", width) .attr("height", height) .append("g") .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); var path = svg.selectall("path") .data(pie(data[index].institution)) .enter().append("pat

javascript - Making a canvas as a background doesn't perform as anticipated -

so in question under impression using canvas background faster,or same speed using canvas tag. have rather bulky script running simulator. javascripting reasons cannot make menu using javascript without detracting simulation had planned use html make menu swipe side of screen. working on stumbled on above link; when run program using background method runs slower. there reason this, , there solution? here relevant portions of code: html <html> <head> <title>curtain sim 2013 </title> <link href="global.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="main.js"></script> <script type="text/javascript" src="fabric.js"></script> <script type="text/javascript" src="background.js"></script> <script type="text/javascript" src="savdat.j

javascript - return value after callback function Not Working -

this question has answer here: how return response asynchronous call? 21 answers i don't know below valid question? or stupidity. function isslaexists(department) { var flag = ""; $.ajax({ type: "post", data: "type=isslaexists&department=" + encodeuri(escape(department)), url: "class-accessor.php", success: function (data) { //flag=data; flag = "yes"; } }); return flag; } alert(isslaexists('department')); i'm trying return value of flag function returns blanks if set value of flag maually. i'm doing wrong? $.ajax({ type: "post", data: "type=isslaexists&department=" + encodeuri(escape(department)), url: "class-accessor.php" }).done

html - I need to replace a div with another div using jQuery -

<div id="main"> <div id="abc"> <div> div replaced </div> </div> <div id="xyz" style="display:none"> <div> div replaced </div> </div> </div> i've given $('#main').children('div:eq(0)').css('display','none') $('#main').children('div:eq(0)').replacewith($('#xyz').html()) but, if see output, <div>this div replaced</div> alone , not parent div of i.e <div id="xyz"> i think should want: $('#main div:first').html($('#xyz').html())

hadoop - Reducer takes more time after 92% -

i have bulk load job using hfileoutputformat load hbase table. mapper completes within 2-3 mins , reducer(putsortreducer invoked hfileoutputfomat) completes till 92% in next 2 mins, takes around 9 mins complete remaining 8% totally 10 reduce tasks spawned in job, of 8 or 9 tasks completes within 2-3 mins , remaining 1 or 2 tasks take 9 mins. , these 1 or 2 last tasks ones restarted in place of failed tasks. logs don't show evident errors reason of failed tasks

qt - QTableWidget, cellClicked and cellDoubleClicked -

i have qtablewidget row selection, , i'm trying treat 3 signals: cellclicked celldoubleclicked customcontextmenurequested things seem fine in code: had in mind connect syntax, type params correct , match, etc; , more specific, "know" code correct because have following situation: if connect 3 signals respective slots, single click , context menú work. if connect 1 signal each time compile code , run program, signal working (for 3 of them). if connect single click signal , context menu, commenting connect macro double click, work well. same double click , context menu. but if connect single click , double click, double click not being treated custom slot. just clarify, each signal has different slot, , meantioned above, work if connect 1 of them , comment other 2 in code. so question is: there bug cellclicked , celldoubleclick working simultaneously? have set flag, attribute or whatever belongs qtablewidget? i'm running out of ideas, help!

java - Using JTextField in a JApplet -

this first time messing japplet.. i'm trying make jtextfield() work properly... no matter cant show on page! import java.awt.*; import javax.swing.*; public class hangman extends japplet{ private static final long serialversionuid = -3966472303224962681l; public void paint(graphics g){ super.paint(g); container c = getcontentpane(); jtextfield input = new jtextfield(20); c.setbackground(color.black); g.setcolor(color.white); g.setfont(new font("arial", font.bold, 30)); g.drawstring("welcome hagman applet web!", 20, 30); g.setfont(new font("arial", font.italic, 18)); g.drawstring("also available on android.", 20, 50); c.add(input); input.gettext(); } } you should not add components applet in "paint" method. f.e. in constructor: public hangman() { container c = getcontentpane(); c.setbackground(color.blac

javascript - How can I easily set a variable to false with a default of true? -

i set object properties so, // boolean this.listening = config.listening || true; but config.listening either true or false, , in case this.listening true because if config.listening false equal true. is there better way set these boolean properties without having if statement? is there if isset function in javascript check exists rather equals to? you use ternary (conditional) operator this: this.listening = config.listening === false ? false : true; if config.listening false , this.listening set false . if it's other value, it's set true . if want check if it's defined, use: this.listening = typeof config.listening !== "undefined" references: https://developer.mozilla.org/en-us/docs/javascript/reference/operators/conditional_operator

c++ - GetKeyboardLayout returns strange layout -

getkeyboardlayout(0) seems have decided thread using kind of mixture of lang_german , sublang_german , lang_english , sublang_english_us . i've tried putting in new project, problem persists... here's code i've used test it. #include <iostream> #include <windows.h> #include <kbd.h> int main(int argc, char* argv[]) { std::cout << "keyboard layout id: " << getkeyboardlayout(0) << "\n"; std::cin.ignore(100, '\n'); return 0; } that keeps returning 04070409 though don't think should possible. (or it? if yes how construct makelangid ?) maps mixture of languages above according msdn . i've tried using loadkeyboardlayout makelangid(lang_german, sublang_german_austrian) standard lang_english, sublang_english (04090409) layout. have read docs wrong , messed something, or what's happening here? i'm out of ideas... this explained in documentation getkeyboardlayout . i'

javascript - dataset property doesn't work with objects? -

el2.dataset.stuff = document.getelementbyid('el1'); doesn't seem work. i need able access innerhtml property of el1, later. el2.dataset.stuff = document.getelementbyid('el1').innerhtml; works, don't idea of storing duplicate content in variables. if have many elements, eat lot of memory. i guess because dataset requires strings? if that's true, how set reference elmement inside el2 ? actually can store strings in dataset attributes definition. so in case either should have separate data-structure (which should accessible in both needed scopes) store reference this: var mypointers = { 'el2': { 'stuff': document.getelementbyid('el1') } }; // later var el1 = mypointers.el2.stuff; or store id of el1 , retrieve actual element, when needed: el2.dataset.stuff = 'el1'; // later var el1 = document.getelementbyid( el2.dataset.stuff );

c++ - Why does Pascal Script expect another semicolon near my external-function declaration? -

i have written function in c++, making dll: functions.h: #ifndef functions_h #define functions_h int dllsquare(int x); #endif /* functions_h */ functions.cpp: #include "functions.h" int dllsquare(int x){ return x*x; } i compiled dll. import pascal script: program testdll; function square(x: integer): integer; external 'dllsquare@libtestdll.dll'; begin end. now doesn't compile. get: (7:1): semicolon (';') expected @ line 6 compiling failed. several tutorials on internet tell me way go, missing here? pascal script throw "semicolon expected" error if declare external function , don't have handler assigned onexternalproc event. you can implement yourself, or can use dllexternalproc upsc_dll unit. consider calling registerdll_compiletime on compiler component, assigns onexternalproc event , registers 2 functions scripts call, unloaddll , dllgetlasterror . although it's understandable ra

Spring JMX and OC4J MBean notifications, can't enable -

i'm deploying spring application oc4j, keep encountering strange problem whereby can access exposed mbeans, use attributes , operations. notifications can been seen under tab, not used there should checkbox present apply button subscribe. isn't present , instead boolean value of false shows i'm not subscribed notification. here spring config use register mbeans: <bean id="test" class="com.app.jmx.homecontroller"/> <bean id="mbeanserver" class="org.springframework.jmx.support.mbeanserverfactorybean"> <property name="defaultdomain" value="mbeanserver" /> </bean> <bean id="exporter" class="org.springframework.jmx.export.mbeanexporter"> <property name="autodetect" value="false" /> <property name="server" ref="mbeanserver" /> <property name="beans"> <map>

python - Is there a way to print out output in a pyramid view callable? -

i new python , pyramid , trying figure out way print out object values using in view callable better idea of how things working. more specifically, wanting see coming out of sqlalchemy query. dbsession.query(user).filter(user.name.like('%'+request.matchdict['search']+'%')) i need take query , office user belongs office_id attribute part of user object. thinking of looping through users come query , doing query office information (in offices table). need build dictionary includes user information , office information return browser json. is there way can experiment different attempts @ while viewing output without having rely on browser. more of front end developer when writing javascript view outputs using console.log(output). console.log(output) javascript as ????? python (specifically pyramid view callable) hope question not dumb. trying learn. appreciate anyones help. this reason experiment pshell , pyramid's interactive python

activerecord - Rails combine results of multiple includes statements -

the scenario need generate notifications on updates. have updates possible on 3 tables namely products, users , notifications. user can "follow" of 3 things , if there updates in either of three, user should notified. the relations are notification belongs user notification belongs nook notification belongs product product has many followers(followers relation user table) user has many followers nook has many followers when try user id = 1: notification.includes(:product => :followers).where("relations.follower_id = ?", 1) notification.includes(:user => :followers).where("relations.follower_id = ?", 1) notification.includes(:nook => :followers).where("relations.follower_id = ?", 1) all above 3 work fine when executed individually. but when do: notification.includes(:product => :followers, :user => :followers, :nook => :followers).where("relations.follower_id = ?", 1) it not give me desir

oop - How to pass by reference in ActionScript? -

i'm trying modify object in class. have this: mainclass.as : .. var myobject:object = new object(); class2_instance.get_json(myobject); trace(myobject.id); // output: undefined. whereas should 42. see below. .. class2.as public function get_json(url:string , the_object:object) { var request:urlrequest = new urlrequest(url); var variables:urlloader = new urlloader(); variables.dataformat = urlloaderdataformat.text; variables.addeventlistener(event.complete, complete_handler_json(the_object)); try { variables.load(request); } catch (error:error) { trace("unable load url: " + error); } } function complete_handler_json(the_object:object):function { return function(event:event):void { var loader:urlloader = urlloader(event.target); the_object = json.parse(loader.data); trace(the_object.id); //returns 42. }; } so json operation performs correctly within class2, , assi

unix - How to print column offset within each matching line in grep -

by passing -o -n grep can output matching parts of pattern within file, , line number on each match found. how can print column offset within line @ pattern found? i think able mimic same thing you're doing awk. referencing awk manual: http://www.staff.science.uu.nl/~oostr102/docs/nawk/nawk_92.html here's file looks like: this,is,a,test,line this, ,a,test,line,with,the,second,field,blank this, is,another,test,line,with,a,blank,in,the,second,field,but,the,field,isnt,blank this, ,is,another,line,with,a,blank,second,field and here's command ran: awk '{regex = "test"; = match($0, regex); print "regex: ",where," on line ",nr}' test and output: regex: 11 on line 1 regex: 10 on line 2 regex: 18 on line 3 regex: 0 on line 4 i did quick , dirty, i'm hoping helps enough need be.

Exception in thread “main” java.lang.StackOverflowError -

errors when compile file no errors when try execute following messages: exception in thread "main" java.lang.stackoverflowerror @ sun.awt.suntoolkit.isinstanceof(suntoolkit.java:1988) @ sun.awt.suntoolkit.isinstanceof(suntoolkit.java:1997) @ sun.awt.suntoolkit.isinstanceof(suntoolkit.java:1997) @ sun.awt.suntoolkit.isinstanceof(suntoolkit.java:1997) @ sun.awt.suntoolkit.isinstanceof(suntoolkit.java:1997) @ sun.awt.suntoolkit.isinstanceof(suntoolkit.java:1997) @ sun.awt.suntoolkit.isinstanceof(suntoolkit.java:1982) @ javax.swing.lookandfeel.installproperty(lookandfeel.java:275) @ javax.swing.plaf.basic.basicbuttonui.installdefaults(basicbuttonui.java:102) @ javax.swing.plaf.metal.metalbuttonui.installdefaults(metalbuttonui.java:80) @ javax.swing.plaf.basic.basicbuttonui.installui(basicbuttonui.java:88) @ javax.swing.jcomponent.setui(jcomponent.java:664) @ javax.swing.abstractbutton.setui(abstractbutton.java:1807) @ javax.swing.jbutton.updateui(jbutton.java:146) @ javax.

ember.js - itemController and bindAttr not working -

i have following code in emblem.js template: each line_items itemcontroller=lineitem .line_item.row-fluid.popover_link id="line_item_#{unbound id}" click="lineitemselected" class={selected ordered} .span8 = product.name if notsingleitem span.quantity &nbsp x #{quantity} a model: app.lineitem = ds.model.extend quantity: ds.attr 'number' #this duplicated reason product_price: ds.attr 'number' order: ds.belongsto 'cluey.order' product: ds.belongsto 'cluey.product' total: ember.computed -> @get('quantity') * @get('product_price') .property('quantity', 'product_price') notsingleitem: ember.computed -> @get('quantity') != 1 .property('quantity') div_id: ember.computed -> "line_item_" + @get('id') .property() ordered: ds.attr 'boolean', { defaultvalue: false } should_print: ds

sql - How to eliminate duplicate rows joining on tables across databases? -

Image
i have been working on script while , have reached dead end. script works unfortunately produces duplicates. script joins 2 different tables across databases on state_issue_teacher_id key , produces output. have checked both tables , row counts same , join should match records evidently there problem key or way i'm joining table , output coming partially incorrect. i've tried concatenating attributes make unique key , join tables still producing incorrect results. here script: select ltrim(rtrim(rt.year_time)) 'year_time' , ltrim(rtrim(rt.state_issue_teacher_id)) state_issue_teacher_id , ltrim(rtrim(rt.district_code)) district_code , rt.district_name , rt.school_name , ltrim(rtrim(rt.assignment_code)) assignment_code , rt.assignment_desc , ltrim(rtrim(rt.position_code)) position_code , rt.position_desc , ltrim(rtrim(rt.last_name)) last_name , ltrim(rtrim(rt.first_name)) first_n

java - How to do common Exception handling -

lets have hundred classes method signature, entry exit method class : public map<string,object> dosome(map arg1, map arg2) and within method body there try/catch block. catch block catches exception , rethrows custom exception. earlier program abandon in catch block. need able return map has key value ("exception", "some went bad in class"). 1 way make additional method within dosome method (and push current code new one) , surround method call try/catch , in catch block catch custom exception , write generic method populate returning map best way achieve of 100+ classes ? wondering if such thing can achieved using spring aop ? of spring advices come across dont allow returning of values (meaning control never bubbles exception thrown from). great if can point me specific examples. this sounds can solved functionality provided parent class. have each of 100 classes ( really, 100??! ) extend abstract parent class. have parent class defin

algorithm - Is there any other way to calculate X value in coords of other coord system? -

Image
sorry, weird topic name, don't know how else name it. the problem is.. have zedgraph control. there lines drawn inside. i have coords of left border of chart area , right border of chart area. i draw vertical lines pictureboxes on zedgraph control, moves in different coords. vertical lines can moved left , right. that way trying x value in coords of xaxis: public double get_x_incontextofchart(int left_coord_of_border) //left of vertical line { //zed_graph.graphpane.xaxis.scale.min minimal x value shown on xaxis //zed_graph.graphpane.chart.rect.left left of yaxis //same else if, aside of using right , maximum x @ right if (zed_graph.graphpane.xaxis.scale.min != 0) //to avoid division 0 return (left_coord_of_border * zed_graph.graphpane.xaxis.scale.min) / zed_graph.graphpane.chart.rect.left; else if (zed_graph.graphpane.xaxis.scale.max != 0) return (left_coord_of_border * zed_graph.graphpane.xaxis.scale.max) / zed_graph.graphpane.char

In FTP, how do I copy a remote file to other directories -

using ftp commands want upload large file once , copy file many directories on remote ftp server. copy commands seems relate copying local remote or other way around. is there ftp command copy remote remote? are trying move file? if yes, can using rename command move file, copy guess still have the get,send local-remote way. as move command should this rename /oldpath/file2move.txt /newpath/file2move.txt basically rename file path infront of file wish move.

.net - How to ensure dates are in correct format for OleDbCommand parameters? -

when execute code below against mdb database, data table empty, when run in query tool against database returns 2 records. what problem? is issue date format of parameters (ie. 8/5/13 vs 5/8/13)? using odb oledbconnection = getdbconnection() using ocmd new oledbcommand("select * " & _ " table1, table2" & _ " (table1.date between @date1 , @date2) , (table1.id null) , (table2.number = table1.num) , (table1.code1 = table2.code1) ", odb) ocmd.parameters.addwithvalue("@date1", date.today) ocmd.parameters.addwithvalue("@date2", date.today.adddays(me.intdaysahead)) odb.open() dt = new datatable() using da oledbdataadapter = new oledbdataadapter(ocmd) da.fill(dt) end using end using end using i think right. recommend specify parameter type oledbtype ocmd.parameters.add("@date1", oledb.oledbtype.date).value = dat

asp.net mvc - Can WebSecurity work in WCF services? -

i new in simplemembership model. websecurity works fine in web pages, have problems when use in services. i have web services, working under: <binding name="securebasicbindingwithmembershipconfig"> <security mode="transportwithmessagecredential"> <transport clientcredentialtype="none" /> <message clientcredentialtype="username" /> </security> </binding> i try recover user id web service. if use websecurity.isauthenticated , returns isauthenticated = 'webmatrix.webdata.websecurity.isauthenticated' threw exception of type 'system.argumentnullexception' however, using system.web.security.membership.getuser() user id correctly returned. can websecurity used within wcf service or doing wrong?

c++ - Vector comparison with string -

i have string vector of user-input data containing strings. need make sure program won't execute if strings different specified few. vector contains 4 fields , every has different condition: vector[0] can "1" or "0" vector[1] can "red" or "green vector[2] can "1", "2" or "3" vector[3] can "1" or "0" i tried writing if every condition: if(tokens[0]!="1" || tokens[0]!="0"){ decy = "error"; } else if(tokens[1]!="red" || tokens[1]!="green"){ decy = "error"; } else if(tokens[2]!="1" || tokens[2]!="2" || tokens[2]!="3"){ decy = "error"; } else if(tokens[3]!="1" || tokens[3]!="0"){ decy = "error"; } else{ switch(){} //working code } return decy; it enters first if , returns error. tried if instead of else if doesn't work either. checked vec

css - jQuery .show() only works for a split second -

i have div <div id="fade_bg"> <div id="login_div"> <form action="../classes/login/authenticator.php" method="post"> <p>username: <input type="text" name="username" /></p> <p>password: <input type="password" name="password" /></p> <p><input type="submit" name="login" /></p> </form> <p><a id="cancel" href="#">cancel</a> </div> </div> that want show when <a id="login" href="">admin login</a> is clicked. used $(function() { $('a#login').click(function() { $('#fade_bg').show(); $('#login').hide(); }); $('a#cance

c++ - Can't initialize valarray as private member of class -

i'm trying implement class contains valarray , 2 ints define size. hpp file looks this: class matrix { public: // constructors matrix(); matrix(int width, int height); // mutators void setwidth(int width); // post: width of matrix set void setheight(int height); // post: height of matrix set //void initva(double width); // accessors int getwidth(); // post: returns number of columns in matrix int getheight(); // post: returns number of rows in matrix // other methods //void printmatrix(const char* lbl, const std::valarray<double>& a); private: int width_; int height_; std::valarray<double> storage_; }; however, when try initialize valarray on constructor this: matrix::matrix(int width, int height) { width_ = width; height_ = height; storage_(width*height); } i keep getting error message: error c2064: t

javascript - Expect.js validation issue on Codeacademy Lesson -

i creating lesson on codeacademy enables users learn creation of html forms. own entertainment, we're on same page. after reading submission test guidelines , api decided use expect.js handle bulk of validation since need traverse dom. so lesson creating asks users create two label elements (with content inside label tags) , two input fields (with type attribute defined , value set text ). again, criteria follows: create 2 <label> elements inside <form> element. sure indicate user filling out! create 2 <input> elements below each of <label> elements. sure include , define type attribute! let's assume have following code: <!doctype html> <html> <head> <title></title> </head> <body> <form> <label>foo</label> <input type="text"> <label>bar</label> <!-- should below her

c++ - Is there a container ordered by primary and secondary keys? -

i looking qmultimap qt library, 2 keys. i able these things: template<tprimarykey, tsecondarykey, titem> class container; ... container<int, int, std::string> container; container.insert(2, 2, "pear"); container.insert(1, 1, "apple"); container.insert(1, 2, "orange"); (auto = container.begin(); != container.end(); ++it) std::cout << *it << std::endl; and output be: apple orange pear that items sorted according tprimarykey , when there more items same tprimarykey sorted tsecondarykey . is there freely available container similar functionality? for stl, make map key pair: std::map< std::pair<int, int>, std::string > container; you might still able use pair qt container, though won't have quite same interface suggested.

kernel - Page Fault Exception Handlers and Updating Page Tables -

in reading how page faults , page hits handled page fault exception handler, 1 thing wasn't clear me. if process using shared page , page fault happens, when page fault exception handler updates page table entry in page table process caused page fault, update page table entries in of other processes share same page? reading on topic seems updates page table entry in page table faulting process how other processes know that page has been paged in? in advance! this 1 of issues have address in design of memory manager. 1 possible design have shadow pte every page can shared. when process faults on shared page, memory manager checks shadow pte. if shadow pte not resident, handles page fault in normal way, updating both faulting processes pte , shadow pte when page available. if shadow pte resident copies shadow pte process pte. way process ptes updated when process touches page. how think windows - knowledge of linux limited, since every page in linux process can shared @

php - phpMyAdmin Drop Query Affecting Multiple Databases -

i have 2 databases: 1 of i'm using on dev server , other live version have exported dev database , imported live one. i needed go , clear out old dev database, , going import else afterwards. went , checked tables , did drop query, reason, dropped tables both dev database , live database. luckily, had backups of everything, tell me why happening? here query, created when 'check all' tables , select 'drop'. using wordpress here. drop table `wp_commentmeta`, `wp_comments`, `wp_layerslider`, `wp_links`, `wp_options`, `wp_postmeta`, `wp_posts`, `wp_revslider_sliders`, `wp_revslider_slides`, `wp_slp_rep_query`, `wp_slp_rep_query_results`, `wp_store_locator`, `wp_terms`, `wp_term_relationships`, `wp_term_taxonomy`, `wp_usermeta`, `wp_users`; you in comments dev replicated live. drop table statements replicated other statement. it's really, bad idea have automated database replication dev live.

c++ - What does it mean that thread_local is not used inside thread? -

there code: int thread_local y = 4; int main() { y++; return 0; } what mean variable y used not in thread (in main function) - there no threads spawned? main thread counted "normal" thread? is main thread counted "normal" thread? yes.

sorting - Which Collection framework to sort Objects -

here class class emp { string firstname; string lastname; int sal; ----------- } here have list of 100 employees, want sort objects based on salary , first name & last name. using collection frame work how can ? related how dictionary works ?? .net has several collection task. list you can create list entities , sort them method sort . example how sort on salary (assuming fields public): list<emp> empcollection= new list<emp> { new emp { sal = 1000, firstname = "chris", lastname = "bakker" }, new emp { sal = 1500, firstname = "bea", lastname = "smith" }, // etc. }; empcollection.sort((a,b) => a.sal.compareto(b.sal)); pro's , con's: pro: resort collection on key. con: although list sorted, cannot search through if faster on key. sorteddictionary you use sorteddictionary. dictionary combination of keys , values. value, in case, employee. key

java - Reload JFrame with JLabel -

i have jframe contains jlabel use display image background of jframe . path image javabean changing constantly, controlled class file. need jframe reload every second keep jlabel image date. i have looked using timer refresh jframe not sure how implement . i sorry cannot post attempts have made can't figure out how use time reload jframe . thanks

java - How can I make a gif out of a .png containing several frames? -

i need automatically convert animated .gif .png file containing several frames. know how many frames each file contain. images have transparency, no alpha channel. frames sorted vertically, although guess won't make difference. since don't have enough reputation seems can't upload pics, can figure. is there library can use? i'm pretty new java , i'm stuck this. thanks. what need crop big png several small images (frames), , build animated gif. meet imagemagick .

multiple mail recipients with CakePHP using bcc (the right insert method) -

i use php framework cakephp create web app. there,i want user insert in field many email addresses desires , hitting send button,a message emailed of emails. to achieve that,i have use bcc. my problem not know how can "read" user email addresses in right form use them in bcc. till now,i have variable $to = $this->request->data['mail']['to']; ,where 'mail' model name,and in case user inserts 1 email address,the recipient receives mail correctly. how can enable receive multiple email addresses (maybe in array??) use variable $to @ piece of code: $email = new cakeemail(); $email->from($from) ->**bcc($to)** ->subject($subject) ->send($message); and welcomed :) thank in advance! there api ( http://api.cakephp.org/2.3/class-cakeemail.html#_addbcc ) , code open source. provide information looking for. if open class cakeemail find ( https://github.com/cakephp/cakephp/blob/master/lib/cake/network/email/

c# - Why does RedirectToAction redirects to <param>.com -

we have mvc4 site homecontroller.index() has following code redirectiontoaction("page", new { id = "home" } ); where action page defined as public actionresult page(string id) ..... on debug, starts localhost:xxxxx redirects www.home.com on setting breakpoint, not hit method page(string id ) any clues on ? looks may have routing issues. routeconfig.cs file in app_start folder in mvc4 project. one other thing, if page action in different controller homecontroller, need code this: public actionresult index() { return redirecttoaction("othercontroller", "page", new { id = "home" }); } created basic mvc4 project redirection have , works me. user ends @ following url: [http://localhost:47272/home/page/home] here's homecontroller.cs public class homecontroller : controller { // // get: /home/ public actionresult index() { return redirecttoaction("page", new { id

windows 8 - Source code for WinRT UI controls publicly available? -

is source windows store (winrt) ui controls publicly available? extend of controls , not have start scratch, can sl , wpf. googling , looking through doesn't turn windows 8. thanks! so unlike wpf, [winrt-xaml] controls written in c++/cx. but, sounds not want source code as want derive existing controls , extend or override functionality. know can this, right? it's easy enough , sounds results asking in question. something this: public class monkeytextbox : textbox { public new string text { { return "always monkeys!"; } set { /* nothing */ } } } this custom textbox wherein have replaced base implementation of text own. granted, hope custom controls better. anyway, can every control, , can add own properties , events. make sense? reference: http://blog.jerrynixon.com/2013/01/walkthrough-custom-control-in-xaml-isnt.html but answer question : no, have not released source (yet). hopefu

java - JQuery Fetching the cell of the last row of a table and can we use autocomplete to hide some value in it -

my first query, code goes suppose table 5 rows , id = "mytable" , 3 cells in it $("#mytable tbody tr:last td").each(function(i, td){ alert("value "+ " "+i+" "+td); }); now alert results iterate 0 3 , td [object htmltablecellelement] now want value inside td tried td.html() jquery says td.html() not function my second query regarding autocomplete i have non primary key autocomplete , on basis of selection have fill in data. there way can hide primary key along autocomplete when user select autocomplete non primary key value, can primary key hidden field , fetch other data regarding value. code goes this i have tried code in i'm putting primary key inside square brackets [] splitting , on basis of primary key m filling data there way can hide primary key totally. mean on mouse hover user displayed part rather inside autocomplete list. e.g. abc [123] abc [345] here abc actual autocomplete values n wa

xcode - how can i use location which is found in another class? -

i taking user's location code: @implementation tabbar cllocationmanager *locationmanager; - (void)locationmanager:(cllocationmanager *)manager didupdatetolocation:(cllocation *)newlocation fromlocation:(cllocation *)oldlocation { // nslog(@"didupdatetolocation: %@", newlocation); cllocation *currentlocation = newlocation; if (currentlocation != nil) { userscurrentlongitude = [nsstring stringwithformat:@"%.8f", currentlocation.coordinate.longitude]; userscurrentlatitude = [nsstring stringwithformat:@"%.8f", currentlocation.coordinate.latitude]; nslog(@"latitude:%@,longitude:%@",userscurrentlatitude,userscurrentlongitude); } and in nslog screen showing location successfully. when want use locations in class imported location class (in case tabbar), location turns null. can solve issue? edited: after try 2 different method issue still getting null @ nslog: first method: at appdelegate.h:

java - Modify the POST header -

this question has answer here: sending http post request in java 8 answers the xml-rpc server trying communicate requires each request contains following in first line of http header: post /air http/1.1 however following code used, urlc = (httpurlconnection)url.openconnection(); urlc.setconnecttimeout(180000); urlc.addrequestproperty("user-agent", "avaya/3.1/1.0"); urlc.addrequestproperty("authorization","basic qxzhewe6qxzhewe="); urlc.addrequestproperty("content-type", "text/xml"); urlc.setdooutput(true); urlc.setrequestmethod("post"); which results in.... post http/1.1 user-agent: avaya/3.1/1.0 authorization: basic qxzhewe6qxzhewe= content-type: text/xml i.e. without "/air" bit. please in modifying post header make sure "/air" part included in url. it

Perl fails to open excel file when executing from Windows Task Scheduler -

this bizarre problem. have perl (version 5.12) script opens , modifies excel spreadsheet (version 2007 or later). below perl code open excel file: my $excel = win32::ole->getactiveobject('excel.application') || win32::ole->new('excel.application', 'quit'); $book = $excel->workbooks->open($excelpath) or die $!; the entire perl script added task scheduler in windows server 2008 r2 because called @ same time every day. when run script task scheduler, error occurs @ "open" statement above , aborts, $! blank. however, when run perl script manually command line, works fine including open-excel logic. can't figure out difference between command-line execution , scheduler execution, , why no error message available when open fails. please let me know if have clue issue. thanks. update : jason gray, i'm able see error message, complains excel file cannot accessed. doesn't make sense me because can guarantee file

javascript - Does a HTML form need an Action/Method in order to be submit? -

could submitted servlet without action or method? i.e.(could use jquery alone send this?, or other method?) <form id="form2"> <input type="text" value="12" name="id"/> <input type="text" value="namethatcomesfirst" name="firstname"/> <input type="text" value="namethatcomeslast" name="lastname"/> <input type=submit id="submit" value="submit"/> </form> no, doesn't need there, default submit loaded script, using get. if want submit ajax, can define when calling instead of through action/method attribute if want using the jquery form plugin . $('#form2').ajaxform( { url: 'comment.php', type: 'put', success: function() { alert('thanks comment!'); } }); // suggested way put action , method on form , `$.ajaxform` // find it. $('#form2&

JQGrid Datefmt not behaving as expected -

as part of colmodel in jqgrid, have following: {name:'reviseddate', width:220, editable: true, datefmt:'yyyy/mm/dd',edittype:'text',editrules:{date:true, required:true},search:true, stype:'text'} the datefmt , date:true seem working anticipated, except 1 special case. in edit box if user enters "2012/04/", jqgrid accepts valid date value, though missing day of month. other incorrect variations display error message in top of form, text: please enter valid date value - yyyy-mm-dd. i have tried changing colmodel use datefmt:'yyyy-mm-dd without success. is there i'm doing wrong? next step roll custom formatter, seems should unnecessary. version of jqgrid: 4.3.1 solution: ended testing regex against string in beforesubmit event, leaving editrules{date:true} in place. bulk of date validation done built in datefmt, below regex band-aid bug. more ideal solution date validation in same place, usage of form doesn't m

c++ - how to forward variable number of arguments to another function? -

this question has answer here: forward invocation of variadic function in c 10 answers in application have lot of logs. accumulate errors logs in 1 place called errorslogger . i've implemented way: static logger errorslogger; .... void logger::error(std::string format, ...) { va_list arglist; va_start(arglist, format); if (this != &errorslogger) { errorslogger.error(format, arglist); // how forward parameters? } vfprintf(logfile, , format.c_str(), arglist); fprintf(logfile, "\n"); fflush(logfile); va_end( arglist ); } however code doesn't work expected errorslogger contains little bit strange strings - seems variable arguments not passed. how fix code valid? the typical formulation of in c have 2 functions, 1 accepts ... , 1 accepts va_list (e.g., printf versus vprintf ). in c++

javascript - Can't access object method -

i've created quasi namespace/class called newscalendar. intent avoid polluting global namespace hide functions should private. when try call should public method "object not support property or method." function newscalendar() { var privatevar; //private vars this.onload = function () //public method { //do stuff }; function getweekstart(date) //private function { //do stuff } } the comments there indicate how i'm intending each item behave. i tried calling onload function this: newscalendar.onload(); but causes "object not support property or method" error. want able use newscalendar namespace , able call variables/methods attached object using newscalendar.propertyname or newscalendar.methodname(). try following setup: var newscalendar = (function () { var privatevar; var onloadhandler = function () { //do stuff }; function getweekstart(date) { //do stu

php - Partial replace on a modified preorder tree traversal from script -

Image
i have mptt (modified preorder tree traversal) this: (taken sitepoint ) my real tree has thousands of nodes , more complex structure, simplification shows problem. until moment, every time need change tree used shell script looks this: #!/bin/bash mysql -umyuser -pmypass database < tree.sql and executes ( tree.sql ): drop table if exists `tree`; create table `tree` ( `parent` varchar(32) default null, `title` varchar(32) collate utf8_unicode_ci not null, `lft` int(11) not null, `rgt` int(11) not null ) engine=innodb default charset=utf8 collate=utf8_unicode_ci; lock tables `tree` write; insert `tree` values (....),(....).... ( note : use shell script because there multiple instalations of same php application in multiple servers , easy/fast way update them, if required can move update php). but now, requirements state that: food/meat branch exist food/meat subtree must preserved because users can edit contents other parts of tree must updated (f

css - CSS3: Make next item indent more -

i'm wondering if there's way add margin-left each next item, such -item1 -item2 -item3 -and forth is possible css3? haven't seen 'every next item'. sure, can. it's freaky ... demo : http://jsbin.com/exuwej/1/edit css : ul { -moz-transform: rotate(-20deg); -ms-transform: rotate(-20deg); -o-transform: rotate(-20deg); -webkit-transform: rotate(-20deg); transform: rotate(-20deg); display: block; width: 500px; padding: 0; margin-left: 100px; margin-top: -50px; list-style: none; height: 400px; } ul li { -moz-transform: rotate(20deg); -ms-transform: rotate(20deg); -o-transform: rotate(20deg); -webkit-transform: rotate(20deg); transform: rotate(20deg); width: 60%; border: 1px solid blue; padding: 0; margin: 0; display: block; float: left; text-align: left; } html : <ul> <li>a</li> <li>b</li> &l

oracle11g - Force decimal value, even when 0 in oracle -

i have field stores version information such 1.1, 1.2 etc. however, store 4.0 4 , 5.0 5. is there way force show .0? i have tried number(5, 3) , decimal(5, 3) data types , neither work. version - oracle database 11g enterprise edition release 11.2.0.2.0 - 64bit production a number column never store decimal value if doesn't need to. you can, however, control how data displayed user when converted string using explicit to_char rather relying on implicit data type conversion. if use format mask 9.0 in to_char call, example, string generated have 1 decimal digit. sql> select to_char( 4, '9.0' ) 2 dual; to_c ---- 4.0 sql> ed wrote file afiedt.buf 1 select to_char( 4.1, '9.0' ) 2* dual sql> / to_c ---- 4.1 that being said, seems unlikely want store software version information in number column rather varchar2 . you, presumably, aren't doing mathematical operations on data of benefit of having number off tabl

ios - CALayer Troubles when loading an image from a UIImagePicker -

i have uiviewcontroller uiimageview (imageview), , i'm defining several layers nested in imageview follows in viewdidload: //container layer - top layer calayer *containerlayer = [calayer layer]; containerlayer.opacity = 0; containerlayer.bounds = [self.imageview.layer frame]; // holder layer calayer *holderlayer = [calayer layer]; holderlayer.opacity = 0; holderlayer.bounds = self.imageview.bounds; // hierarchy layers [containerlayer setvalue:holderlayer forkey:@"__holderlayer"]; [containerlayer addsublayer:holderlayer]; [self.imageview.layer addsublayer:containerlayer]; i have following code works when loading image uiimagepicker : uiimage *image = [info objectforkey:uiimagepickercontrolleroriginalimage]; uiimageview *newimgview = [[uiimageview alloc] initwithframe:self.imageview.frame]; cgrect frame = self.imageview.frame; newimgview.image = image; frame.origin = cgpointmake(0, 0); newimgview.layer.frame = frame; newimgview.la

time series - Using timestamp as mongodb _id? -

i want use mongodb store timeseries data, , think make things more sense keep 1 unique indexed field represent date-time. question is, can replace automatic _id creation own timestamp, , there drawbacks? can replace automatic _id creation own timestamp? yes, can. would there drawbacks? one have work it, whereas built in _id is, well, built in. 1 you're responsible making sure _id indeed unique. depending on data frequency , kind of timestamp use, may or may not simple. i'm not saying it's bad idea. advantages clear, but, yes, there drawbacks.