Posts

Showing posts from January, 2012

mysql - Django group by dates and SUM values -

this question has answer here: django: group date (day, month, year) 5 answers is possible reproduce following mysql query in django without using select method ? mariadb [db1]> select datetime, sum(datas) table , datetime between '2013-07-26 13:00:00' , '2013-07-26 23:00:00' group datetime; to kind of result : +---------------------+-----------+ | datetime | sum(data) | +---------------------+-----------+ | 2013-07-26 13:00:00 | 489 | | 2013-07-26 14:00:00 | 2923 | | 2013-07-26 15:00:00 | 984 | | 2013-07-26 16:00:00 | 2795 | | 2013-07-26 17:00:00 | 1308 | | 2013-07-26 18:00:00 | 1365 | | 2013-07-26 19:00:00 | 1331 | | 2013-07-26 20:00:00 | 914 | | 2013-07-26 21:00:00 | 919 | | 2013-07-26 22:00:00 | 722 | | 2013-07-26 23:00:00 | 731 | +---------------------+-----------+ 1...

javascript - Autocomplete - two fields -

i'm trying create page fields, use autocomplete function. first field - "ana" works fine. second fails. don't see errors in console. prompt doesn't appear. here snippet: <script src="/inc/jquery-1.8.3.js"></script> <script src="/inc/jquery-ui.js"></script> <link href="/inc/jquery-ui.css" rel="stylesheet" type="text/css"/> <table> <tr> <td>ticker:</td><td><input type="text" name="ana" /></td> </tr> <tr> <td>cmp: </td><td><input type="text" name="sou" /></td> </tr> </table> <div id="result" style="margin-top:25px;"></div> <script language="javascript"> $(document).ready(function() { ana = [ <% getana %>]; $("input[name='ana']").autocomplete({ source: ana }); so...

c# - Drop and replace table in Excel via OleDb -

i need replace table created oledbcommand in excel file. new table has same name, has different structure. managed deleting sheet via interop.excel there problem when other sheets refer sheet. formulas lost. noticed creating new table via oledbcommand creates new defined name in names property (names manager). i've tried create new table other name, copy table headers , change name location in: workbook.names.item(shname, type.missing, type.missing).refersto=oldsheetrange where oldsheetrange column headers range. unfortunately when try insert new data rows not insert table (no error occurs). is there option replace table saving reffering formulas? regards, kuba

ember.js - How to save model relationships with ember data -

i have following model: app.loan = ds.model.extend name: ds.attr('string'), products: ds.hasmany('app.product') then on code i'm calling save method on loan object, has many products associated, loan gets posted server, associated objects not. quickly looking @ code, seems intended, because calling save on record add record, , record in current transaction. associated objects added if embedded. in case, first create new transaction, adding record , associated objects, , calling commit on transaction. like var transaction = store.transaction(); transaction.add(loan) loan.get('products').foreach(function(product)){ transaction.add(product); }); transaction.commit() if want embed products in loan, can configuring adapter this. assuming using default rest adapter: ds.restadapter.map('app.loan', { products: { embedded: } }

html - Download a file with javascript and ignore MIME -

i wants browser download video file when server ready. i have seen download file using javascript/jquery , however,it not possible change mime on server. but browser regard video streaming media , display @ hidden iframe,instead of download it. how can fix this,make browser ignore mime , download it? thanks help! maybe, html5 download attribute need? give client link video , add attribute it. not every browser supports it, though.

php - Wrong product URLs magento -

i've been working on custom sells related products script, displaying 4 random products. problem is: normal product url is: /shop/$productname this generating url like: /$productname/ or url like: /catalog/product/view/id/$productid/4/s/$productname/category/$categoryid/ i want have urls same so: /shop/$productname <div class="upsell"> <h2>you might interested in</h2> <?php // list mode ?> <?php $_iterator = 0; ?> <?php // grid mode ?> <table class="products-grid upsell" id="upsell-product-table"> <tbody> <tr> <?php $_collectionsize = $_productcollection->count() ?> <?php $_columncount = $this->getcolumncount(); $_columncount=4; ?> <?php $i=0; foreach ($_productcollection $_product): ?> <?php if ($i++%$_columncount==0): ?> <?php endif ?> <td> ...

c - Error in calculation of the number of digits in a number -

