Posts

Showing posts from February, 2015

sql order by - Need a help for sort in mysql -

hi want sort table .the field contains numbers,alphabets , numbers alphabets ie, 1 2 1a 11a 6a b i want sort to, 1 1a 2 6a 11a b my code is, select * t order cast(st signed), st result is, b 1 1a 2 6a 11a i found code in url " http://www.mpopp.net/2006/06/sorting-of-numeric-values-mixed-with-alphanumeric-values/ " please me this required sort order, in presence of 0 in table; select * t order st regexp '^[[:alpha:]].*', st+0, st an sqlfiddle test with . as first sort criteria, sorts anything starts letter after doesn't. that's regexp does. as second sort criteria sorts numerical value string starts ( st+0 adds 0 numerical part string starts , returns int) as last resort, sorts string alphabetical ones in order.

iphone - Dismiss MBProgressHUD when delegate method fires -

first time working hud , i'm confused. i setup hud in viewdidload: [mbprogresshud showhudaddedto:self.view animated:yes]; dispatch_async(dispatch_get_global_queue( dispatch_queue_priority_low, 0), ^{ [[[wsxmppusermanager shared] xmppstreammanager] connect]; dispatch_async(dispatch_get_main_queue(), ^{ [mbprogresshud hidehudforview:self.view animated:yes]; }); }); the hud doesn't show. think reason follows. xmpp connect method fires off connection request xmpp server , it's done. there no activity wait is. however, connection isn't established until server responds , following delegate method fired: - (void)xmppstreamdidauthenticate:(xmppstream *)sender i want wait , dismiss hud, i'm @ loss how that. i'm missing simple. you need move code dispatch_async(dispatch_get_main_queue(), ^{ [mbprogresshud hidehudforview:self.view animated:yes]; }); after long running method has finished... is, if code indeed returnin

audiotoolbox - How to play raw pcm 16 bit data using audio toolbox in iphone -

i trying play raw pcm data in iphone using audio toolbox framework. have tried manage callback system final output not correct. so, looking sample or example play raw pcm 16 bit audio chunks. first decode audio chunks , raw 16 bit (short*) pcm data. greatful. thanks.

css - How to wrap the text in the DisplayFor in MVC view? -

Image
developing mvc app. have commenting feature in app. my problem is, when user posts comments without pressing enter key, comment comes out 1 single line , crosses screen , user has scroll horizontally see entire comment. i want wrap comment , show @ specific width. ex. admin 04 may 13 12:43 pm zxczxcasdasdzxczxcasdasdzxczxcasdasdzxczxcasdasdzxczxcasdasdzxczxcasdasdzxczxcasdasdzxczxca i use below code show comments in view <div class="commentp" style="width:550px;" > @html.displayfor(modelitem => item.commenttext, new {style = "width:550px;" }) </div> use <div style="word-wrap:break-word;"> or <div style="overflow:auto;">

mysql - SELECT * FROM table while condition=true? -

i want select table while 1 condition true, select * (select * from`table1` `t1` order t1.date) `t2` while t2.id!=5 when while condition comes false stop selecting next rows. please me, have search lot , many similars in stackoverflow can't it. please don't tell me where , want solution in sql not in php or other ok real problem here select *,(select sum(t2.amount) (select * transaction t1 order t1.date) `t2`) total_per_transition transaction here want calculate total balance on each transaction first find first date condition fails, id=5 : select date table1 id = 5 order date limit 1 then make above derived table (we call lim ) , join original table rows previous dates: t.date < lim.date select t.* table1 t join ( select date table1 id = 5 order date limit 1 ) lim on t.date < coalesce(lim.date, '9999-12-31') ; the coalesce() case when there no rows @ id=5 - , in case want rows table.

c# - json Array posting to mvc controller -

