Posts

Showing posts from July, 2014

Using a boolean attribute as a conditional on an update action on a model in Rails 3 -

imagine have boolean , string attribute on model data this: model.locked => true model.status => "available" when update action invoked, want use boolean attribute control whether string attribute gets modified update, other attributes in update should saved regardless. so if model.locked => true and try model.status = "sold" then model.status => "available" currently have model this... before_update :dont_update_locked_item, :if => :item_locked? def item_locked? self.locked end def dont_update_locked_item #some rails magic goes here end how prevent single attribute being updated? i know answer going hurt, me out. it's late, i'm tired , i'm fresh out of talent. ;-) hope doesn't hurt :) class item < activerecord::base validate :cannot_update_if_locked, :on => :update def item_locked? self.locked end def cannot_update_if_locked errors.add(:item_id, "is lo...

Conventions for combining PHP with HTML -

i studying php book. author uses echo output html. @ first thought how supposed done, picked more "advanced" book. author of second book inserted php code between html rather echo whole thing. how done in large web development companies work on large projects? can use either, or 1 more accepted other? take code example: <?php //pagination if ($pages > 1) { //determine current page $current_page = ($start / $display) + 1; //print out previous page button if ($current_page != 1) { ?> <div class="pages"><strong><a href="view_users.php?s=<?php echo ($start - $display); ?>&amp;p=<?php echo $pages; ?>">&nbsp;&lt;&nbsp;</a></strong></div> <?php } //print page numbers ($i = 1; $i <= $pages; $i++) { if ($i == $current_page) { ?> <div class="pages active"><span>&nbsp;<?php echo $i; ?>&nb...

regex - Extract various characters from string (Alternate method) -

