Posts

Showing posts from September, 2010

ruby on rails - Rerun JavaScript on successful ajax call -

i have delete button remote: true option set: # _categories.html.erb <%= link_to 'destroy', category, method: :delete, data: { confirm: 'are sure?' }, remote: true %> my destroy method uses json: # categories_controller.rb def destroy @category = admin::category.find(params[:id]) @category.destroy save_to_history("the category \"#{@category.name}\" has been destroyed", current_user.id) respond_to |format| # can't retrieve @categories before attempting delete one. @categories = admin::category.all format.json end end and destroy.json.erb file looks like: #destroy.json.erb <% self.formats = ["html"] %> { "html":"<%= raw escape_javascript( render :partial => 'categories', :content_type => 'text/html') %>" } now problem have javascript run on page load, , deleting initial category works intended... until data changes. n

c# - How to query records based on date -

i have datatable 5 columns type of int, string , datetime. have written linq query filter records date. how records today , yesterday? var data = _dtall.asenumerable() .where(datas => datas.field<datetime>("date") == datetime.now.date) .select(datas => new { ---}) i not getting records. record @ 14/05/2013 10:00 am. dont need query time, need query date. appriciated. the dates of yesterday , today dates between midnight yesterday (including) , midnight tomorrow (excluding): var upperbound = datetime.today.adddays(1); var lowerbound = datetime.today.adddays(-1); var data = _dtall.asenumerable() .where(datas => datas.field<datetime>("date") < upperbound) && datas.field<datetime>("date") >= lowerbound) .select(datas => new { ---})

java - android how to change the starting activity -

i have built application 1 activity android. want add login page should run first. how can change application run login first? my first activity mainactivity.java. went application's properties -> run/debug settings -> edit conf. -> launch action. there mainactivity, cannot see login activity. i using eclipse, way. is there easy way fix this? modify manifest: <activity android:name=".your_login_activity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> and modify entry of mainactivity <activity android:name=".mainactivity" android:label="@string/app_name" > </activity> update

Start service in blackberry 10 application -

hi new blackberry 10 application development , developing application can run service in background , start application @ particular interval. want know possible create services can run in background? read documents describe android features not supported blackberry runtime android apps on blackberry 10. =) software features no support run services in background. applications can run services while user runs them, either in fullscreen or in thumbnail mode

ios - NSURLCache not used by NSURLConnection / AFNetworkingOperation -

when start request nsurlrequestreturncachedataelseload policy expect result nsurlcache if any, no matter how old is. however, system tries reach server request points , returns error if server doesn't answer. i use uiimageview category of afnetworking request. nsurlrequest* request = [nsurlrequest requestwithurl:url cachepolicy:nsurlrequestreturncachedataelseload timeoutinterval:60.0]; __weak __typeof(self) weakself = self; nslog(@"[%@] %@", request.url, [[nsurlcache sharedurlcache] cachedresponseforrequest:request]); // returns instance of nscachedurlresponse! [self setimagewithurlrequest:request placeholderimage:nil success:^(nsurlrequest *request, nshttpurlresponse *response, uiimage *image) { __typeof(weakself) self = weakself; self.image = image; } failure:null]; this not set image if asking nsurlcache directly return valid nscachedurlresponse . the app running on ios6 only, there should no problems on-disk cache far know?! any appreciated!

performance - Fastest way to sort vectors by angle without actually computing that angle -

Image
many algorithms (e.g. graham scan ) require points or vectors sorted angle (perhaps seen other point, i.e. using difference vectors). order inherently cyclic, , cycle broken compute linear values doesn't matter much. real angle value doesn't matter either, long cyclic order maintained. doing atan2 call every point might wasteful. faster methods there compute value strictly monotonic in angle, way atan2 is? such functions apparently have been called “pseudoangle” some. i started play around , realised spec kind of incomplete. atan2 has discontinuity, because dx , dy varied, there's point atan2 jump between -pi , +pi. graph below shows 2 formulas suggested @mvg, , in fact both have discontinuity in different place compared atan2 . (nb: added 3 first formula , 4 alternative lines don't overlap on graph). if added atan2 graph straight line y=x. seems me there various answers, depending on 1 wants put discontinuity. if 1 wants replicate atan2 , answer