write program using if statement calculates how many digits number contains: my code : #include <stdio.h> int main (void) { int n; printf ("enter number :"); scanf ("%d",&n); if ( n<=9) printf ("textnumber has 1 digit:"); if ( n <=99) printf ("textnumber has 2 digits:"); if (n<=999) printf ("textnumber has 3 digits:"); if (n <=9999) printf ("textnumber has 4 digits:"); return 0; } the problem when run this, , put example : 223 i have result in screen : textnumber has 3 digitstextnumberhasfourdigits... where wrong? this because compiler punishing not indenting code properly. just kidding, in fact, your logic flawed (and/or expectation doesn't match working of code): need else if s because if number greater limit, it greater smaller limits too, of them printed - erroneously.

java - How to perform a p2 Install programmatically -

i use p2 perform installation through code, p2 director it, can't find api. please point me place start looking? i found starting point in class directorapplication , part of plug-in org.eclipse.equinox.p2.director.app .

Group tuple and list maintaining order python -

i have list , tuple. know tuples not meant modified, need join tuple list keeping order between two, example.. l1 = [(166l,), (155l,)] l2 = [0.74, 0.25] i l3 = [[166,0.74],[155,0.25]] i tried sorted(l1+l2) did not work giving [0.25, 0.7, (155l,), (166l,)] >>> l1 = [(166l,), (155l,)] >>> l2 = [0.74, 0.25] >>> zip([x x, in l1], l2) [(166l, 0.74), (155l, 0.25)] >>> map(list, zip([x x, in l1], l2)) [[166l, 0.74], [155l, 0.25]]

c# - Autorun Ngen.exe on First Run -

my app doesn't have installer. portable need run ngen.exe on because runs on startup. is recommended autorun ngen.exe on first run of app? cause problems later? there built in way it? is recommended autorun ngen.exe on first run of app? i have never read or heard such recommendation, interesting idea. i go , test whether works situation (which interesting insofar "portable"/"no-installer" requirement). is there built in way it? there not built-in way run ngen on first run of app; can done poc below demonstrates. poc code the following poc code incorporates code related answer . using system; using system.diagnostics; using system.io; using system.linq; using system.threading; namespace selfngenpoc { class program { static void main(string[] args) { /* * check whether app has been ngen'd code adapted * https://stackoverflow.com/a/20593260/1810429, outlines ...

java - how to convert specified time in particular timezone? -

i living in india timezone ist when want fix meeting uk client put time in field 10 a.m 11 a.m. how convert in gmt0000 uk time zone? basically have textfied enter time after inserted there 1 dropdown box containing available timezone when select uk timezone how convert process using java? thanks in advance.. tell me solve issue.. note: don't want manually? cause of selection converted? task.. hope understand problem.. regards.. india time gmt + 5.30 . 10.00 -5.30 can consider gmt time. in java can this dateformat df = new simpledateformat("hh:mm"); date dateist=df.parse("10:00"); // india time df.settimezone(timezone.gettimezone("gmt")); system.out.println(df.format(dateist));// uk time

ios - invalid context 0x0, Creating UIImage from CALayer -

i trying convert calayer uiimage code post . copied here. when use got tons of error. @ first put in nsobject class use store model. read in post suppose put in controller, view or category of calayer. tried putting in controller or calayer , still doesn't work. - (uiimage *)imagefromlayer:(calayer *)layer { if ([[uiscreen mainscreen] respondstoselector:@selector(scale)]) uigraphicsbeginimagecontextwithoptions([layer frame].size, no, [uiscreen mainscreen].scale); else uigraphicsbeginimagecontext([layer frame].size); [layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *outputimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return outputimage; } error: <error>: cgcontextsetstrokecolorwithcolor: invalid context 0x0 <error>: cgcontextsetlinewidth: invalid context 0x0 <error>: cgcontextmovetopoint: invalid context 0x0 <error>: cgcontextaddarc: invalid context 0x0 ...

foreign keys - Converting an ER diagram to SQL code -