ok, have garbled text strings , want extract lower-case characters, upper-case characters , numerical values string 3 sub-strings , later use them purpose. have code this: sinput = "awsedrgy vgiycfry2345ewscfvg gyifvygxscyui^rsfv gyd&k^dfyuodvl234sdv8p7ogyhs" local slower, supper, snumbers = "", "", "" sinput:gsub("%l", function(s) slower=slower..s end) sinput:gsub("%u", function(s) supper=supper..s end) sinput:gsub("%d", function(s) snumbers=snumbers..tostring(s) end) print( slower, supper, snumbers ) and working fine. not sure on using these 3 separate extractions 30,000 lines of such garbled text. there more efficient way? or way best possible solution? try using complement classes : sinput = "awsedrgy vgiycfry2345ewscfvg gyifvygxscyui^rsfv gyd&k^dfyuodvl234sdv8p7ogyhs" local slower = sinput:gsub("%l","") local supper = sinput:gsub("%u","...

neo4j - Using relationship index on gremlin is relatively slow -

in neo4j, have relationship index 'index_e_assoc_smethdgexp' containing 180000 edges, attribute 'property'. want simple query lists 200 edges index, @ point regardless of property value (later query fetch same attribute values 200 first edge out vertices edge property <= 0.01), , fetch few attribute values out node: time = system.currenttimemillis(); t = new table(); g.idx('index_e_assoc_smethdgexp')[[property: neo4jtokens.query_header + "*"]][0..200].outv().id.as('nodeid').back(1).alias.as("alias").back(1).chr.as('chr').table(t,["nodeid","alias","chr"]).iterate(); system.currenttimemillis() - time =713ms getting 200 first edges index takes 262ms : time = system.currenttimemillis(); g.idx('index_e_assoc_smethdgexp')[[property: neo4jtokens.query_header + "*"]][0..200]; system.currenttimemillis() - time why first query completed slowly? shouldn't take long 200 ...

php - Dealing with an array of input text dynamically generated in JavaScript -

i want phone numbers of customer in form generates input text dynamically. have made this <html> <head> <title> telephones </title> <script language="javascript"> function add(type) { //create input text dynamically. if(typeof add.counter=='undefined') { add.counter=0; } add.counter++; var element = document.createelement("input"); //assign different attributes element. element.setattribute("type", type); element.setattribute("value", ""); element.setattribute("name", type.concat(add.counter)); var foo = document.getelementbyid("foobar"); //append element in page (in span). foo.appendchild(element); return add.counter; } </script> </head> <body> <form action="test1.php" method="post"> //here think there problem <input type="button" value="add...

Showing 500 (Internal Server Error) using backbone.js with slim.php when only adding new model -

i got code https://github.com/ccoenraets/backbone-cellar trying learn backbone.js. when trying add new model database using slim.php, showing 500 (internal server error). when trying fetch, update, delete working good. why showing error on adding ? plz me, thanks. window.wineview = backbone.view.extend({ initialize: function () { this.render(); }, render: function () { $(this.el).html(this.template(this.model.tojson())); return this; }, events: { "click .save" : "beforesave", "click .delete" : "deletewine" }, beforesave: function () { var self = this; var check = this.model.validateall(); if (check.isvalid === false) { utils.displayvalidationerrors(check.messages); return false; } // upload picture file if new file droppe...

symbol - How to return the real/imaginary part of a symbolic polynomial in MATLAB? -

given polynomial such (a+b*i)*c+i , a , b , c defined symbolic elements represent 3 real values , i imaginary unit, how return real part , imaginary part of polynomial? a = sym('a','real'); b = sym('b','real'); c = sym('c','real'); expand(real((a+b*1i)*c+1i))

asp.net - How to update a session variable after request is processed -

i have object need store in session. at beginning of each request, copy object httpcontext.current.items collection can reused during request. during request, state of object can modified, need write out session can used next request. i tried updating via httpapplication.endrequest event handler, discovered httpcontext.current.session null point. is there event handler in httpapplication occurs after request has been processed, within can still access httpcontext.current.session? the session available httpapplication.postrequesthandlerexecute event, according documentation: "occurs when asp.net event handler (for example, page or xml web service) finishes execution." this page helpful in understanding sequence of httpapplication events: http://blog.dotnetclr.com/archive/2007/03/14/httpapplication-pipeline-demystified.aspx

android - AR Mobile Games using live camera -

i wanna start working on developing games : mosquito ar games : http://www.makayama.com/mosquitoes.html driodshooting : http://www.youtube.com/watch?v=ku9qsujwzgi the app use camera , radar spotting object , hit using touch best sdk or platform or programming model execute similar game targeting android , ios your , advice highly appreciated thanks in advance i agree ivan question broad handled here. anyway, here few things consider android platform: if want make use of 3d graphics (opengl) might run bottleneck, because time being cannot have live camera preview , opengl surface view simultaneously on same screen. problem called surfaceview (which used opengl rendering , camera live preview) not designed layered on top of each other. can unexpected results when comes display order (3d graphics rendered behind video preview). there 2 solutions problem though: you don't use 3d graphics , resort rendering 2d objects on top of camera preview you use 3d ...

sms - Insert predefined message into existing conversation (Android) -

is there way can insert predefined message existing conversation in inbox app built on android platform? with code able retrieve last sent , received messages. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); textview tv = new textview(this); uri urisms = uri.parse("content://sms/"); cursor cur = getcontentresolver().query(urisms, null, null, null, null); cur.movetonext(); string body = cur.getstring(cur.getcolumnindex("body")); string add = cur.getstring(cur.getcolumnindex("address")); string time = cur.getstring(cur.getcolumnindex("date")); string protocol = cur.getstring(cur.getcolumnindex("protocol")); string contactname = ""; uri personuri = uri.withappendedpath( contactscontract.phonelookup.content_filter_uri, uri.encode(add)); cursor c = getcontentresolver().query(personuri, new string[] { phonelookup.display_name }, null, null, null ); if( c.movetofirst() ) ...

JavaScript function arguments for filter function -

numbers = [1,2,3,4,5,4,3,2,1]; var filterresult = numbers.filter(function(i){ return (i > 2); }); i don't understand how works. if omit function argument breaks function isn't tied why need there? .filter ( array.prototype.filter ) calls supplied function 3 arguments: function(element, index, array) { ... element particular array element call. index current index of element array array being filtered. you can use or of arguments. in case, i refers element , used in body of function: function(i){ return (i > 2); } in other words, "filter elements element greater 2" .

java - garbage collector doubts -

i have question on here regarding java garbage collector. first let me clear have understood regarding java gc. gc background thread run in background when jvm starts. each object having 1 finalize() method. method used release system resources before object destroyed. according java experts, should not put resources under finalize() method releasing system resources. becuase cannot make sure when gc run. can request gc run calling system.gc() . so question is, gc background thread run in background. how can dont know when gc run? statement "we dont know when gc call finalize() method " meaning of that? if meant, job of gc ? gc 's responsibility find out un used variable , remove memory. in case,why gc cannot call finalize() method also? now how can dont know when gc run?. functioning of gc dealt complex algos, dependent on underlying os , hardware. can't because if 1 tell particular jvm version not valid other jvms. better can't rel...

Bind data with list,string fields to the grid view in winforms c# through interface -

Image
i want bind data grid. class follows. public class dependency { public string issueid { get; set; } public string jirastatus { get; set; } public int dependencyfound { get; set; } public list<string> depends { get; set; } public list<string> linked_issues { get; set; } } i trying bind data through wizard or ui. here list type fields not appearing. through ui not possible? dont have idea how bind through code. can once give me link or solution this. thanks for parent-child relation (collection associations) populate 1 gridview parent level data. when user clicks on 1 of record fetch , show corresponding child data in separate grid(s), when list type. otherwise may need consider using thir-party grid controls support nested grid display.

svn - Subversion 405 Method Not Allowed -

i'm trying check out subversion repository. other 2 subversion clients don't have issues trying check out. in network setup. i'm using tortoisesvn 1.7.5 64 bit (also tried newest 1.7.7 64 bit). when following error: server sent unexpected return value (405 method not allowed) in response report request '/svn/cosara2/!svn/vcc/default' in other posts found there problem existing folder. i've made sure there no such folder. the subversion server set use webdav svn url http://some/url/to/svn/repo/branch could issue http proxy webserver? other thoughts? i've solved issue setting https svn repository. dav not allowed proxy server since proxy server cannot interpret https can not block dav.

I can't access my Apache server from my Android device -

it second time asking question on stackoverflow. i'm trying access local apache server i've set on desktop computer (ip starts ie. 192.168.1* . **)on android phone. somehow not allow me access server @ all! :( strangely, allow me access server lol! it's 1 out of 20 each attempts. also, doesn't allow me access server on laptop either.. need guys.. working fine when working locally within desktop pc using emulator. i've done quite lot of research wasn't able find solutions. thank guys ===================================== arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); httpclient client = new defaulthttpclient(sethttpparams()); httppost request = new httppost(path + filename); if (json != null) { request.setentity(new bytearrayentity(json.tostring().getbytes("utf8"))); request.setheader("json", json.tostring()); } else { request.setentity(new urlencodedformentity(name...

model view controller - Magento Adminhtml: Where do forms come from? -

my question comes seeing question , not being able find correct answer. when adding new product, actual code come input fields? in aforementioned question, desire add maxlength attribute input box. dug around on hour , did find plenty of form helpers not 1 exact case. how find true origin of (or any) form in magento? if i'm understanding question correctly, majority of magento's form fields come varian_data_form can specify maxlength property via higher call, in: $fieldset->addfield('title', 'text', array( 'label' => mage::helper('form')->__('title3'), 'maxlength' => '30', // <-- change here 'class' => 'required-entry', 'required' => true, 'name' => 'title', 'onclick' => "alert('on click');", 'onchange' => "alert...

clojure - Returning a value from a loop -

i'm new clojure , hoping me out here: ;; loop collect data (defn read-multiple [] (def inputs (list)) (loop [ins inputs] (def input (read-val ">")) (if (not= input "0") (recur (conj ins input))) (i-would-like-to-return-something-when-the-loop-terminates))) how i, after collecting input, list of input collected far? the return value of loop retrun value of if statement (loop [ins inputs] (def input (read-val ">")) (if (not= input "0") (recur (conj ins input)) return-value-goes-here)) and replace def let binding locals (loop [ins inputs] (let [input (read-val ">")] (if (not= input "0") (recur (conj ins input)) return-value-goes-here)))

java - How to get Latitude and Longitude in android? -

how current latitude , longitude in android2.3.3? i try follow this can't run programs. my code latview = (textview)findviewbyid(r.id.lattext); lngview = (textview)findviewbyid(r.id.lngtext); locationmanager lm = (locationmanager)getsystemservice(context.location_service); location location = lm.getlastknownlocation(locationmanager.gps_provider); double longitude = location.getlongitude(); double latitude = location.getlatitude(); in android manifest put this. <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> please help. thanks. this have in application find device current location, works fine: public class mylocationactivity extends activity implements locationlistener { private locationmanager mgr; private st...

c++ - Should static_assert be triggered with a typedef? -

i noticed static assertions in class templates not triggered when instantiations typedef 'ed. #include <type_traits> template <typename t> struct test_assert { static_assert( std::is_same< t, int >::value, "should fail" ); }; typedef test_assert< float > t; this code compiles without error. if try create instance, assertion fails: t obj; // error: static assertion failed: "should fail" finally, if replace condition false , assertion fails if don't instantiate class template: template <typename t> struct test_assert { static_assert( false, "always fails" ); }; i tried code on gcc-4.5.1 , gcc-4.7.0. behavior normal? @ time compiler supposed verify static assertions? guess two-phase lookup involved, shouldn't typedef trigger second phase? i tried code on gcc-4.5.1 , gcc-4.7.0. behavior normal? yes at time compiler supposed verify static assertions? this interesting ques...

c# - Entity framework remove object from context, but not from database -

i working on batch process dumps ~800,000 records slow legacy database (1.4-2ms per record fetch time...it adds up) mysql can perform little faster. optimize this, have been loading of mysql records memory puts usage 200mb. then, start dumping legacy database , updating records. originally, when complete updating records call savecontext make memory jump ~500mb-800mb 1.5gb. soon, out of memory exceptions (the virtual machine running on has 2gb of ram) , if give more ram, 1.5-2gb still little excessive , putting band-aid on problem. remedy this, started calling savecontext every 10,000 records helped things along bit , since using delegates fetch data legacy database , update in mysql didn't receive horrible hit in performance since after 5 second or wait while saving run through update in memory 3000 or records had backed up. however, memory usage still keeps going up. here potential issues: the data comes out of legacy database in order, can't chunk updates , perio...

php - Converting nested JSON array -

i have php function builds json array via $jsonarray= array(); ($i=0; $i<$dircount; $i++){ $query = sprintf("select * tour filename= '../%s/%s'", $imagedirectory, $dirarrays[$i]); $result = mysqli_query($link, $query); if (mysqli_num_rows($result) == 1){ $row = mysqli_fetch_row($result); $jsonarray[]= array('filename'=>$dirarrays[$i], 'location'=>$row[4], 'latitude'=>$row[2], 'longitude'=>$row[3], 'heading'=> $row[5]); } } and returns upon execution via ajax query. however, shown in firebug [ 0 : object{ 'filename' : , 'location': , 'latitude': , 'longitude: }, 1 : object{ 'filename' : , 'location': , 'latitude': , 'longitude: }, ] and on how can convert index locations location value instead? have in mind is 'start' : object{ 'filename' : , 'location': , 'latitude': , 'longitu...

jpa - Alternative namedquery for nativequery -

i need change query native-query ( named-query or create-query ) in jpa. em = getentitymanager(); string query = "select kcu.table_name information_schema.key_column_usage kcu,information_schema.tables kt " + "where kcu.referenced_table_name = 'sampletable1' " + "and kcu.table_schema='sampledatabase' " + "and kcu.referenced_column_name = 'samplerollnoid' " + "and kt.table_name = kcu.table_name " + "and kt.table_rows > 0 " + "and kt.table_schema = kcu.table_schema"; list tablenamelist = (list) em.createnativequery(query).getresultlist(); this query returns tablenames (the tables names foreign key refer table (sampletable1)). i got error when change createquery or namedquery. like list tablenamelist = (list) em.createquery(query).getresultlist(); or list tablenamelist = (list) em.createnamedquer...

java - project stopped unexpectedly -

i trying write code getting cords on mobile. i tried debug code , guess error in locationlistener ll=new mylocationlistener(); trackmobileclass package prakash.work.trackmobile; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle; import android.app.activity; import android.content.context; import android.widget.textview; public class getcords extends activity { textview longi; textview lat; textview tv=(textview) findviewbyid(r.id.tv); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.get_cords); longi=(textview) findviewbyid(r.id.longi); lat=(textview) findviewbyid(r.id.lat); locationmanager lm=(locationmanager) getsystemservice(context.location_service); locationlistener ll=new mylocationlistener(); lm.requestlocationupdates(locationmanager.gps_provider, 0, 0, ll); } class myl...

ios - Security considerations: can you intercept UIWebView / UIWebViewDelegate -

from user perspective can security risk let app not leave application. letting app handle login view in uiwebview within app itself. should not use custom url scheme in .plist? thanks it depends on want do. more keep user in app, longer he'll stay , use it. it's bid idea use uiwebview , user experience not same compared native interface. concerning oauth, dialog asking user credentials and/or approval may coded, need post data @ right url when user submit. if want use web view, yes it's better include in app, overall authentication.

sorting - How does the sort() work in javascript? -

var numarray = [4,2,5,3]; numarray.sort(function(a,b){ console.log("a:" + + ", b:" + b); return a-b; }); the 3 possible return numbers are: <0 (less 0), 0, or >0 (greater 0): less 0: sort "a" lower index "b" zero: "a" , "b" should considered equal, , no sorting performed. greater 0: sort "b" lower index "a". i getting on console a:4, b:2 a:4, b:5 a:5, b:3 a:2, b:3 a:4, b:3 [2, 3, 4, 5] may know how values of , b getting changed seen above? in first step a=4 , b=2. in case swap. array becomes [2,4,5,3]; in second step a=4 , b=5. in case items remains same. array becomes [2,4,5,3]; in third step a=5 , b=3. in case swap. array becomes [2,4,3,5]; until step okay. after how value of , b becomes 2 , 3 > respectively instead of 2 , 4. anyone can me? thanks in advance there no guarantee so...

javascript - MVC FileUpload file size client side validation -

how can validate file size client side. can controlled via controller like, if (file.contentlength > 1048600) { } on client side can control name , extension of file. how control size? <input type="file" name="file" id="file" /> thanks i dont think there cross browser way want, check question this can work in webkit based browsers example var size = document.getelementbyid('file').files[0].size;

Magento catalog price rule condition 'contains' not working -

i using magento , trying create promotion using catalog price rules. want use sku condition. if following: sku equals n12380_black it works fine. however if do: sku contains n12380 it doesn't work @ all. need work can apply rule multiple items in 1 go. magento version 1.5.0.1 is there bug in version causing problem? if know fix it? cannot see i've done wrong - i've checked sku details, nothing seems work. it appears though rule script in app/code/core/mage/rule/model/condition/abstract.php if helps anyone. any appreciated! i got working using conditional 'is 1 of' , listing sku's - using contains isn't way trying.

delphi - Disable/de-activate a custom component with published property -

i working on custom component in delphi -7 have published properties private { private declarations } ffolderzip ,fimagezip,ftextzip,factivatezipcomp : boolean; fmessagebo : string; published { published declarations } {component properties} {#1.folder zip} property zipfolder : boolean read ffolderzip write ffolderzip default false; {#2.send imagezip ?} property zipimage : boolean read fimagezip write fimagezip default false; {#3.text files} property ziptext : boolean read ftextzip write ftextzip default false; {#4.message} property zipmessage: string read fmessagebo write fmessagebo ; {#5.activate } property activatezipper: boolean read factivatezipcomp write factivatezipcomp default false; end; when user drops component on application, activatezipper properties give use option activate/enable or deactivate/disable component executing. component creates file in constructor have this, crea...

asp.net - Kind of #if (Debug Symbol) but for web.config file -

i use different section debug , release configuration. tried use "web.config transform" functionality works great deploying. , not when want build , execute application locally. can add condition web.config choosing right ? thanks. if using visual studio 2010 can have them on different config files. check http://msdn.microsoft.com/en-us/library/wx0123s5.aspx

html - php: dynamic link appends content to existing page rather than opening new one -

i have dynamic link fetches invoice detail based on invoice id. <a href='<?php echo $_server['php_self']; ?>/retrieve?class=invoicelineitems&amp;id=<?php echo $invoice['invoice_id']; ?>'><?php echo $invoice['invoice_number']; ?></a>&nbsp;<?php echo $invoice['customer_name'] ?>&nbsp;<?php echo $invoice['invoice_date'] ?> it calls function public function retrieve($class, $id = null) { switch ($class) { case 'invoice': $invoices = $this->invoice->getinvoices(); include 'view/invoicelist.php'; break; case 'invoicelineitems': $partnerinfo = $this->partnerinfo->getpartnerinfo($id); $invoicelineitems = $this->invoicelineitems->getinvoicelineitems($id); include 'view/invoice.php'; break; } } however, include statement...

node.js - How to select value from MongoJS query output -

i have mongojs query call: db.users.find({username:"eleeist"},function(err, docs) { console.log(docs); }); the docs variable looks in console output: [ { _id: 4fee05662b17f88abbeb60b6, username: 'eleeist', password: 'test' } ] i display password of user eleeist . i tried docs.password awful errors. so how select values returned query result? docs array of documents, password of first 1 you'd use docs[0].password .

How to prevent browser from executing PHP code that i have added as sample/example on my page -

i want paste php code samples on web page browser treat normal php code , execute rather treating text. how can achieved... hope answer simple has alluded me. spent 2 hours on this. rather using <?php ... ?> use &lt;?php ... ?&gt;

compact framework - Drawing control with transparent background -

Image
i've been trying display image has transparent border background control. unfortunately, transparent area creates hole in parent form follows: in above image, form has red background i'd hoped see behind control in transparent areas. the code used follows: protected override void onpaint(system.windows.forms.painteventargs e) { if (this.image != null) { graphics g = graphics.fromimage(this.image); imageattributes attr = new imageattributes(); //set transparency based on top left pixel attr.setcolorkey((this.image bitmap).getpixel(0, 0), (this.image bitmap).getpixel(0, 0)); //draw image using image attributes. rectangle dstrect = new rectangle(0, 0, this.image.width, this.image.height); e.graphics.drawimage(this.image, dstrect, 0, 0, this.image.width, this.image.height, graphicsunit.pixel, attr); } else { ...

oop - Error using javascript getters & setters in IE -

i reading john resig's article javascript getters , setters when found code: function field(val){ this._value = val; } field.prototype = { value(){ return this._value; }, set value(val){ this._value = val; } }; i've tested , works major browsers, except damn ie, gives me script1003: ':' expected error. after wondering while, realized error happens because ie doesn't recognize javascript getters , setters, thinks get value , set value syntax error. is there way make code cross-browser? thanks in advance edit : i tried check if browser supports getters&setters: if(window.__lookupsetter){ field.prototype = { value(){ return this._value; }, set value(val){ this._value = val; } }; }else{ field.prototype = { value: function(val){ if(val) return this._value = val; return this._value; } ...

New entity ID in domain event -

i'm building application domain model using cqrs , domain events concepts (but no event sourcing, plain old sql). there no problem events of somethingchanged kind. got stuck in implementing somethingcreated events. when create entity mapped table identity primary key don't know id until entity persisted. entity persistence ignorant when publishing event inside entity, id not known - it's magically set after calling context.savechanges() only. how/where/when can put id in event data? i thinking of: including reference entity in event. work inside domain not necesarily in distributed environment multiple autonomous system communicating events/messages. overriding savechanges() somehow update events enqueued publishing. events meant immutable, seems dirty. getting rid of identity fields , using guids generated in entity constructor. might easiest hit performance , make other things harder, debugging or querying ( where id = 'b85e62c3-dc56-40c0-852a-49f759ac68f...

javascript - SlickGrid Unselect Row CheckBox Event -

i new jquery, , need use grid in project. chose slickgrid (quite slick indeed). need disable buttons when rows deselected. i using following callback: grid.onselectedrowschanged.subscribe(function(){}); the problem callback executed on selection - not when rows deselected. grid.onselectedrowschanged.subscribe(function(){ var selectedrows = grid.getselectedrows(); if (selectedrows.length === 0) { // (when rows deselected) // logic goes here... } }); if want execute logic on row deselect suggest storing selectedrows in global variable updated on selectedrowschanged event. in onselectedrowschanged compare global selectedrows variable , grid.getselectedrows() lenghts see if changes have occured. var lastselectedrows = []; grid.onselectedrowschanged.subscribe(function(){ var selectedrows = grid.getselectedrows(); if (selectedrows.length < lastselectedrows.length ) { // proceed in finding actual row comparing ...

Virtual memory size and allocation -

on 32-bit x86 systems, total virtual address space has theoretical maximum of 4 gb. default, windows allocates half address space (the lower half of 4-gb virtual address space, x00000000 through x7fffffff) processes unique private storage , uses other half (the upper half, addresses x80000000 through xffffffff) own protected operating system memory utilization. 64-bit windows provides larger address space processes: 7152 gb on ia-64 systems , 8192 gb on x64 systems. i have several questions above quote : why low address space allocated processes? "...uses other half (the upper half, addresses x80000000 through xffffffff) own protected operating system memory utilization." - why operating system doesn`t use physical addresses system address space,but uses virtual addresses? why on x64 system 8192gb used process , system?in oppose 32bit os not space of addresses used? thank you

c# - UI Initialization Slow in Silverlight -

i have large silverlight application divided "tabs", each of them divided further subtabs. xap file don't take long download, , first screen login. after logging in, however, app's rootvisual set "mainpage", contains main tabs. since each of these contains subtabs, , each subtab contains graphical user controls, every ui component of app loaded when main page loads. thus, login "freezes" 30 seconds while main page loads usercontrols app. best way split entire app's ui isn't loaded @ initialization? thinking not call each controls initializecomponent() until it's parent tab clicked on? or not loading main tab's "subtabs" until clicked on? surely there must better way split up. when use tabcontrol silverlight takes care of these things. doesn't render control until tabitem selected. make sure haven't written anycode inside constructor of control. codes should go on loaded event of cotrol whether usercont...

pointers - Valgrind error: Invalid read of size 1 -

i cant find error in code, im looking @ hours... valgrind says: ==23114== invalid read of size 1 ==23114== invalid write of size 1 i tried debugging printfs, , think error in function. void rdm_hide(char *name, byte* img, byte* bits, int msg, int n, int size) { file *fp; int r;/ byte* used; int = 0, j = 0; int p; fp = fopen(name, "wb"); used = malloc(sizeof(byte) * msg); for(i = 0; < msg; i++) used[i] = -1; while(i < 3) { if(img[j] == '\n') i++; j++; } for(i = 0; < msg; i++) { r = genrand_int32(); p = r % n; if(!search(p, used, msg)) { used[i] = (byte)p; if(bits[i] == (byte)0) img[j + p] = img[j + p] & (~1); else if(bits[i] == (byte)1) img[j + p] = img[j + p] | 1; } else --; } for(i = 0; < size; i++) fput...

z3c.form reference widget - able to re-order and pick both AT and Dexterity content in Plone -

is there reference widget plone 4.1+ able pick , reorder both archetypes , dexterity content. namely widget used define dropdown menu order , items folder (pick , reoder items inside folder) here code: https://github.com/miohtama/webcouturier.dropdownmenu/blob/master/src/webcouturier/dropdownmenu/menusettings.py

android - How to convert a pdf to an image? -

using pdfbox displays error: import java.awt import javax` based on following code: imagetype = bufferedimage.type_int_argb; //need specifies java.awt string[] formats = imageio.getreaderformatnames(); //need specifies javax finally found solution. can't use awt android, so, go pdf viewver lib on http://sourceforge.net/projects/andpdf/files/ find out apk , source pdf image. here myclass convert pdf image: package com.print; import java.io.bytearrayoutputstream; import java.io.file; import java.io.fileoutputstream; import java.io.ioexception; import java.io.randomaccessfile; import java.nio.channels.filechannel; import net.sf.andpdf.nio.bytebuffer; import net.sf.andpdf.refs.hardreference; import android.app.activity; import android.app.progressdialog; import android.content.context; import android.graphics.bitmap; import android.graphics.rectf; import android.os.bundle; import android.os.environment; import android.os.handler; import android.util.log; impo...

php - Http post over a captcha protected jsp page using curl -

hello im trying make http post on jsp page using curl. it's not working. php code i'm trying. <?php if(isset($_post['submit'])){ $captcha = $_post['answer']; $ch = curl_init(); curl_setopt($ch, curlopt_url,"http://example.com/post_comments.jsp"); curl_setopt($ch, curlopt_referer, 'http://www.example.com'); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, "post_id=123&body=blabla&title=blabla&name=blablabla8&captcha=$captcha"); curl_setopt($ch, curlopt_returntransfer, true); $result= curl_exec ($ch); curl_close ($ch); echo $result; }else { ?> <form action="<?php echo $_server['php_self']; ?>" method="post"> <img src="http://example.com/captcha.jsp" /> <input name="answer" /> <p><input type="submit" name="submit" value="submit"></p> </form> <?php }...

Rails: Scope: making a method available to all Views and Controllers -

i've struggled scope few days. have small number of methods available views , controllers. suppose code is: def login_role if current_user return current_user.role end return nil end if include in application_helper.rb, it's available views, not available controllers if include in application_controller.rb, it's available controllers, not available views. use helper_method method in applicationcontroller give views access. class applicationcontroller < actioncontroller::base helper_method :login_role def login_role current_user ? current_user.role : nil end end consider putting related methods in own module may make them available this: helper loginmethods

java - Distance transform in OpenCV output error -

Image
i'm using android binaries , first time i'm performing distance transform in opencv. opencv specification says output image of distancetransform 32-bit floating-point, single-channel image. mat (mdist), on creating bitmap out of mat throws illegalstateexception. due incompatibility of output , mat object? have specify color channel details mat or anything? following code portion. mat mimg = new mat(); mat mthresh = new mat(); mat mdist = new mat(); imageview imgview = (imageview) findviewbyid(r.id.imageview); bitmap bmpin = bitmapfactory.decoderesource(getresources(), r.drawable.w1); utils.bitmaptomat(bmpin, mimg); //load image mat imgproc.cvtcolor(mimg, mimg, imgproc.color_bgr2gray); imgproc.threshold(mimg, mthresh, 0, 255, imgproc.thresh_binary | imgproc.thresh_otsu); //grayscale , thresholding imgproc.distancetransform(mthresh, mdist, imgproc.cv...

sql server 2008 r2 - Can you use a Try Catch in a stored procedure to "do" something? -

i have linked servers need updates. begin try delete [sdny-pand\barcode].barcodes.dbo.barcodes plant_location <> 'jefferson, ga123' -- bla bla bla end try begin catch --print ' in error now' set @strbody = 'it appears server holds barcode data unavailable. please validate plugged in , turned on is' set @mailto = 'thatgroup@work' set @esubject = 'message barcode server update process' exec msdb.dbo.sp_send_dbmail @recipients =@mailto, @body = @strbody, @body_format ='text', @subject = @esubject, @profile_name ='colossusmain' end catch will process or there better way? you can better checking linked server status, way. there built-in procedure called sp_testlinkedserver . raise error if linked server unreachable, preventing trying deletes etc. , sending catch instead. if there further errors due delete, say, catch invoked, error_message() d...

vb.net - How to detect and get text from win32 popup in .net -

i've looked through several examples of trying listed on stackoverflow, haven't found lists how .net coding. need detect popup, , once found popup pull title of window, , text inside popup. i tried using post: how-can-i-change-text-on-a-win32-window but had no luck trying find how "get text" how see if popup exists. window i'm trying text standard windows error window (#32770) a.k.a win32 critical popup window (one red x). know title of error window going "tlp2011" i need able read title, text, , click "ok" on error button. reason? there's software run , cut on inbound call costs want write program detects errors popup, once been detected close error window , tell user error automatically fixed. (my new program have able read text error window in order determine how automatically fix error error doesn't show again) ----------edited show latest finds------------ thanks gx posting following link how can functionality simil...