h.264 - How to create mp4 file from h264 encoded frames on android? -

i have h264 frames encoded android encoder. want create , write them 1 one mp4 file. please advise how on android in java. don't want use opencv or native code. mp4-parser can't understand navite mpeg4writer complicated use wondering why such common , useful thing mp4 writer not camera not implemented in android you may use mp4parser project. can mux h264 , aac in pure java it: h264trackimpl h264track = new h264trackimpl(new fileinputstream("raw.h264").getchannel()); movie m = new movie(); m.addtrack(h264track); isofile out = new defaultmp4builder().build(m); fileoutputstream fos = new fileoutputstream(new file("h264_output.mp4")); out.getbox(fos.getchannel()); fos.close();

BlackBerry Push Notifications , OS < 7.X -

i working on developing bb os<7.x application, implements push notifications. ended working code able receive push. however, push notifications dont work first time deploy application on phone. if try send push on device, after deployed it, when send push server, can see on right corner of device little arrow loading , no push message displayed on screen. if restart device, push notifications work properly!! whenever send push, see little arrow again on right screen , push message displayed corrected. the code looks this(the parts consider important): myapp.java public class myapp extends uiapplication { public static void main(string[] args) { //every time start application register bis push if (args.length > 0 && args[0].equals("blackberrycity")) { system.out.println("!!!!!!!!!!!!!!i inside if"); //registering push push_main.registerbpas();

javascript - What is the lifetime of a jQuery Mobile Widget? -

i have issue jquery mobile 1.3.1 table widget think related widget lifetime. i'm using table widget in columntoggle mode in page. on first use of page there no issues. if navigate around site (without refreshing browser window) , go page there seem 2 instances of widget hanging around. older 1 raises error if try , resize page, think because it's attempting manipulate elements unloaded. example code below , published in fiddle: http://jsfiddle.net/cjindustries/thqga/ (navigate page 2, resize browser. removal of elements emulates jqm unloading page.). can explain me how jquery mobile manages widgets in general , if/how need actively destroy widgets in scenario? thanks, chris. <div id="p1" data-role="page"> <table data-role="table" id="table1" data-mode="columntoggle" class="ui-responsive table-stroke"> <thead> <tr> <th data-priority="2">rank<

c# - returning one item at a time from ajax -

i have large list of objects have created in webmethod, takes long load. i wondering if had example of pulling 1 item @ time allowing ajax display each object it, making them see part of data faster(even tho may slower in long run) thanks. you need execute separate ajax request each item you're retrieving. webmethod needs receive parameter item should return on each request.

animate asp.net menu with javascript -

i found javascript code change opacity of asp.net menu items , $(function () { $("ul.level1 li").hover(function () { $(this).stop().animate({ opacity: 0.7}, "slow"); }, function () { $(this).stop().animate({ opacity: 1}, "slow"); }); }); but don't want change opacity ! how can if want change items' background color following function ? $(function () { $("ul.level1 li").hover(function () { $(this).stop().animate({ backgroundcolor: red}, "slow"); }, function () { $(this).stop().animate({ backgroundcolor: blue}, "slow"); }); }); you need this a better method use simple css transition :hover pseudo selector. update as said there no native support background color animation in jquery. need include plugin if want in javascript. still, see how easy make css here

python - asynchronous subprocess with timeout -

i have problem spawning asynchronous subprocesses timeout in python 3. what want achieve: want spawn multiple processes asynchronously without waiting results want assured every spawned process end within given timeout. i have found similar problems here: using module 'subprocess' timeout , asynchronous background processes in python? not solve issue. my code looks this. have command class suggested in using module 'subprocess' timeout : class command(object): def __init__(self, cmd): self.cmd = cmd self.process = none def run(self, timeout): def target(): print('thread started') args = shlex.split(self.cmd) self.process = subprocess.popen(args, shell=true) self.process.communicate() print('thread finished') thread = threading.thread(target=target) thread.start() thread.join(timeout) if thread.is_alive(): print('terminating process') self.process.terminate

angularjs - How do I use ng-animate in ng-repeat to shrink items on leave? -

i trying use new ng-animate directive, , struggling desired effect when used ng-repeat. trying make items grow when entering, , shrink when leaving. far enter working, shrink animation fails. i have set fiddle here can see issue:- http://jsfiddle.net/rpk98c/6t42m/1/ the relevant html is:- <ul> <li ng-animate="{enter: 'repeat-enter', leave: 'repeat-leave', move: 'repeat-move'}" ng-click="remove($index)" ng-repeat="name in names">{{name}}</li> </ul> and relevant css:- .repeat-enter-setup, .repeat-leave-setup, .repeat-move-setup { -webkit-transition:all linear 1s; -moz-transition:all linear 1s; -ms-transition:all linear 1s; -o-transition:all linear 1s; transition:all linear 1s; } .repeat-enter-setup { max-height: 0; opacity:0; } .repeat-enter-setup.repeat-enter-start { max-height: 250px; opacity:1; } .repeat-leave-setup { opacity:1;

symfony - Symfony2 - Validation for form with multiple entities not working -

i have form product relation onetomany entity productlocale , user can add many productlocale want. the rendered form in html seems correct when receive post array , perform bind() server response error: "error: value should of type wearplay\wearbundle\entity\productlocale. but send 2 productlocale entities , validator doesn't recognize them. it obvious post request contains multi-dimensional array contains various entities productlocale , question why $form->bindrequest($request) doesn't work correctly? edit #1: product entity <?php namespace wearplay\wearbundle\entity; use doctrine\orm\mapping orm; use doctrine\common\collections\arraycollection; use symfony\component\validator\constraints assert; /** * @orm\entity * @orm\haslifecyclecallbacks * @orm\table(name="product") */ class product { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ priv

Unable to redirect a category in Magento using URL Rewrites -

been banging head past few hours :) i have category (id:46) in magento being deactivated , redirect either category or landing page. i've removed system redirect url rewrite rules , following these guides http://www.aotearoadesigns.net/blog/magento-categories-1-product http://www.magentocommerce.com/wiki/modules_reference/english/mage_adminhtml/urlrewrite/index have far tried following: id path: category/46 request path: shops/friendly-uri target path: catalog/product/view/id/3111/category/52 (to redirect product) i have tried setting other category ids, , random values id path, various other urls target path, making category both active , inactive. nothing seems work. @ same time when try redirect non shop path "any-uri" seems work fine. any highly appreciated. first find , delete path category 46 catalog -> manage url rewrite -> search in id path "category/46" delete it. next create re-write catalog -> manage url rewrite

c++ - Reading multiple files, and keeping a set of data for each file. -

i want read file , save header in variable when rewriting(overwriting) file, can paste header , carry on printing rest of modified file. header, in case, not change can afford print out. here code inside class: . . . static char headerline[1024]; static int read(const char* filename){ fget(var,...; (int i=0; i<1024; ++i){ headerline[i] = var[i]; } . . . } int write(filename){ fprintf(filename, headerline); //printing rest of file . . . } the code prints line saved while reading file. however, problem saves header of file read last time. if have 2 files opened , want save first one, header of second file written first one. how can avoid that? if static map solution, that? secondly, best way print whole header(5-8 lines) instead of 1 line doing now. so, problem needs solving reading multiple files, , want keep set of data each file. there many ways solve this. 1 of connect filename header . suggested in comment, using std::map<std::string

Grouping MySQL results -

Image
i have following mysql query: select * members_family_view order `agelastsept` asc which returns following results: i want able change data returned display purposes instead of agelastsept displaying 7 display u8's, 8 display u9's, 10 display u11's, 11 display u12's, 12 display u13's , 13 display u14's. is possible in mysql query? try query select concat('u', (id+1), '\'s') name, total tbl sql fiddle : | name | total | ---------------- | u2's | 50 | | u3's | 55 | | u4's | 89 |

ios - what is the default orientation of the iPad? -

i have heard few conflicting comments regarding default orientation of ipad. some portrait (how tend use ipad), landscape. i have sort of thing in css target elements when device in portrait mode, find don't have same sort of scaling problems landscape , hence have no need media query below. @media , (orientation:portrait) { } i can't find anywhere says sure default orientation device. there one? there no default. both allowed , equally important. fact have problems portrait consequence of specific site's design, others you'll have same on landscape. since landscape presents 1024px wide browser user it's less probable cause issues since desktop sites historically 960 1050 pixels wide well. doesn't make 'default' though, less cause problems. it's identical asking default screen size desktop browser - doesn't have one, can resize @ will. rotating ipad intents , purposes that, sudden resize of browser.

sql - Insert Or Update After a Merge -

i have following merge operation on ms sql server. declare @data xml declare @id int declare @version rowversion set @data = ? set @id = ? <# if ( tw.local.enableoptimisticlocking == true ) { #> set @version = cast(? rowversion) <# } #> merge [<#=tw.local.dbschema#>].[<#=tw.local.tablename#>] target using (select @id id, @version version ) source on target.id = source.id when matched <# if ( tw.local.enableoptimisticlocking == true ) { #> , target.version = source.version <# } #> update set data = @data when not matched insert (data) values (@data) output $action _action<# if ( tw.local.enableoptimisticlocking == true ) { #>, cast( inserted.version bigint) [version]<# } #>, inserted.id; i wish have insert / update statement db , table update columns based on results of above merge. i not sure if can have other insert/update inside merge or need use output data want insert/update merge? i tried following not work....

java - on listview filtration is not working properly -

Image
i facing problem while filtration of list .i using ontextchange() method .it working problem type single character in edit text soft keyboard gets disappear , have tap edit text again type complete string .i have done code soft keyboard not disappear after text change type still have tap on edit text.here code : search.addtextchangedlistener(new textwatcher() { @ override public void ontextchanged(charsequence s, int start, int before, int count) { // todo auto-generated method stub string startwith = s.tostring(); arraylist < myshares > filterlist = new arraylist < myshares > (); (int = 0; < filelist.size(); i++) { if (filelist.get(i).getname().tolowercase().startswith(startwith) || filelist.get(i).getname().touppercase().startswith(startwith)) { filterlist.add(filelist.get(i)); } } adapter = new mlistadapter(playlistactiv

html - JavaScript: expand div to max height without getting scroll bars -

i working on document structure this: <html> <head> <script src="http:http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript" charset="utf-8"></script> </head> <body> <h1>title</h1> <div id="main"> <div id="head">some text</div> <div id="content"><canvas id="canvas"></canvas></div> <div id="foot">some more text (and table)</div> </div> </body> </html> this is, of course, bit simplified, shows real structure of document. now, want extend #canvas document wide , high possible without getting out of viewport (i.e., without getting scroll bars on document). css-only solutions not o.k. @ least 2 reasons: this done dynamically, on request. depending on other factors, user may chose content of #canvas bigger or smaller that. want "make o

c# - WPF coordinate System update -

Image
i created coordinate system on canvas element. draw every got value red point , connect old one. see here: i'm getting every second 10 values. 1 value = 1 pixel the red line represent values, i'm getting constant value testing. my goal update drawing when reaches end of coordinate system. want push drawing left , draw next points. my goal is: i dont want lose points in graph because later want zoom in , out i dont want slow down system less possible ... this code not sure how can update graph in ending part.... static double xold = 32; static double yold = 580; static double t = 32; system.windows.shapes.path path; static geometrygroup linegroupdrw1 = new geometrygroup(); .... public void drawpoly(double value) { //increase point position t++; //generate 2 point connection point pone = new point(xold, yold); point ptwo = new point(t, va

javascript - WebGL: Reuse assets when reusing a canvas -

i'm writing small tool allows developers render 3d content on canvas using webgl. it used specifying view , camera, simplified example: displayview( '#mycanvas1', [0, 5, 2] ); which might called several times display in several canvases: displayview( '#myfrontcanvas', [0, 5, 2] ); displayview( '#mysidecanvas', [5, 0, 2] ); or might called multiple times on same canvas change view: displayview( '#mycanvas', [0, 5, 2] ); // later displayview( '#mycanvas', [5, 0, 2] ); // later displayview( '.thiscanvasisactuallythesameoneagain', [5, 0, 0] ); each time it's called on new canvas, need set buffers, shaders, etc. when called on used canvas, should re-use old buffers , shaders. don't think it's possible share resources between contexts need duplicate & keep track of them myself. my thought store buffers, shaders, etc. in array each time called on canvas, search array in later calls. can't store canvas

ember.js - Ember Array Controller - function not loading -

i new ember , trying load small array controller. trouble is, addcard function i've defined in cardscontroller not showing , getting error: "object function() has no method 'addcard'". doing wrong? using following: handlebars-1.0.0-rc.3.js, ember-1.0.0-rc.3.js, ember-data.js here code: app = ember.application.create({ ready: function(){ //populate content[] in cardcontroller app.getcards(); } }); app.getcards = function(){ card1 = app.card.create({ id: 0, title: 'alabama', desc: 'montgomery' }); app.cardscontroller.addcard(card1); }; app.card = ember.object.extend({ id: null, title: null, desc: null, current: true }); app.cardscontroller = ember.arraycontroller.extend({ content: [], //property adds item content addcard: function(item){ this.addobject(item); } }); assuming is code make app, nee

ariatemplates - Model update on keydown for TextInput -

how can make textinput widget update model on keyup or keydown (like autocomplete) instead of blur? i saw in sources these events added in dropdowntextinput, guess didn't miss configuration option. creating new widget mandatory behavior want? there easier way? or code snippets maybe? if don't care style provided default skin, use @html:textinput widget. it provides type event out of box. for template_error on instantat, it's bug should fixed asap.

python - How to get numbers from filenames? -

i have many files in directory according key: pic001.jpg pic002.jpg pic012.jpg [...] ico001.jpg ico002.jpg ico012.jpg [...] and want list files , create structure this: for r,d,f in os.walk(directory): file in f: if file.startswith("pic"): pic = file ico = ??? images_list.append({ 'big': directory + '/' + pic, 'thumb': directory + '/' + ico, }) how "pic" file , "ico" assigned him (only if ico exist)? the simplest answer seems be: ico = 'ico' + file[3:]

vectorization - Vectorising an R function -

i have following function f <- function(x){sum(g(x - x))} where x - n-dimensional vector data g vecrtorized function how can vectorize function f take n-dimensional input , yield n-dimensional output? i trying following rowsums(sapply(x, "-", x)) the problem approach not cover case of one-dimensional x . possible cover both cases? example let x <- c(1,2,3) x <- c(6,9,1) g <- function(x){x^2} if use sapply -based code correct answer (n-dimensional vector) rowsums(sapply(x, "-", x)) [1] -12 -21 3 but if set x=1 , run same code, wrong answer (n-dimensional vector instead of scalar) rowsums(sapply(x, "-", x)) [1] -5 -8 0 this not surprising, since rowsums applied column-vector gives column vector. need in case of one-dimensional x , apply sum . there elegant way without using if conditional on dimensions? it seems have 2 examples, i've named them f , h : x <- c(6,9,1) g <- function(x){x^2}

c++ - Boost Spirit placeholder type conversion -

i'm trying write parser (as first step, of course expanded lot) parses double , creates object of class expressiontree passing double factory method of class. first try struct operands : qi::grammar<string::iterator, expressiontree()> { operands() : operands::base_type(start) { start = qi::double_[qi::_val = expressiontree::number(qi::_1)]; } qi::rule<string::iterator, expressiontree()> start; }; this doesn't compile ( can't convert boost::spirit::_1_type double ) because (if understand correctly) qi::_1 not double evaluates double. i tried using boost::bind(&expressiontree::number, _1) in way don't know how result assigned attribute _val i grateful if point me in right direction. you need lazy actors in semantic actions. i'm assuming number static unary function or non-static nullary (instead of, e.g. type): start = qi::double_ [ qi::_val = boost::phoenix::bind(&expressiontree::number, qi

javascript - node js : should be use alert to invoke the function? -

i dont know happen code..i have node.js queries mysql db within route , displays result user. problem how run queries , block until queries done before redirecting user page requested? if add alert before call,function run , quick response..but if alert disable function cant return value,the function freeze.. this user code request value nodejs function fred(){ //request function here fblue alert('fred called'); //if disable alert,the function not return value get('id', function(datmovmar) { var obj = json.parse(datmovmar); var items = object.keys(obj); var output=''; items.foreach(function(item) { output+=obj[item].something+'<br/>'; alert(output); }); }); } function get(id, callback) { $.ajax('http://localhost:8000/' + id + '/', { type: 'get', datatype: 'json', success: function(data) { if ( callb

excel - Apache POI - Generating conditional formatting that refers to other cells -

Image
i'm generating xssf spreadsheet in java using apache poi. i'm trying generate conditional formatting formula that's similar "if value in cell $a2="x", turn $c2 green", , apply way down column c. i haven't seen examples of online, though—all examples seen deal 1 column @ time, not references. possible do? the conditional formatting rule want apply like: sheetconditionalformatting scf = sheet.getsheetconditionalformatting(); conditionalformattingrule cfr1 = scf.createconditionalformattingrule("(indirect(address(row(), column() - 1))) = \"cds correct\""); the formula finds whatever value of cell 2 left of current cell. can use cellrangeaddress appropriate number of rows in c column have populated.

c# - XNA - Freezing Menu Error -

when click down arrow gets stuck on second selection , or down no longer work, how fix that? second question: how prevent freezing when changing menu items? when change menu items, freezes of second selection. here code concerning question; keyboard = keyboard.getstate(); mouse = mouse.getstate(); if (keyboard.iskeyup(keys.up) && prevkeyboard.iskeydown(keys.down)) { if (selected > 0) selected--; else selected.equals(buttonlist.count - 1); } if (keyboard.iskeyup(keys.up) && prevkeyboard.iskeydown(keys.down)) { if (selected < buttonlist.count - 1) selected++; else selected.equals(0); } prevmouse = mouse; prevkeyboard = keyboard; } the original code had, after being modified worked fine me. here modifications: public void update(gametime gametime) { keyboard = keyboard.getstate(); mouse = mouse.getstate(); if (checkkeyboard(keys.up)) {

php - parse next value from xml feed on page refresh -

i have xml feed can access using simplexml_load_file , using each access of records in it. able access individual node using following: $xml->property[0]->propertyid; what want ble indvidually display each record in turn, ie move [0] [1] , on in turn on page refresh don't know how go that. i'm hobbyist please forgive me if bit of newb question you need introduce state somewhere, can remember you've got to. you can either have browser count each time page refreshed using cookie , or can remember on server side storing current node number somewhere - in database, in file, or in url. probably simplest thing tack next node number onto end of url, when page reloaded, you'll see parameter on server side , can load node. this: $node = 0; if (empty($_get['nextnode'])) { header('location: example.php?nextnode=' . node + 1); } else { $node = $_get['nextnode']; } ... $xml->property[$node]->propertyid; when pag

html - Youtube iFrame inside another iFrame -

on site have banners @ top, banners iframe elements. need add youtube video, inside banner iframe. how add youtube iframe inside iframe? problem is, can add youtube video banner, can't change size of youtube video without changing whole iframe. i can make whole thing in html has iframe. , stuck. you put iframe next iframe banner, put position absolute , position within iframe. dirty doable. <iframe style="position: absolute; left: 0px; top: 0px;" src="" /></iframe>

c# - Validating inherited attribute using DataAnnotations -

i have mvc project relies on webservices provide data , webservices based on cmis specification custom functionality. have several classes used datacontracts, created visual studio when added references services calling. using class model ensure able send instances service , process correctly sent me. i have views edit instances of classes , use dataannotations validate forms (usually [required] atribute , display name change). i not want put atributes in service reference files because updating reference mean loose atributes (at least not sure still same after reference update). my thought create child class serve tool introduce dataannotations atributes know sure using (those not dissapear datacontract class sure). how accomplish such inheritance code? example - have class created vs in reference.cs file: [system.diagnostics.debuggerstepthroughattribute()] [system.codedom.compiler.generatedcodeattribute("system.runtime.serialization", "4.0.0.0")] [sy

javascript - No database is running on event click -

this code working. tx.executesql('insert routes (id_object) values (4)'); tx.executesql("select * routes", [], function (tx, result) { alert(result.rows.item(0)['id_object']) }, function (tx, error) {alert('Неудача');} )}; but doesn't working. added click event. <button id = "click2">Добавить в БД</button> function querysuccess(tx, results) { $('#click2').click(addobject); function addobject(tt){ tt.executesql('insert routes (id_object) values (4)'); tt.executesql("select * routes", [], function (tt, result) { alert(result.rows.item(0)['id_object']) }, function (tt, error) {alert('Неудача');} ) }; why that? the transaction tx closed shortly after function querysuccess returns. click handler executed later, when doesn't have valid transaction. you have create new transaction inside click handler.

cuda - Global device variable OpenCL -

how can declare device variable global threads in opencl? i'm porting code cuda opencl. in cuda implementation have like ... ... __device__ int d_var; ... ... void foo() { int h_var = 0 cudamemcpytosymbol(d_var, h_var, sizeof(int)); do{ //launch kernel, inside kernel d_var modified cudamemcpyfromsymbol(h_var, d_var, sizeof(int)); }while(h_var != 0); } i've been reading through opencl example codes cannot figure out how this. advise great ! unfortunately not straight-forward port. whereas i'm not sure if can @ least define , use (read/write) such global variable in opencl program (but don't think so), there no way access (read/write) variable host. what have put kernel additional kernel argument. if writen host , read kernel ordinary int variable suffice (thus copy each kernel). in case written in kernel , read host, has __global pointer, appropriate buffer bound: __kernel void func(..., __global int *d_var) { ... } whic

ios - How to create NSDate like '2013-05-11 00:00:00' -

this question has answer here: how create current date (or date) nsdate without hours, minutes , seconds? 2 answers how can nsdate object today @ midnight? 9 answers this basic question, guess, can't seem find answer in of books. suppose have date, created this: nsdate *today = [nsdate date]; but want change time part of 'today' '00:00:00'. how can this? ---- added ---- i tried this: nsdatecomponents *components = [[nsdatecomponents alloc] init]; [components setday:11]; [components setmonth:5]; [components setyear:2013]; [components sethour:0]; [components setminute:0]; [components setsecond:0]; nscalendar *calendar = [nscalendar currentcalendar]; nsdate *startdate = [calendar datefromcomponents:components];

.net - Overloaded methods give "Method with optional parameter is hidden by overload" warning in Resharper -

i have few c# apps logging, , output method has overload accept message , streamwriter, , overload additional parameter params array. example of method signatures is: private static void output(string message, streamwriter writer, params object[] args) {..} private static void output(string message, streamwriter writer) {..} the question concerns resharper gives following warning these methods: " method optional parameter hidden overload ". the warning misleading because call 2-param overload inside 3 param overload , not result in recursive call, overload not hidden. i did research on resharper site , there have been tickets opened on issue have been closed "will not fix". it seems me valid use case, since runtime knows overload call. there examples in .net framework use such overloads. for example, streamwriter.writeline() has overloads value write, , format params . is valid argument, or should methods renamed "outputformat" since