i want post json array mvc controller through ajax post as: $.ajax({ type: 'post', data: json.stringify(totaldata), traditional:true, url: '/builder/save', success: function () { alert("playlist saved successfully!!"); } }) and controller code have made array of 1 viewmodel & want update values as. [httppost] public actionresult save(ilist<itemeditviewmodel> data,long playlistid=0, string title="") { (int = 0; < data.count; i++) { var pc = db.playlistcontents.firstordefault(x => x.playlistcontentid == data[i].id); if (pc == null) { pc = new playlistcontent(); db.playlistcontents.add(pc); } pc.contentmetadataid = data[i].metaid; pc.playli

magento - mysql4-install-1.0.0.php file not working for Mageno 1.5 -

recently have created on custom magento extension , release found installtion file not install. the installation file not creating tables. i have following code in config.xml <?xml version="1.0" ?> <config> <modules> <tricore_contactus> <version>1.0.0</version> </tricore_contactus> </modules> . . . </config> i have created mysql4-install-1.0.0.php file in sql\contactus_setup folder inside extension below code. $installer = $this; $installer->startsetup(); $installer->run(" insert ".mage::getconfig()->gettableprefix()."core_email_template values (null, 'tricore contact us', 'name: {{var data.name}}\r\ne-mail: {{var data.email}}\r\ntelephone: {{var data.mobilenumber}}\r\n\r\ncomment: {{var data.message}}', null, 1, 'contact form', null, null, null, '2013-04-23 11:04:45', 'contacts_email_email_template',

generics - java passes toString() to a method -

i have following code public class mamman14 { public static void main(string[] args) { // todo code application logic here } public class sortedpair < e extends comparable < e >> { e max_element; e min_element; public sortedpair(e firstelement, e secondelemnt) throws illegalpair { int compare_result = firstelement.compareto(secondelemnt); if (compare_result == 0) { max_element = null; min_element = null; throw new illegalpair(firstelement.tostring(), secondelemnt.tostring()); } else if (compare_result > 0) { max_element = firstelement; min_element = secondelemnt; } else { max_element = secondelemnt; min_element = firstelement; } } public e getfirst() { return max_element; } public e getsecond() {

controls - Characteristic Equation of A Closed Loop System in Terms of PI Controller -

just wondering if guide me on how find characteristic equation of trasfer function g(s) (see below g(s)) in terms of coefficients in pi controller? g(s) = 45/(5s + 2) no sure here, i'm used multiplying error proportional gain - there's no error value provided. any advice appreciated. in advance ;) given: g(s) = 45/(5s + 2) (plant transfer function) c(s) = kp + ki/s (pi controller transfer function) and assuming system looks like: https://www.dropbox.com/s/wtt4tvujn6tpepv/block_diag.jpg the equation of closed loop transfer function is: gcl(s) = c(s)g(s)/(1+c(s)g(s)) = cg/(1+cg) in general, if had transfer function on feedback path, h(s), the closed loop transfer function becomes: cg / (1 + cgh) if plug in g(s) , c(s) shown above following closed loop transfer function after algebraic simplification: 45*[kp*s + ki] / [5*s*s + (2 + 45*kp)*s + 45*ki] and characteristic equation is 5*s*s + (2 + 45*kp)*s + 45*ki = 0 notice how integral term ad

c++ - How to extract __VA_ARGS__? -

i hava macro call static function each args. for example: #define foo(x) x::do(); #define foo_1(x,y) x::do(); y::do(); my question need use foo variable number of arguments, possible use __va_args__ ? like line below: #define foo(...) __va_args__::do() ? thanks macro expansion not work argument pack expansion variadic templates. have expand to: x,y::do(); and not to x::do(); y::do(); as hoped. in c++11 use variadic templates. instance, want way: #include <iostream> struct x { static void foo() { std::cout << "x::foo()" << std::endl; }; }; struct y { static void foo() { std::cout << "y::foo()" << std::endl; }; }; struct z { static void foo() { std::cout << "z::foo()" << std::endl; }; }; int main() { do_foo<x, y, z>(); } all need (relatively simple) machinery: namespace detail { template<typename... ts> struct do_foo; template<typename t, type

jquery - jsfiddle - Simple Ajax request -

i beginner jquery , trying call simple request. here's jsfiddle: http://jsfiddle.net/xvrnl/ i using code: html: <button>click me</button> and jquery: $("button").click(function() { $.ajax({ url: "http://jsfiddle.net/echo/html/", success: function(result) { alert("data: " + result); } }); }); but doesn't work. reading documentation doesn't me. can suggest solution? thank much ........ these reasons problem: you have refer jquery library reference jsfiddle you cant use absolute urls ajax requests. please refer following answer more information. $.ajax call working fine in ie8 , doesn't work in firefox , chrome browsers

java - Find character in a number which is in String format -

how can find string in number? a simple example follows private char check() { string sample ="1212kkk";//121hhh444 | 12-22 return 'k';//'h' | '-' } if other number want return value. how can first character ring? try this: string result = sample.replaceall("\\d" ,""); return result;

java - Updating JList when elements are added froma different Jpanel -

i have problem application use netbeans gui builder havea jlist contains elements added element jlist, program have 2 tabs, first tab contain jpanel contains jlist , second tab contain jpanel. want add element jlist second tab, add successful nut when swith first tab contains jlist elements added not therethe element jlist contains elements added begining. there no problems add method fine, question how update jlist when add elements anoother jpanel when adding elements, make sure added list model. call firecontentschanged().

Flattr buttons display an error using Tumblr theme code -

similar this question on my blog since few days ago flattr displaying error on buttons. wrong? has changed api? have not changed code when see blog or of posts there there big "error" displayed instead of flattr button. there way reason why there error? here can see code using generate flattr buttons. above in head can see javascript including. there error in code? because code worked time. i using en_us locale is not supported . don't know why worked before changing en_gb solved problem. voxpelli pull request fix , explanation.

Bloomberg weather data -

we have bloomberg (bbg) data license subscription , want include weather data our application. however, found out while have current weather data, no weather data history available. now, have hard time believing data provider big bbg offers no weather data history , assume standard support never understands problem, otherwise they'd work in development , not support. finally, sure not guy needing weather data history. for these reasons ask if (and how) weather history (or weather forecast history) can obtained using bbg data license? ps: not strictly dev topic assume people had type of problem (i.e., developers) know answer. management/support/whoever knows app "uses bbg data" not tickers, fields, ... the short answer yes, can historical temperature data bloomberg , there ticker each series year , weather station. i tried solve once. used terminal screen obtain graph of ytd daily temperature history (low,high,average) 10 calendar years zip code of int

arrays - something similar to sql left join in php -

i want sql left join functionality in php. $table1 = array( 0 => array("id" => "id1", "common_key" => 1), 1 => array("id" => "id2", "common_key" => 2), 2 => array("id" => "id3", "common_key" => 1) ); $table2 = array( 0 => array("name" => "name1", "common_key" => 1), 1 => array("name" => "name2", "common_key" => 2) ); $result = left_join($table1, $table2); $result should equal array below. array( 0 => array("id" => "id1", "common_key" => 1, "name" => "name1"), 1 => array("id" => "id2", "common_key" => 2, "name" => "name2"), 2 => array("id" => "id3", "common_key" => 1, "name" => &

javascript - Program works corectly two times after that it goes wrong -

after entering correct answer twice, subsequent try, if correct answer entered again, shows "try again" output. causing strange behavior? <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <script type="text/javascript"> var answer; var firstnum; var secondnum; var check = true; question(); function question() { firstnum = math.floor(math.random() * 101); secondnum = math.floor(math.random() * 101); answer = firstnum * secondnum; document.writeln("<h1>how " + firstnum +

Jquery Mobile Back Buttons -

i have application in programmatically add button page. means first page not have button on it. app has many ways of entering app, in other words can notification , in touching notification goes particular area in app. area not have backbutton go homepage, , if add 1 manually conflict programmed button. so looking way add button go homepage when page loaded first , other times when visit page button performs expected. i assume you're using data-add-back-btn=true dynamically add data-rel=back buttons pages. hence, possible first, checking if there no data-rel=back in active page and secondly, not home page. one more thing, need remove button once navigate away page in order not overlap 1 jqm generate. demo var backbtn = '<a href="#home" data-icon="arrow-l" data-iconpos="notext" class="backbtn"></a>'; $(document).on('pagebeforeshow', function () { var activepage = $.mobile.activepage;

Use C++-Iterators on Python-List with the Python/C API? -

is possible use tools needing iterators , function-pointer module <algorithm> on pyobjects ? the concrete problem want solve (it constructed learn it): i have huge list of ids stored in python-list now want perform std::binary_search on list, using module written in c++ one way access python-list c-array, constructing vector (which uses pointers/ not copy), doing binary_search , export array pyobject . would possible? well, binary search isn't complicated, why don't code 1 based on range of indices instead of iterators? believe list conforms sequence protocol of python, should pretty easy. if want use binary_search() algorithm learning experience, there possibility create stl-style iterators on top of python sequence. need pointer sequence , index create random-access iterator. if want to, can transparently convert python objects in list according id type (some integer type, guess). struct iterator { // typedefs required compliant

java - JSF 1.2: Navigation rules in a different config file -

i using jsf 1.2 application. trying create separate config file (named: navigation-config.xml ) navigation rules throughout application. below steps followed same: made entry in web.xml file , placed same directory faces-config.xml present: <context-param> <param-name>javax.faces.application.config_files</param-name> <param-value>/web-inf/faces-config.xml,/web-inf/navigation-config.xml</param-value> </context-param> below content of navigation-config.xml : <?xml version='1.0' encoding='utf-8'?> <!doctype faces-config public "-//sun microsystems, inc.//dtd javaserver faces config 1.1//en" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config> <navigation-rule> <description>welcome screen navigation</description> <from-view-id>/login.jspx</from-view-id> <navigation-case> <from-outcome>success&l

javascript - Determine which level i'm in the JSON tree -

i may have simple problem, can't figure out. if have multy denominational json array so: [ { "name":"one", "children": [ { "name":"two", "children": [ { "name":"two", "children": [] }, ... ] }, ... ] } ] i want determine level i'm at. if going loop true first entities printed bellow: one -| 2 -> view children once " view children " clicked: one -| 2 -| 3 -> view children || go back. and if " go back " clicked go to: one -| 2 -> view children so it's similar hierarchy. can't figure out how make button work. able figure out go forward using peace of code: level

c# - Index of an address in Associative Mapped Cache -

while calculating index of memory trace adddress in associative maping, using folllowing code: address trace address read memory trace file. block_shift=5 // fro 32bit block size cache_size=1024 associativity=4 // why m dividing index 2, 2^2=4 associativity long index = ((address >> block_shift) & (cache_size - 1)) / 2; int tag = address >> block_shift; // high order bits tag /* in line above want high bits (can include index bits) uniquely identify contents of cache-block */ if (tags[index] != tag) { // compare see if our data or other data mapped same location in cache misses++; tags[index] = tag; } references++; but code giving wrong number of misses, method of calculating index of associative mapped cache correct.

Yii Captcha don't refresh image on refresh button clicked -

i don't know why captcha image not refresh when click on refresh link. my code : <?php $this->widget('ccaptcha'); ?> <?php echo $form->textfield($model,'verifycode'); ?> i saw xhr response , empty , checked link of refresh link , thing tis : mydomain/captcha?refresh=1&_=1367673730496 and return image should return somthing {"hash1":311,"hash2":311,"url":"/mydomain/captcha?v=518509b295d06"} i saw above link in other application of mine works fine ccaptch. on page refresh , captcha image changes. the corrupted captcha sent 1 xhr , refresh 1 fine captcha should send 2 saw in other application,one refresh , other getting image. what should ? edit: i found fact : functional captcha works jquery.min corrupted 1 works jquery !! don't add header , added yii. second edition: i found 2 files handle captcha in yii framework , see when send request : mydonmain/contr

html5 input date empty on post php -

i'm using html5 input date type. after posting, see input empty, , other inputs (html4 types) ok. what reason? this form: <form action="/sgm/index.php?r=manager/addcoach_post" method="post"> <div class="registerfeildarea2"> <div class="registertxtp2">family name</div> <div class="registerfeild"> <input name="lname" type="text" value="" size="" class="registerfeildvalue" /> </div> </div> <div class="registerfeildarea"> <div class="registertxtp2">first name</div> <div class="registerfeild"> <input name="fname" type="text" value="" size="" class="registerfeildvalue" /> </div> </div>

c++ - Call function with all instances of a struct -

i want call function struct objects. i need function can loop through struct-objects a_1, a_2 calling struct struct_a. empty function 'reset_all_structs( ??? )' @ bottom of code. sample code: #include <iostream> struct struct_a { unsigned char number = 0; bool bool_1 = 0; bool bool_2 = 0; } a_1, a_2; // objects: maybe later a_3, ... , a_x void print_to_terminal(struct_a &struct_name); void set_bool_1(struct_a &struct_name); void set_bool_2(struct_a &struct_name); void reset_one_struct(struct_a &struct_name); void reset_all_structs(); int main() { set_bool_1(a_1); a_1.number = 111; set_bool_2(a_2); a_2.number = 222; std::cout << "a_1:\n"; print_to_terminal(a_1); std::cout << "\n"; std::cout << "a_2:\n"; print_to_terminal(a_2); std::cout << "\n"; reset_one_struct(a_1); // <-- reset 1 struct works, question ist how reset s

php - how do I read session content xml format with php5 -

i need read session content php. session created shopping cart script called easybasket , need extract data stored in session, can save mysql table. seems data stored in xml format. here content of session: array (size=3) 'username' => string 'test@gmail.com' (length=21) 'nombre' => string 'joe smith' (length=16) 'basket' => string '<basket version="1.0" timestamp="2013-05-04t12:58:37+00:00"> <items count="2" quantity="4" subtotal="1460" postage="0" total="1460" paypal="yes" google="no"> <item unit-price="380.00" quantity="2" subtotal="760" postage="0" total="760"> <title>dancer catamaran adults</title> <price>380.00</price> </item> <item unit-price="350.00" quantity="2" subtotal="700" postage="0&q

crash - display: -webkit-box; sometimes crashes my iPad -

do have ideas why websites keep crashing on single post template? powered wordpress. problem appears on ipad (i've tested 2 ipad 2's). http://luzlol.me how diagnose such things? thanks. update: figured out reason. display: -webkit-box; crashes ipad on single post template (like http://luzlol.me/bittorrent-sync/ one), don't know why. deativate w3tc , use dev tools console fix jquery errors. use firebug firefox, or use developer tools in chrome or safari or ie. use http://validator.w3.org/ check html , css.

algorithm - counter example of a stable matching -

i reading algorithm book , came across stable matching problem. , question came mind i'm curious about, book doesn't answer. question is: for matching, if not stable, pick blocking pair(w, m), , match them. , match previous partners. , repeat. correct algorithm reach stable matching? it seems answer no. can not think out counter example. there can help? i think have found answer. suppose have 3 women , 3 men. preference list of them are: w1: m3 > m2 > m1 w2: m2 > m3 > m1 w3: don't care m1: don't care m2: w1 > w2 > w3 m3: w2 > w1 > w3 the initial matching: (w1,m1) (w2,m2) (w3,m3) step 1: w1 , m2 match, (w1,m2) (w2,m1) (w3,m3) step 2: w1 , m3 match, (w1,m3) (w2,m1) (w3,m2) step 3: w2 , m3 match, (w2,m3) (w1,m1) (w3,m2) step 4: w2 , m2 match, (w1,m1) (w2,m2) (w3,m3) after 4 steps, matching goes initial state, leads infinite loop.

xpages - Is OneUI free to use in internal projects? -

have been looking couldn't find licensing information regarding ibm oneui. the 1 thing see header inside core.css file, says: "use, duplication or disclosure restricted gsa adp schedule contract ibm corp." is free use in internal company's projects? in freely available documentation guidelines says: "this code enables common , feel , common code base lotus® web applications. goal remove arbitrary differences between products thereby improving ease-of-use , making easier customize products when deployed in enterprise." and in legal notices says: "you may copy, modify , redistribute sample html contained in document in form without payment ibm, purposes of extending functionality and/or interfacing ibm lotus products." this suggests me entire purpose of oneui used applications built companies have licenses deploy notes applications , ibm encourages people so. more point, in document explicitly can't. so, while not cate

Difficulties with showing android calendar in different versions -

i trying open user's calendar. wrote following code: startmillis = calendar.getinstance().gettimeinmillis(); uri.builder builder = uri.parse("content://com.android.calendar").buildupon(); builder.appendpath("time"); contenturis.appendid(builder, startmillis); intent intent = new intent(intent.action_view).setdata(builder.build()); startactivity(intent); the problem works in version 4.0 not in 2.2, target version. what doing wrong? after trying different things, installed different calendar on avd , workes now.

java - JVM bytecode limitations on class-class interactions -

i looking through jvm bytecode instructions , surprised see interactions between classes (e.g. casting, new , etc.) rely upon constant pool lookups identity of other classes. am correct in inferring means 1 class cannot know existence of more 64k others, impossible refer them? if 1 did need refer many, ought 1 do--delegate work multiple classes each of have own <64k interactions? (the reason interests me have habit of writing code generators, producing thousands of distinct classes, , languages (e.g. scala) create classes prolifically. seems if true have careful: if have hundreds of methods in class each using hundreds of (distinct) classes, exceed constant pool space.) am correct in inferring means 1 class cannot know existence of more 64k others, impossible refer them? i think correct. , don't forget there constant pool entries other things; e.g. of classes method , fields names, , of literal strings. if 1 did need refer many, ought 1 do--delega

image processing - imageprocessing obtaining histogram from patches matlab -

i have image of size (h,w). histograms of each patch of size [n,n] image. these patches should have half overlap. fast way it? if use blockproc in matlab think won't able overlapping patches. you can use blockproc overlapping blocks. use 'bordersize' property.

javascript - Blank texture in webGL -

i have simple quad, , simple shader (see below). load image needed texture, process it, uniform place in shader program, , send it, way has been explained in "learning webgl" examples. tested , used webgl inspector see textures i've been using , problem quad whole black. in fragment shader, line: gl_fragcolor = texture2d( usampler, vuv); actually sets fragment color (0,0,0,1). it's "blank" texture, or all-black alpha equals 1 texture, not same image i'm trying attach. if encountered similar problem , knows how fix it, please tell me. it's done in chrome, --allow-file-access-from-files flag, html page, js/webgl code , image local, tested on server, no results. vertex: attribute vec3 avertexposition; attribute vec2 auv; uniform mat4 upmatrix; uniform mat4 umvmatrix; varying vec2 vuv; void main() { vuv = auv; gl_position = upmatrix * umvmatrix * vec4(avertexposition, 1.0); } fragment: uniform sampler2d usampler; varying vec2 vuv; void

web services - Design pattern for working with different versions of webservices? -

Image
i'm looking design pattern solve architectual issue i'm having. i use webservices kinda same not exactly. each new version of webservices there might few more methods available, part same. i want write abstractionlayer works regardless of version of webservices i'm communicating with. if i'm using method exists in newer versions of webservices sort of error, ok. can handle those. the reason want abstraction layer avoid tight coupling between application , version of webservices communicating with. what options when comes design patterns abstraction layer? see there 1 pattern called adapter, , 1 called bridge. of in situation? appreciated! edit - clarity here drawing. sometimes want application talk webservices version 1, , other times want use webservices version 2. depends on using client application. the client application shouldn't relly know or care version talking to. exception if uses method available in of versions need handle gracefully (t

html - Space on top of div for unknown reason -

i'm working on website , done. have 1 problem. table-cell on right side (chalkboard) has space on top of , cant figure out life of how rid of it. fine until put pictures left of it. to best of knowledge because in separate div's. can please help? thank you! the url thecheesepatch.com your .right-container set display table-cell , vertically aligning bottom. assign attribute .right-container , you're go: .right-container { vertical-align: top; }

javascript - Pines Notify closing notice and stacks -

i'm trying use jquery pines notify 1.2. 1) there close button in notice popup, can close notice it. or when timer reaches delay value closes automatically. possible close notice clicking on point in notice ? 2) tried , runned basic ones. tried demo page 's "examples of custom stacks" part. didn't work. example this: show_stack_topleft('notice'); function show_stack_topleft(type) { var opts = { title: "over here", text: "check me out. i'm in different stack.", addclass: "stack-topleft", stack: stack_topleft }; switch (type) { case 'error': opts.title = "oh no"; opts.text = "watch out water tower!"; opts.type = "error"; break; case 'info': opts.title = "breaking news"; opts.text = "have met ted?"; opts.type = "info"; bre

c++ - Do I need to use volatile keyword if I declare a variable between mutexes and return it? -

let's have following function. std::mutex mutex; int getnumber() { mutex.lock(); int size = somevector.size(); mutex.unlock(); return size; } is place use volatile keyword while declaring size? return value optimization or else break code if don't use volatile? size of somevector can changed of numerous threads program have , assumed 1 thread (other modifiers) calls getnumber() . you haven't mentioned type of mutex variable is, assuming std::mutex (or similar meant guarantee mutual exclusion), compiler prevented performing lot of optimizations. don't need worry return value optimization or other optimization allowing size() query being performed outside of mutex block. however, mutex lock released, waiting thread free access vector , possibly mutate it, changing size. now, number returned function outdated. mats petersson mentions in answer , if issue, mutex lock needs acquired caller of getnumber() , , held until caller done usi

tsql - Problems with update statement in c# -

im relatively new programming in c# , have come across problem during creating update statement, managed insert statement run there seems error confirmation of id, form looks database , displays information in datagridview, once record selected information displayed textboxes. private void btnsave_click(object sender, eventargs e) { dbcon.connectionstring = "provider=microsoft.ace.oledb.12.0; data source=elemental.accdb"; dbcon.open(); string sql = "update tblopencalls set [callid]= @callid, [staffid]= @staffid, [problemdesc] = @desc, [problemtype] = @problemtype, [department] = @department, [location] = @location, [urgency]= @urgency, [datecreated] = @created, [dateamend] = @amend, [allocatedto] = @allocate, [forename] = @forename, [surname] = @surname [callid]= $callid"; oledbcommand cmd = new oledbcommand(sql, dbcon); cmd.parameters.addwithvalue("@callid", txt_callid.text); cmd.parameters.addwithvalue("@staffid&

javascript - Using deeply nested object from JSON in AngularJS - strange behavior -

i'm trying understand how angularjs sees object nested json. here's example plunker . data comes service , assigned $scope.data . javascript code seems want me declare every level of object first before usage, referencing deep level within object view html works, , using deep level in function kinda works. it's rather inconsistent. i'm not sure if understanding of $scope lacking, or if has promise objects. advise please? html <body ng-controller="mainctrl"> referencing nested obj in view works: {{data.level1.level2}} <br> using nested obj within declared scope var doesn't work: {{nestedobj}} <br> using nested obj in function works throws typeerror: {{getlen()}} </body> javascript var app = angular.module('app', []); app.factory('jsonsvc', function ($http) { return {read: function(jsonurl, scope) { $http.get(jsonurl).success(function (data, status) { scope.data = d

php - How to return special value when objected is casted to an array? -

there magic method __tostring , triggered if object used in string context or casted such, e.g. <?php class foo { public function __tostring() { return 'bar'; } } echo (string) new foo(); // return 'bar'; is there similar function triggered when object castend (array) ? no, there arrayaccess interface, allows use class array. looping functionality la foreach need interface iteratoraggregate or iterator . former easier use if have internal array using because need override 1 method (which provides instance of arrayiterator ), latter allows more fine-grain control on iterating. example: class messages extends arrayaccess, iteratoraggregate { private $messages = array(); public function offsetexists($offset) { return array_key_exists($offset, $this->messages); } public function offsetget($offset) { return $this->messages[$offset]; } public function offsetset($offset, $value) {

JQuery UI dialog not passing form variables after preventdefault -

i believe i'm doing wrong here. have perl script says "if not submit button name submit/save, display html page. on submit, run subroutines pretty insert6/update data db. if ($cgi->param("group_submit") eq '') { &display_add_promo(); exit(0); } else { &group_product($group_id); $group_page = "./group?group_id=$group_id"; print $cgi->redirect($group_page); &close_and_exit; } exit(0); now using jquery check if "product new promotion code assigned contained within old promotion code assigned , if through alert. \$('#dialog').dialog({ height: 270, width: 500, autoopen: false, modal: true, buttons: { 'continue': function(event) { \$(event.target).css({opacity: 0.25}).unbind(); \$('#my_form').unbind('submit').submi

javascript - looping in a node.js callback function -

can run loop (while, for, dowhile etc) in callback function. here sample code : var execute = function (data,callback) { //do data callback(); } execute (data,function(error,returndataarray) { var boo = true; while(boo) { //do returndataarray if (returndataarray.length == 10) boo=false; } }); now, doubt is, main node.js thread wait until above while loop executed? your main thread blocked looping occuring inside callback function. that's because callback functions delayed until completion, , then, they're pushed javascript event loop , executed once thread free. in simpler word, in node (and javascript) happen in single thread (normal execution, callback, timeouts, etc). the way execute function thread javascript manually pushing thread. in browser that'll web worker, , on node cluster.

hilo - Implementing multi-tenancy in MultipleHiLoPerTableGenerator for Hibernate -

i'm trying create multi-tenant application shared schema.we have identified discriminator field filter out data base on customers. i'm facing problem in tablegenerator strategy generating primary keys of entities. as per logic have 2 columns seq_name , another(seq_count) tracking count. but since multitenant application need keep them separate each customer. multiple customers have seq_name & seq_count columns belong them respectively. i thinking might have write custom logic tablegenerator attribute discriminator column, before need advice other way this?

Extension method on Conversion in VB.NET -

as cannot write extension method objects in vb.net, can write method converting other type , use object? i assume you're trying around this issue . note not can't write extension methods object , can't use them on object variables or expressions because has cater late-bound calls. if knew object other type cast , use extension method (including method extending object , of course).

linux - How to find total size of all files under the ownership of a user? -

i'm trying find out total size of files owned given user. i've tried this: find $myfolder -user $myuser -type f -exec du -ch {} + but gives me error: missing argument exec and don't know how fix it. can can me this? you need terminate -exec. if want totals each directory possibly -type d required. find $myfolder -user $myuser -type d -exec du -ch {} \;

C++ What to learn next -

right i'm finished general things , not know else learn. am learing http://www.cplusplus.com/doc/tutorial/ am new in c++ maybe 2-3 month learn all. i have learned , tested following: basics of c++ structure of program variables. data types. constants operators basic input/output control structures functions (i) functions (ii) compound data types arrays character sequences pointers dynamic memory data structures other data types object oriented programming classes (i) classes (ii) friendship , inheritance polymorphism advanced concepts templates namespaces exceptions type casting preprocessor directives and confused bcs idk next learn. can me next start studying improve knowledge. interested networking. prev. expiriance 5-6 year in php. realy thanks. i recommend learning posix thread library . since interested in networking, if haven't done so, start looking @ code of open source network simulator to

objective c - Parse world weather online JSON with ObjectiveC for iOS 6 -

i need suggestion: i've json downloaded http://www.worldweatheronline.com/free-weather.aspx . i've issue parse json: { "data":{ "current_condition":[ { "cloudcover":"0", "humidity":"57", "observation_time":"07:23 pm", "precipmm":"0.0", "pressure":"1013", "temp_c":"23", "temp_f":"73", "visibility":"10", "weathercode":"113", "weatherdesc":[ { "value":"clear" } ], "weathericonurl":[ { "value":"http:\/\/www.worldweatheronline.com\/images\/wsymbols01_png_64\/wsymbol_0008_clear_sky_night.p

php - Image not cropped only for browsers? -

Image
i cropped image using php gd imagecopyresampled() function. used function in past, seems somehow, browsers firefox & chrome (latest versions of both) image not cropped, somehow transparent in part should removed. the osx finder , photoshop shows correct image sizes , no transparency... what wrong? this code jpg images... if(!($sourceimage = @imagecreatefromjpeg($source))) { $image = imagecreate($width, $height); $colorwhite = imagecolorallocate($image, 255, 255, 255); $colorblack = imagecolorallocate($image, 0, 0, 0); imagefill($image, 0, 0, $colorwhite); imagestring($image, 1, 1, 10, "immagine non disponibile", $colorblack); imagejpeg($image, $destination); return(false); } $destinationimage = imagecreatetruecolor($width, $height); imagecopyresampled($destinationimage, $sourceimage,0,0,$x,$y,$width,$height,$width,$height); i

Sinatra/Ruby new to programming - increasing an integer if a radio button is selected -

i new , trying pretty simple not sure begin. need increase "vote" count of newly posted link 0 10 if radio button selected. here complete code have far, appreciated: require 'sinatra' require 'data_mapper' require 'haml' require 'sinatra/reloader' set :bind, '0.0.0.0' datamapper::setup(:default,"sqlite3://#{dir.pwd}/example.db") class link include datamapper::resource property :id, serial property :title, string property :url, text property :bullet, boolean, :default => false property :score, integer property :points, integer, :default => 0 property :created_at, time attr_accessor :score def calculate_score time_elapsed = (time.now - self.created_at) / 3600 self.score = ((self.points-1) / (time_elapsed+2)**1.8).real end def self.all_sorted_desc self.all.each { |item| item.calculate_score }.sort { |a,b| a.score <=&

tags - ASP.NET how to modify control id 'ContentPlaceHolder1'? -

when create gridview in asp.net, set control id "factorytable", in browser html code, id turn "contentplaceholder1_factorytable" can delete "contentplaceholder1_" or modify other name? just add attribute clientidmode="static" to gridview markup. example: <asp:textbox id="txtecho2" runat="server" width="65%" clientidmode="static" /> example output: <input id="txtecho2" style="width: 65%" name="ctl00$masterpagebody$ctl00$txtecho2" /> see here different modes: http://weblogs.asp.net/asptest/archive/2009/01/06/asp-net-4-0-clientid-overview.aspx

c++ - Qt example: no mutex lock when reading, why? -

i looking @ this example, , raises queston me: when looking @ this file mutex being used when accessing global variable m_abort when being changed. when run method reads it, nothing mutex @ all. why? well, cannot see purpose of mutex @ all. both reading , writing m_abort can performed without mutex protection it's bool variable, , value changed atomically (at least on platforms). , if write not atomic , variable can have inconsistent value - can either false or true, , read true (since value written there true ).

PHP If statement always passing first statement -

i'm having problem if statement, sits inside of wordpress loop. first if statement — if ( $caption == "1") — seems work, second seems pass, when $image_title doesn't == strings. foreach ( $images $attachment_id => $attachment ) { // $alt = get_post_meta($attachment->id, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; $caption = $attachment->post_excerpt; $description = $attachment->post_content; $img_url = get_post_meta( $attachment->id, '_gallery_link_url', true ); //wp gallery custom links url field if ( $caption == "1") { echo '<div class="imagewrapb">'; if ($image_title == "branding" or "print" or "digital" or"packaging") { echo '<h3>'.$image_title.'</h3>'; ec

c++ - How could I use SplitEdge method in llvm -

i need insert basic block edge. tried use splitedge method in following link: http://llvm.org/docs/doxygen/html/basicblockutils_8cpp_source.html found answer here: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-july/033288.html but, don't want set in runonfunction,, how use without facing problem of pass not equal null thanks i think simplest way copy implementation of splitedge method own code , modify them work when pass null. in current implementation, means modify call own version of splitblock , , in version add return new before calls on p . however, if these sorts of operations on llvm ir, consider doing them within proper pass - make code play far more nicely existing passes.

java - Android App strange behaviour when comeing back from sleep -

since stuck on problem , don't know mistake need ask guys. when first launch app works fine, when press "back" button on phone main screen , start app again (which not real new startup because app goes sleep) has strange behaviour. i using opengles draw texture onto screen , when make touch texture changes. touch sets boolean true indicates draw other texture. somehow false when test value when got written true touch event. wondering because happens when pressed "back" button on phone. when returning main screen home button , moving app thing doesnt occur , works. first thought threads 2 different threads(activity rendering thread , surfaceview thread touch events) when synchronizing get/set methods still doesnt work. starting think touch thread thing still operating on old objects , changes values there while references in rendering thread newly instanciated boolean set touch rendering thread takes default value because got different objects somehow not

actionscript 3 - Using variable from another class as3 -

i separated 1 big file multiple file have cleaned , got problem now. i have main.as, character.as, camera.as. what i'm trying access variable class set later on class. ill show mean. from main.as im loading each class , add them child displayed on screen. public function buildgame() { var loadmap:sprite = new nf_mapbuilder(); var xchar:sprite = new nf_character(); var xcam:sprite = new nf_camera(); var usercontrol:nf_usercontrol = new nf_usercontrol(); addchild(loadmap); addchild(xchar); addchild(xcam); addchild(usercontrol); } everything show on screen needed. goes character.as: package as3 { import flash.display.sprite; import flash.events.event; public class nf_character extends sprite { public var character_pos:array = new array(); public var character_is_moving:boolean = false; public var character_x_dir:int = 0; public var character_y_dir:int = 0; public var chara