Image
this er diagram, tables have made in sql code implementing constraints. made tables , tried implementing relationship via foreign keys, jus wanted confirm, whether these tables correct or not. 1) department table: create table department(dpet_id number primary key, dept_name varchar2(15) not null); 2) branch table: create table branch(branch_id varchar2(5) primary number, electives varchar2(10), dept_id number references department(dept_id)); 3) course table: create table course(course_id number primary key, course_name varchar2(10) not null,branch_id varchar2(5) references branch(branch_id)); 4) student table: create table student(stud_id number primary key, stud_name varchar2(30) not null, branch_id varchar2(5) references branch(branch_id); 5) applicant table: create table applicant(app_id number primary key, stud_id number constraint fk references student(stud_id) constraint stu_unq unique); 6) applicant_branch table: create table applicant_branch(app_i...

javascript - Google chart enabled page not loading when uploaded to the server -

i uploaded following index.html file subdomain , isn't loading. shows title tag. i want load when go xxx.myapp.com. setup ok on godaddy because see title, rest of page doesn't render. see network requests on server bit nothing... any thoughts? <!doctype html> <html> <head> <title>mi testing title</title> <!--load ajax api--> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript" src="http://www.myapp.com/js/helperfunctions.js"></script> <script type="text/javascript" src="http://www.myapp.com/js/settings.js"></script> <!-- zurb foundation--> <link type="text/css" rel="stylesheet" href="http://www.myapp.com/foundation-4.3.1/css/foundation.css" /> <link type="text/css" rel="stylesheet" href=...

OpenCV python videowriter Windows output mp4/other web video -

i trying use opencv in python output videos can used html5 video tag. however, can find things output avi files, doesn't work video tag know compatible four_ccs output mp4 files? you should take @ @ this link . lists four_cc output format.

node.js - what is the different between obj.__proto__ = events.EventEmitter.prototype and obj.prototype.__proto__ = events.EventEmitter.prototype -

obj.prototype.__proto__ = events.eventemitter.prototype i have seen code above sometimes, , google it, line copy of eventemitter properties obj. , see code this: obj.__proto__ = events.eventemitter.prototype so wondering if same? i saw first usage in article , in author gives exapmle: var events = require('events'); function door(colour) { this.colour = colour; events.eventemitter.call(this); this.open = function() { this.emit('open'); } } door.prototype.__proto__ = events.eventemitter.prototype; var frontdoor = new door('brown'); frontdoor.on('open', function() { console.log('ring ring ring'); }); frontdoor.open(); and explains: this line: door.prototype.__proto__ = events.eventemitter.prototype; copies of eventemitter properties door object. as second way, saw in source of hexo , in init.js, there code: var hexo = global.hexo = { base_dir(){return basedir}, public_dir(){return basedir ...

php - Ridiculously slow MySQL Queries in Joomla 3.x -

Image
before go further, let me say, i've done that's recommended when google "slow joomla" or "optimize joomla". is, site gzipped, of css , js optimized , minified, i'm not running unnecessary components, plugins, or modules (hardly any, in fact), images optimized, caching turned on (both page , progressive) , i'm on supah-fast cloud hosting rackspace, sql database on separate rackspace server. all of that, , i'm still getting load times upwards of 10-12 seconds, as 14-15. from joomla debug: application 0.000 seconds (+0.000); 0.75 mb (+0.755) - afterload application 0.027 seconds (+0.027); 2.25 mb (+1.491) - afterinitialise application 0.040 seconds (+0.013); 3.26 mb (+1.010) - afterroute application 11.986 seconds (+11.947); 5.09 mb (+1.833) - afterdispatch application 12.000 seconds (+0.014); 5.63 mb (+0.539) - beforerendermodule mod_chronoforms (tip line) application 12.006 seconds (+0.005); 5.85 mb (+0.225) - afterrendermodule mod_chron...

C# Task.Factory.NewTask and WCF. Why I'm doing wrong? -

i have application in wcf runs in machines on customer. 1 works server in net. in model, every time wcf "client" called, call wcf "server" obtain response. so, have configuration on interface: [webinvoke(bodystyle = webmessagebodystyle.wrappedrequest)] [operationcontract] myobjectreturn checkupdate(string foo1, string foo2, string foo3); in code, this: myobjectreturn myobjreturn = new myobjectreturn(); if (this.master) { myobjreturn.code = 15000; myobjreturn.message = "new update found"; return myobjreturn; } else { var mytask = task<myobjectreturn >.factory.startnew(() => { servercontractclient server = new servercontractclient(master.url); return server.checkupdate(foo1, foo2, foo3); } return mytask.result; } when wcf "client" calls "server", return null! if not use "task . factory.startnew", bad request error any tip? uh, first, "server" , ...

java - Printing applet GUI -

Image
i'm trying print same have in applet gui. the things it's when print it's not same... size of each component changes in disproportionately way. the gui: printed: the margins not problem, can fix them easily... can see barcode , vertical text has not proper size. main class: public class impresion extends applet{ printerjob job = printerjob.getprinterjob(); panel test; label test2; label test3; string copyparam = null; string dialogparam = null; string codeparam = null; string descparam = null; public void init(){ copyparam = this.getparameter("copias"); dialogparam = this.getparameter("ventanita"); codeparam = this.getparameter("codigo"); descparam = this.getparameter("descripcion"); copyparam = "1"; dialogparam = "1"; codeparam = "0...

java - ForeignCollection auto load with queryRaw() -

i have card class, has eager foreigncollection in it. have query instances of class dao.queryraw() , because select complicated built simple querybuilder (see other question ). how query , build objects rawrowmapper : genericrawresults<string[]> rawresults = getcarddao().queryraw(statement); list<card> results = new arraylist<card>(); (string[] row : rawresults) { results.add(getcarddao().getrawrowmapper().maprow(rawresults.getcolumnnames(), row)); } rawresults.close(); unfortunately when try foreigncollection on objects, returns null. if query objects simple dao.queryforfirst , foreigncollection ok. i have had same problem today. solution has been call dao.refresh(<card object>) for every object returned queryraw function (and accumulated "results" list). trick me, reloading objects db filled foreign collection.

javascript - Arrows navigation based on which section are you in -

does know if there exists plugin or similar achieve navigation on website: http://discover.store.sony.com/tablet/#entertainment i talking , down arrows appear when hovering on top pr bottom part of screen. in theory, shouldn't difficult write yourself. here's starting point achieve arrows when hovering on parts of page. need handle attaching specific links arrows depending on section user looking at. see comments more details. fiddle note in fiddle have used event.pagex , event.pagey current mouse position, in reality should use event.screenx , event.screeny . because demo in fiddle embedded small window actual page, using latter not work. // define how wide areas should // arrow appears var top_nav_height = 70; var bottom_nav_height = 70; // dimensions var page_height = $(document).height(); var half_arrow_size = $('.uparrow').width() / 2; // listen user moving mouse $(document).mousemove(function(event) { // mouse? var pos_y = even...

c# - Converting hexadecimal color to integer -

this integer color in database : "8689404". i change color following: color = colorhelper.fromargb(255, byte.parse(event.labelcolor.value.tostring("x8").substring(6, 2), numberstyles.hexnumber), byte.parse(event.labelcolor.value.tostring("x8").substring(4, 2), numberstyles.hexnumber), byte.parse(event.labelcolor.value.tostring("x8").substring(2, 2), numberstyles.hexnumber)) this gives me color string "#fffc9684" now problem unable parse color string integer, can save in database. have yet is: byte = byte.parse(labelcolor.color.trimstart('#').substring(0, 2), system.globalization.numberstyles.hexnumber); byte b = byte.parse(labelcolor.color.trimstart('#').substring(6, 2), system.globalization.numberstyles.hexnumber); byte g = byte.parse(labelcolor.color.trimstart('#').substring(4, 2), system.globalization.numberstyles.hexnumber); byte r = byte.parse(labelcolor.color.trimstart(...

html - Need a dynamic PHP gallery -

Image
so, i've made login page user gets redirected folder on server corresponds registered username if login info correct. now need way dynamically (or need admin page deal adding new content) page list images , or videos available user. this should presented thumbnails in gallery. each of these thumbnails represent "project", , if user clicks of these page can see content (multiple images/videos, details, , ability download images wants). also, want able sort main content. can tag each project multiple tags, , later sort them show me related projects. now, how do this? :p i'm not @ php, hoping point me in right direction? guess sql database here, simpler better. :) i dont know begin this, , i've spend time looking through web see if there exists scripts can use this. far i'm still left working login page :p in case i'm not clear, want: the user presented projects available him. can click of images , or videos in particular project. can do...

vba - Gah!! Error 424 runtime error : Object required Word Visual Basic -

im trying load contents of textfile variable titular error, searching vba knowledgebase led me belive that set mysql = my.computer.filesystem.readalltext("c:\sql_query_temp.res") would solve produces 'error : object required' when run. heres code, have missed? 'requires microsoft activex data objects x.x library in references public sub connecttoodbc() dim myconn new adodb.connection dim myrs new recordset dim mysql string dim myrows long 'open file containing sql query mysql = my.computer.filesystem.readalltext("c:\sql_query_temp.res") <----- bad! 'open connection myconn.open "dsn=database" 'do query myrs.source = mysql set myrs.activeconnection = myconn myrs.cursorlocation = aduseclient myrs.open 'count rows myrows = myrs.recordcount 'add text word document! selection.typetext (myrows) 'close connection myrs....

maintaining order in json (python flask) -

this question has answer here: items in json object out of order using “json.dumps”? 5 answers simplejson returns values not in order [duplicate] 4 answers i made sorted dictionary pass through json javascript, however, seems whenever throw json.dumps() changes order alphabetical keys. critical keep in order or else not work. there way achieve this? objects in json unordered collection of key:value pairs (same dictionaries in python), should use different data structure if order relevant. a structure (in json) work: { "columns" : [ "id", "name", "age"], "rows" : [[ "john", "john doe", 42], [ "jane", "jane miller", 28] ] }

c# - PayPal Windows 8 Checkout SDK -

i reading documentation paypal windows 8 checkout sdk windows phone 8 on: https://developer.paypal.com/webapps/developer/docs/classic/windows-8-checkout-sdk/gs_win8xo/ https://developer.paypal.com/webapps/developer/docs/classic/windows-8-checkout-sdk/ht_win8xo-examples/ now, have 3 questions: 1) api redirect buyer paypal's web page on button click, buyer can log-into account using paypal username , password , authorize transaction? 2) if answer question 1 no, api make use of browser control? 3) if api not make use of browser control, specify buyer's paypal account in code (see second link)? code on page pointed second link specifies merchant's paypal account. thank :) yes question #1. not sure if browser related answer expecting: user redirected either mobile or desktop friendly site them authorize transaction. if looking more specific related browser control please comment , can clarify further.

php - insert data with add previous row data in a column -

may easy way cant this.i try sum() in insert operation not working. have table name amount . id total_amount 1 200 2 400 3 600 4 800 5 1000 i want when i'll insert value in total_amount it'll insert , sum previous data. suppose if want add 500 in total amount it'll insert 1500 . id total_amount 6 1500 if want add 300 insert 1800 id total_amount 7 1800 how can this? you want use insert statement along query: insert t(id, total_amount) select max(id)+1, sum(total_amount) + 300 t; this setting value of id . if auto_increment , unnecessary.

unix - remove first line if there is a duplicate -

i know how remove duplicate lines using sort , uniq there way remove first line duplicate not second? for example, if have file following lines in it: aaaaaaa bbbbbbb bbbbbbb ccccccc aaaaaaa ccccccc the output needs be: bbbbbbb aaaaaaa ccccccc do need run loop of sort or can done uniq ? and, yes, know sorting backwards give me output that's not want. thanks. add sequential field beginning of each line using paste (1,2,3...), reverse list based on field, , run uniq ignoring field. sort field insure have remained in right order. remove field using cut or colrm.

sql server - SSRS Report takes longer to display than the Execution Long Indicates -

i've got report running on ssrs 2008 r2. report pretty simple tablix report; no subreports or that, not subtotalling. users want report "clean" when export excel can manipulate easily. query report stored procedure accepts 3 parameters. in development, runs in 30 seconds or less. stored procedure completes in less time that, depending upon parameters chosen. (client number, year , month.) it's been running on production server few weeks, now. , client has run specific set of parameters there takes 30 minutes complete! i've gone through usual debugging. sp takes 9 seconds parameters. i've read the article parameter sniffing , , that's not it. , i've checked values in reportserver.dbo.executionlog3 view. show results following: timestart: 2013-08-07 08:36:45.173 timeend: 2013-08-07 08:37:08.943 timedataretrieval: 11598 timeprocessing: 3408 timerendering: 8171 all of seems indicate report completed , ...

How to get Euler–Mascheroni's constant in R? -

is euler–mascheroni's constant $\gamma \approx 0.577$ available in r, $\pi$ pi or $e$ exp(1) ? mathmatically can write constant of interest negative of derivative of gamma function evaluated @ 1. r has derivative of gamma function digamma it's matter of plugging in. -digamma(1) #[1] 0.5772157

command line interface - Checking installed Yeoman generators -

Image
what powershell command run see yeoman generators have installed? i'm assuming it's npm command, have no idea since i'm new cli. this i'm seeing when enter "yo" command line. i'm on version 1.0.0-rc.1.3. you should able use yo -h in 1.0.0-rc.1.3 , list installed generators along generator tasks provide.

c++ - How to access the address of a static const member of a class? -

this code does't compile, , error information " undefined reference `a::a' ": code 1: #include <iostream> using namespace std; class { public: static const int a=0; }; int main() { cout<<&a::a<<endl; return 0; } but non-const static member compiles: code 2: #include <iostream> using namespace std; class { public: static int a; }; int a::a=0; int main() { cout<<&a::a<<endl; return 0; } is there no way of accessing address of static const member of class? if there is, how? , why code 1 not compile? put const int a::a; in source file, otherwise compiler doesn't generate address a. note value not repeated here.

jquery - Reload an iframe without flickering/flash (in Javascript) -

i ask if has simple solution allow me reload/refresh iframe without flickering/flash when page reloads, possible ? maybe animate blur-out , blur-in instead of flickering/flash? don't know input helpful, thanks. here how reload iframe now document.getelementbyid("frameid").contentdocument.location.reload(true); thanks help. easiest approach: create new iframe outside of dom or in hidden element. load page inside hidden frame once load fires within hidden frame, swap them around! swapping to swap them, have them next each other , toggle display: none / block css of each one.

JSONP Ajax Call with JQuery causes memory leak -

Image
i searched complete day , cannot find issue why such big memory leaks in phonegap application, uses lot of ajax-jsonp requests server. therefore broke down simplest example. can find here on jsfiddle . the main content of is: function run(){ $.ajax({ datatype: 'jsonp', url: "http://thawing-bayou-7281.herokuapp.com/test.js", success: function (res) { // stuff here settimeout(run, 250); } }); }; run(); so code calls jsonp api request endless time every 250ms. please note: know example never implement that! it's detecting memory leak. when run example used memory increases rapidly (you can see best in chromes timeline tab). number of dom nodes increasing rapidly. @ point breaks down (maybe gc?) elements , needed memory increases rapidly. has of idea how fix problem? thanks! this not memory leak, sawtooth type graphs common in java. memory usage ramps up, garbage collector ...

mod rewrite - remove dynamic part of url .htaccess -

i need remove dynamic part of url: example.com/pagename/?btag=a_233b_230c_&affid=201 so remove after , including "?" but don't want rule apply directory: example.com/wp-content/?attr=1345 is possible .htaccess? thanks, appreciated jon rewritecond %{request_uri} !^/wp-content that might help:-d repeat other folders.

android - How to convert ASCII char* to wchar_t* in C++ without using mbstowcs? -

i'd convert ascii char* wchar_t* in c++ on linux without using mbstowcs() . on ios , windows, works perfectly. on android, however, mbstowcs seems convert things quite literally, one-to-one. using different variations of setlocale() , i've been unable convert. i might end manually converting on android copying 1 byte, , filling rest zeroes. proper ascii? first 255 characters of utf-32/unicode same ascii (iso 8859-1/iso latin-1) character set? if don't mind taking stl dependency , using string , wstring instead of raw char * , wchar_t * pointers, can use function following perform string conversions: template<typename target, typename source> target convertstring(const source &s) { target result; result.assign(s.begin(), s.end()); return result; } use follows: #include <string> #include <iostream> using namespace std; int main() { wstring wstr(l"hello world"); string str(convertstring<strin...

Drag and zoom with canvas kineticjs -

i've made draggable stage kineticjs , made zoom function means of scaling canvas. when using zoom factor, canvas zooming center of screen. after dragging canvas , using zoom function, canvas still zooming point on center @ beginning dragged aside. what want zoom new point on center of screen after dragging. can please explain how handle this? thanks in advance! you need set offset fixed point (the centre of screen) canvas knows zoom. if not, zoom towards original point. var stage = new kinetic.stage({ container: 'container', width: 400, height: 300, offset: [200, 150] //zoom towards point (200,150) }; also, see answers here scaling fixed point in kineticjs juan.facorro , eric rowell (kineticjs developer) more information.

graphics - Matlab -plot a vector field -

Image
i have written function in matlab gives me vector @ position (x,y,z). now looking easiest way make colored map of field on grid , color should related norm of vector. what easiest way define such grid $x \in [x_0,x_1],y \in [y_0,y_1], z \in [z_0,z_1]$? linspace each component possible, maybe there command gives me grid. now need evaluate function. problem is, gives me 2 vectors, interested in first one. when first tried thought $[a(i,j,k),~]=function(x(i),y(j),z(k))$ work, did not(my goal was: choose first vector(a) , mark him reference(i,j,k), later on know coordinates vector belongs to). so highly interested in kind of ideas. instead of [a(i,j,k),~]=function(x(i),y(j),z(k)); try [a(i,j,k,:),~]=function(x(i),y(j),z(k)); so can fit entire size of 3-coordinate vector. also, if want preallocate space use = zeros(nx,ny,nz,3); where nx,... dims of coordinate space. @moly explains, use meshgrid generate 3d grid, [x y z] = meshgrid(x,y,z); and loop or...

zend framework - Callback functions in PHP < 5.3 -

i have multidimensional array , want usort in zendframework.** following code work in php 5.3+, not lower versions because of callback function in usort . usort($array, function (array $a, array $b) { return date('ymdhis',$a['time']) - date('ymdhis',$b['time']); }); so instead of callback function how can divide , use external function call in zend framework. in normal php script individual call working below. usort($array, 'usortcallback'); function usortcallback(array $a, array $b) { return date('ymdhis',$a['time']) - date('ymdhis',$b['time']); }); but want workable code zend framework. thanks, sandeep you can use create_function() , fork older php too. $callback = create_function( '$a, $b', 'return date("ymdhis",$a["time"]) - date("ymdhis",$b["time"]);' ); usort($array, $callback);

How to use Bootstrap accordion with a radio button list -

i trying build ui combines html radio button list accordion functionality offered bootstrap's collapse component. goal selecting radio button expands accordion panel below it. here's jsfiddle demonstrates partially working implementation. unfortunately, although accordion functionality works, radio buttons not selected (apart initial selection, subsequently never changes). please excuse invalid html in sample. aware input element doesn't have href attribute, don't believe cause of problem. i have seen this answer similar question, prefer avoid editing bootstrap code , hope there might purely declarative way of making work. many suggestions, tim edit: else facing same issue, functionality works out-of-the-box in bootstrap v3.0. i got work little jquery. jsfiddle i'm sure there more elegant ways of doing this. works. $('#collapseone').on('shown', function(){ $('#radio1').prop('checked', true); }); $(...

vb.net - Only Shows Error List For One vb File -

i'm kind of new visual studio. i've built few simple programs in it, i'm in process of rewriting huge system wrote in vba. frustrating me error list in vs listing errors 1 .vb file in project, lets call vbfile1 . now, when work on vb file, vbfile2 , in same project vbfile1 no red squiggles or errors listed vbfile2. don't understand how happen. i've tried/checked: filter set 'current project' , played around other filter settings no change. checked text editor under options , according research i've done fine. plus, have never changed of these settings anyway. closed , re-opened visual studio. closed open files in project , still displays same error list close files except vbfile2 still shows same error list of vbfile1. i have visual studio 2012 ultimate. feel should easy fix...i confused what's going on. hope makes sense! update: excluded project, vbfile1 , errors listed vbfile2...why be? i not sure if has been fixed ...

localization - How to localize ActiveReport 7.0 XML PageReports rdlx -

we have huge number of page reports created using activereport (*.rdlx files) use them our asp.net mvc web appolication. all captions , other stuff created on english now need add multilanguage support there so, somehow need existing texts inserted in resource file , can add translations is there way achive task quickly, without going each report field , manually extracting resource file? documentation says once change language property, resource files created, seems not working xml reports, or there shouldbe trick for reports designed code-behind, resource files created pretty same if create windows form... fail find out how xml reports. page reports support localization; doesn't resource file. this mentioned off-hand in single sentence on page localization activereports 7 . setting localized value in page report done same in section report. change report's language property , set new textbox values. @ report runtime appropriate value textbox used. ...

Windows path doesn't contain C:\WINDOWS\system32, can I add it using batch script? -

i writing batch script that, quite reasonably, depends on "c:\windows\system32" being part of path environment variable. encountered (developer's) machine had weird path didn't include system32, , therefore batch script didn't work. i looked ways batch script check path variable , add system32 if not there. however, solution found used setx ironically enough depends on system32 in path variable. there programmatic ways add system32 path without being there? also please let me know if such edge case doesn't make sense make script robust against it. i'm not expecting of typical users have such borked path variable. should bother? try this: for /f "delims=" %%a in ("%comspec%") set "path=%path%;%%~dpa" or this: for /f "delims=" %%a in ("%comspec%") set "compath=%%~dpa" set "path=%path%;%compath:~0,-1%"

C++ standard sort documentation issue -

my copy of c++ standard document documents standard sort function. 25.4.1.1 sort template<class randomaccessiterator> void sort(randomaccessiterator first, randomaccessiterator last); ... effects: sorts elements in range [first,last). requires: randomaccessiterator shall satisfy requirements of valueswappable (17.6.3.2). type of *first shall satisfy requirements of moveconstructible (table 20) , of moveassignable ok - shouldn't require elements referred comparable? i expect "requires" clause include like: "type results dereferencing randomaccessiterator should satisfy requirements of lessthancomparable ." or better yet " iterator_traits<randomaccessiterator>::value_type should satisfy requirements of lessthancomparable." since 24.4.1 says in part "it required if iterator type of iterator, types ... iterator_traits<iterator>::value_type defined" why isn't such language included. surely ...

Opening source code instead of decompiled class in eclipse 3.5 and jd-eclipse plugin -

i have set eclipse (eclipse 3.5) associate java run time jars source code. have accomplished associating jdk rt.jar source code ships jdk (c:\program files\java\jdk1.6.0_37\src.zip). i happen have jd-eclipse decompiler plugin setup. when click on hashmap class, opens decompiled hashmap class; wanted see source code (from jdk src.zip file). possible tell eclipse to: open associated source code library class if available. if source code not available; , decompile class? system info: eclipse 3.5 jd-eclipse 0.1.3 os: windows 7, 64 bit enterprise edition thanks in blog post , author describes 2 problems jd-eclipse plugin has: the generated source code doesn’t line debug line numbers because generated code can’t include original comments. if choose associate “*.class” file type within eclipse “class file editor” decompiled output if have real source attached. i guess 2. problem facing , appears jd-eclipse not capable of need. it looks mchr3k...

angularjs - Carousel slide effect with ng hide/show and ng-animate? -

i have slider type carousel 2 section containers can slide left , right. in developed version have images inside 1 section container. problem i'm experiencing because images server take while load i'm finding when user clicks button page being added dom again (due ng switch) , having reload images. my question: there way use ngif or hide/show instead page setting display: none when hidden page containers not shown not removed dom? <!--animate--> <div ng-animate="{enter: 'enter', leave: 'leave';}" ng-switch on="par.selection"> <!--page1--> <div class="page page1" ng-switch-when="settings"> <b>page 1</b><br><br> <button ng-click="par.selection = 'home'; go('front');" >go page 2</button> </div> <!--page2--> <div class="page page2" ng-switch-when="home"> ...

java - JSON deserialization with Gson -

this json data: { "boards": [ { "board": "3", "title": "3dcg", "ws_board": 1, "per_page": 15, "pages": 11 }, { "board": "a", "title": "anime & manga", "ws_board": 1, "per_page": 15, "pages": 11 }, { "board": "adv", "title": "advice", "ws_board": 1, "per_page": 15, "pages": 11 }, ... ] } this code deserialization: jsonobject json = readjsonfromurl("http://api.4chan.org/boards.json"); string jsonboards = json.tostring(); gson gson = new gson(); map<string, object> map = new hashmap<string,object>(); map = (map<string,object>) gson.fromjson(jsonboards, map.getclass()); but doesn...

Use PayPal's own "Thank you" page -

does paypal include own "thank purchase" page? want show thank page after successful payment. currently, return url getting opened in popup, want avoid. how can accomplish this? you should see paypal's thank page default unless have set settings show own. in case, can set back.

c# - Remove extra white spaces on string with special characters -

i having trouble removing white spaces following: abc\ae.exe 1 b 2%% acu > log.txt i using following code remove spaces (that found on s.o.): regex.replace(cmdline, @"^\s*$\n", string.empty, regexoptions.multiline).trimend(); the above code removing white spaces between abc\ae.exe & fine; however, not removing white space 2%% acu (has 2 spaces in between). i not familiar reg expressions assuming has fact % sign might reg ex key word. any guidance appreciated. regex.replace(cmdline,@"\s+"," "); will replace multiple spaces single space the + means match character 1 or more times here's regex guide c#

node.js - Mongoose upsert duplicate key error -

i'm trying upsert using mongoose, i'm getting duplicate key error key should trigger upsert. schema: "resource": {type: schema.objectid, ref: "resource"}, "skill": {type: schema.objectid, ref: "skill"}, "level": {type: number, min: 1, max: 5} .index({skill: 1, resource: 1}, {unique: true}); then make call: //self resource instance resourceskilllevel.update({ resource: self._id, skill: skill._id, level: level }, {$set: {level: level}}, {upsert: true}, cb); if (resource, skill) not exist, call works fine , creates resourceskilllevel entry. however, when call again duplicate key error index . listed duplicate key tuple resource/skill key. why isn't upserting when finds duplicate? you're including level in update query criteria parameter, if doesn't match existi...

javascript - Regex to get parameters of Embed -

code: var = [ /<b\>(.*?)<\/b\>/ig, /<i\>(.*?)<\/i\>/ig, /<u\>(.*?)<\/u\>/ig, /<br\/\>(.*?)/ig, /<embed(.*?)/ig ]; var b = [ '[b]$1[/b]', '[i]$1[/i]', '[u]$1[/u]', '\r', '[flash($2,$3)]$1[/flash]' ]; (var =0;i<a.length;i++) { ele = ele.replace(a[i], b[i]); } html: <embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://www.youtube.com/v/dm0vrhuu6ei" width="500" height="500" type="application/x-shockwave-flash" wmode="transparent" quality="high" scale="exactfit"> what is $1 starting position of [flash] $2 width parameter $3 height parameter the beginning of code change html elements bbcodes. should go regex different in embed regex? see example here better understand! http://jsbin.com/ajeqog/2/edit as turns out...