Posts

Showing posts from June, 2014

javascript - Error in the format of JSON -

i have json format : [15:17:37,612] ({rb:"0.6", i:[{id:"cost_reportings_timestamp", label:"cost_reportings_timestamp", type:"date", pattern:""}, {id:"bureau de m. le maire min-sum-cost_reportings_cost", label:"bureau de m. le maire", type:"number", pattern:""}, {id:"salle de r\xe9union min-sum-cost_reportings_cost", label:"salle de r\xe9union", type:"number", pattern:""}, {id:"secr\xe9tariat / accueil min-sum-cost_reportings_cost", label:"secr\xe9tariat / accueil", type:"number", pattern:""}], k:[{c:[{v:(new date(1354921200000))}, {v:0}, {v:1.8221145868301392}, {v:1.0604355335235596}]}, {c:[{v:(new date(1355007600000))}, {v:0}, {v:2.288118362426758}, {v:0}]}, {c:[{v:(new date(1355094000000))}, {v:0.4536628723144531}, {v:2.1034255027770996}, {v:1.1031612157821655}]}, {c:[{v:(new date(1355180400000))}, {v:0.4586494

Javascript function not getting all values first time -

i trying let user upload list of items filter search results table by. problem not rows don't have values in filter list removed first time, program want need run multiple times. the attached code works, want remove 'badworkaround()' function <div align="center"> <script> function readlist() { var origtext = document.getelementbyid("cusiptextarea").value; var filterlist = origtext.split("\n"); var table = document.getelementbyid("resultstable"); var rows = table.getelementsbytagname("tr"); for(i = 1; < rows.length; i++) #first row has column names start @ i=1 { var found = '0' for(j = 0; j < filterlist.length; j++) { if (rows[i].innerhtml.indexof(filterlist[j]) > 0){ found = '1' break; } } if (found != '1'){rows[i].remove();} } } function badworkaround(){ readlist();

javascript - Looking for responsive js carousel -

i trying find carousel in: http://whiteshoe.ferragamo.com simpler. need responsive full page carousel items have description , link on "active" mode, , others title , inactive, darker or greyish. ive tried 1 http://caroufredsel.dev7studios.com don't know how add inactive/active states, , responsive: true doesn't re size images. :) it's funny, seems responsive of responsive caroussel doesn't work in browser (on demo page)... there lot of responsive jquery caroussel anyway, you'll find 1 on google...

ruby on rails - Jquery fancybox doesnt show - only after page reload -

this view: <div id='profile_galery'> <ul> <li class='big'><%=link_to image_tag(@profile.user.get_avatar(:large) ), @profile.user.get_avatar(:very_large), :class => 'fancybox'%></li> and js: $(document).on("ready page:change", function() { $(".fancybox").fancybox({ openeffect : 'elastic' }); }); when go page image fancybox class , click on - there no fancybox but... html change , page locked. seems fancybox opened did not show , blocked everything. when reload page - fancybox works. whats going on? try add parent option $('.fancybox').fancybox({ parent: "body"});

Passing 'next' to django login template via urls.py -

i'm trying pass 'next' field login.html template via urls.py file using code this works fine: urls((r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'myapp/login.html'}), but don't want redirect after login go '/accounts/profile/' page, want go site root, '/'. url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html', 'next':'/'}), but get login() got unexpected keyword argument 'next' not sure how pass 'next' argument via urls function , can't seem find other solutions, advice? i able this, url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html', 'extra_context': {'next':'/'}}),

how can i compare the index in iPhone -

i have taken indexes of array shown in tableview , want play @ didselectrowatindexpath same in index. mpmediaitem *item = [arranand objectatindex:3]; nsurl *url = [item valueforproperty:mpmediaitempropertyasseturl]; avplayeritem *playeritem = [[avplayeritem alloc] initwithurl:url]; player2 = [[avplayer alloc] initwithplayeritem:playeritem]; [player2 play]; here have pass 3 ..but need index match select @ did select row help!! the tableview:didselectrowatindexpath: pass indexpath object, contains index of selected table cell: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { mpmediaitem *item = [arranand objectatindex:indexpath.row]; nsurl *url = [item valueforproperty:mpmediaitempropertyasseturl]; avplayeritem *playeritem = [[avplayeritem alloc] initwithurl:url]; player2 = [[avplayer alloc] initwithplayeritem:playeritem]; [player2 play]; } the indexpath.row give direct index if not have sections in tab

javascript - jQuery: using localized variable -

Image
i trying use jquery cookie in order show/hide div element. var cexpiry = lu_ban_object.cexpiry; jquery('.float_close').click(function () { jquery('.float_notice').fadetoggle('slow'); jquery.cookie('noticevisibility', 'hidden', { expires: [cexpiry], //problem here path: '/' }); the expires: number , represents cookie expiry day. number being stored in array , localized, have assigned localized numebr cexpiry variable, not accepting brackets, [] have tried () , {} not working, +[cexpiry]+ i following error; uncaught typeerror: object [object array] has no method 'toutcstring' how change data type number? according screenshot saved string. expires needs date object or number. question, looks cexpiry number already, no need cast object or array wrapping in brackets. cexpiry might stored string, if that's cas

python - How to connect to access (.mdb) database with pyodbc using latin-1 filename -

i use code connect access (.mdb) database: # -*- coding: latin-1 -*- filemdb = 'c:\\python27\\optimisateurlievre\\final\\archives_previsionsesp_août_2013.mdb' param = "driver={microsoft access driver (*.mdb)};dbq={%s};pwd={pw}" % filemdb con = odbc.connect(param) i following error: pyodbc.error: ('hy000', '[hy000] [microsoft][pilote odbc microsoft access] filename incorrect. (-1044) (sqldriverconnect); [hy000] [microsoft][pilote odbc microsoft access] filename incorrect. (-1044)') the problem seems come database filename û caracter. understanding of string , unicode, filemdb string encoded in latin-1. since, computer runs latin-1 encoding don't understand why filename incorrect. i work windows xp , python 2.7. thank help! it appears pyodbc tries convert connection string 'ascii' , characters above 0x7f invalid: con = pyodbc.connect(param) unicodedecodeerror: 'ascii' codec can't decode byte

html - Make Text Overlap to 1px horizontal line -

i trying put text on horizontal line. want if text length increases line should adjusted according text length. working fine on ie7,8, mozilla. want make work google chrome. it's working fine except google chrome. here code: /*css*/ .pagehd{ font-size:30px; color:#369; font-weight:bold; padding:20px 0} .pagehd p{display:block; margin-right:10px} .title-line{ height:1px; border:0 none; background:#e5e5e5; position: relative; right:0; top:0px} <!--html--> <div class="pagehd"><p class="left">zones showcases</p> <hr class="title-line" /></div> can me this. thanks.! here's understand on question: you want make text overlap hr element. if i'm not mistaken on understanding question, answer. just make content after hr overlap hr. your new html be: <div class="pagehd"><hr class="title-line" /></div> and new css be: .pagehd { font-size:30px;

c++ - conversion operator with template functions -

i have class conversion operator std::string . works great except functions receiving std::basic_string<t> (templated on t ). #include <string> struct a{ operator std::string(){return std::string();} }; void f(const std::basic_string<char> &){} template<typename t> void g(const std::basic_string<t> &) {} int main(){ a; f(a); // works! g(a); // error! return 0; // because otherwise i'll lot of comments :) } the error receive error: no matching function call 'g(a&)' note: candidate is: note: template<class t> void g(const std::basic_string<_chart>&) now, know can define g friend in struct a , it'll work, problem lot of stl functions exist , receive std::basic_string<t> (for example, operator<< printing function, or comparison operators, or many other functions. i able use a if std::string . there way this? i able use i

javascript - Enabling vendor prefixes in CSS transitions make callback fires twice -

i'm implementing excellent solution (found here ) use callback function a la jquery when using css transitions. the problem if use vendor prefixes, chrome @ least binds 2 events: 1 webkittransitionend , second 1 transitionend and, of course, fires callback twice. here's piece of code: jquery("#main").one('webkittransitionend otransitionend otransitionend mstransitionend transitionend', function(e) { console.log("poum!"); }); am doing wrong? you're not doing wrong. chrome uses both prefixed , un-prefixed versions. there couple options: using outside variable. var fired = false; jquery("#main").one('webkittransitionend otransitionend otransitionend mstransitionend transitionend', function(e) { if ( ! fired ) { fired = true; console.log("poum!"); } }); using kind of detection single variable transitionend (the below uses modernizr, , taken documentation ): var tran

dynamics crm 2011 - Microsoft CRM Plugin Infinite Loop -

another ms crm question me, i'm afraid. i've got following code being executed on update of contact record gives me error saying job cancelled because includes infinite loop. can tell me why happening, please? // <copyright file="postcontactupdate.cs" company=""> // copyright (c) 2013 rights reserved // </copyright> // <author></author> // <date>8/7/2013 2:04:26 pm</date> // <summary>implements postcontactupdate plugin.</summary> // <auto-generated> // code generated tool. // runtime version:4.0.30319.1 // </auto-generated> namespace plugins3test { using system; using system.servicemodel; using microsoft.xrm.sdk; using microsoft.xrm.sdk.query; /// <summary> /// postcontactupdate plugin. /// fires when following attributes updated: /// attributes /// </summary> public class postcontactupdate: plugin { /// <summary&g

c# - Updating Datagrid datacontext eats memory -

i have wpf datagrid , need update every minute. have added dispatchtimer data , update data context of datagrid. problem seems data sticking around. first thinking lists had lists running out updated datacontext , don't see megs of memory being used. dispatchertimer dispatchertimer = new dispatchertimer(); dispatchertimer.tick += new eventhandler(dispatchertimer_tick); dispatchertimer.interval = new timespan(0, 0, 1); i have set 1 second testing. private void dispatchertimer_tick(object sender, eventargs e) { observablecollection<technician> techdata = loaddata(); dg1.datacontext = null; dg1.datacontext = techdata; } ... private observablecollection<technician> loaddata() { observablecollection<technician> techdata = new observablecollection<technician>(); uri urigreenimage = new uri("pack://application:,,,/images/green.png"); uri uriredimage

javascript - Hide Input Field and Still Take User Input -

i working on project need hidden input field take user input. i have javascript in place focus on input field. when div visible can see typing. when hide div type , make div visible again not see change. how can make when div hidden, still take user input? really, if there way besides hiding, great. <html> <body> <div id="diva"> <input name="geta" id="geta" type="text" onkeypress="javascript:geta.focus();" onkeyup="javascript:geta.focus();" onblur="javascript:geta.focus();" onchange="javascript:geta.focus();" /> </div> <button onclick="javascript:change();">show/hide div</button> <script language="javascript" type="text/javascript"> <!-- function change() { var div = document.getelementbyid('diva'); if (div.style.display !== 'none') { div.style.display = 'none'; } else {

java - contains method of String is not working properly -

i have 1 question not able solve . public static void main(string [] arg) { string description = "this time $fb highest priority"; list<string> list = new arraylist<string>(); list.add("$fb"); list.add("$f"); for(string s : list) { if(description.contains(s)) { system.out.println(s); } } } the out put getting $fb , $f dummy string contains 1 string of list .. other method give exact match ? it looks want see if word contained. can this: set<string> words = new hashset<string>(arrays.aslist(description.split(" "))); ... words.contains(s) ...

java - JFormattedTextField not working correctly -

i have code: jformattedtextfield formattedtextfield = new jformattedtextfield(); formattedtextfield.setbounds(25, 330, 56, 20); contentpanel.add(formattedtextfield); formattedtextfield.setvalue(new double(10.0)); its supposed accepting double numbers, if input character, 's', taken anyway. how can change block make accept keyboard numbers or ','? ignoring other character

java - Behaviour of lastAccessTime BasicFileAttributes.. -

i know should in order change return value of lastaccesstime system.out.println("last access time is:"+basicattributes.lastaccesstime()); system.out.println("last modified time:"+basicattributes.lastmodifiedtime()); even though access file called readattributes on.. lastaccesstime() methods not update value time last accessed file.. using ubuntu , attribute should supported.. what's wrong that? thanks in advance. the operating system isn't obliged update directory every time access file. when close file.

postgresql - Postgres access with www-data and --host argument -

i want access postgres www-data user. command launched cli. my program need able launch command : psql --username www-data --host=127.0.0.1 --dbname=dbname it work if remove --host=127.0.0.1, unfortunately use third party program command , can change it. my pg_hba.conf standard local postgres peer # type database user address method # "local" unix domain socket connections local peer #host www-data 127.0.0.1/32 md5 # ipv4 local connections: host 127.0.0.1/32 md5 # ipv6 local connections: host ::1/128 md5 in postgresql.conf put listen_addresses = '*' yes it's insecure testing everything. still doesn't work in .pgpass 127.0.0.1:5432:*:www-data:password i tried method : peer, ident, md5, passw

WPF. TextBlock and TextBox aligned properly -

what have when size of border container wide enough: name value namelonger value then size of border gets smaller , have this: name value namelonger v i used wrappanel , achieved this: name value namelonger value it better achieve this: name value namelonger value is possible achieve such thing? not sure if totally understand explaining based on think yiou describing, looking for? <border> <grid> <grid.columndefinitions> <columndefinition width="auto"></columndefinition> <columndefinition width="auto"></columndefinition> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="auto"></rowdefinition> <rowdefinition height="auto"></rowdefinition> </grid.rowdefinitions> <!--put textblocks in here--> </grid> </bord

c# - Entity framework distinct but not on all columns -

i'd make query through entity framework unions contacts 2 different tables, remove duplicates , orders date. issue i'm having around different dates making same contact appear unique. don't want include date in distinct need afterwards ordering. can't ordering first, remove date , perform distinct, because distinct changes ordering. neither can order before union because doesn't ensure ordering after union. i distinct fields except date, required ordering. ideally pass comparer distinct ef can't translate sql. db.packages.select(p => new recent() { name = p.attention, address1 = p.address1, ... , date = shippingdate }) .concat(db.letters.select(l => new recent() { name = l.addressedto, address1 = p.address1, ..., date = markeddate }) .distinct() .orderbydescending(r => r.date); or problem in sql select distinct attention, address1, shippingdate packages union select addressedto, address1, markeddate letters order shipmentdate desc

python - CSV read/write using regex re.sub -

i'd read csv file , recompile using: re.sub('\s+(street|st|trail|trl|tr)\s*$', '', test_file, flags=re.m) i'm getting: typeerror: expected string or buffer when using: import csv reader = csv.reader(open("some.csv", "rb")) row in reader: print row import csv writer = csv.writer(open("some.csv", "wb")) writer.writerows(someiterable) looks need function. have sugestions? you have pass string re.sub() third argument, can line of reader object. can pass writer iterable substitutions: import csv reader = csv.reader(open("input.csv", "rb")) writer = csv.writer(open("output.csv", "wb")) test = '\s+(street|st|trail|trl|tr)\s*$' writer.writerows( (re.sub(test, '', line[0], flags=re.m) line in reader) )

c# - Redirect https to http using rewrite rule in webconfig file -

this have tried far. <rule name="https main site http" stopprocessing="true"> <match url="^(.*)$" ignorecase="true" /> <conditions> <add input="{https}" pattern="off" /> </conditions> <action type="redirect" url="http://{http_host}/{request_uri}" /> </rule> how can redirect https://www.mysite.com http://www.mysite.com this asked long time ago, looks has been answered here: how force https using web.config file . pay close attention 1 of comments mentions query string appended twice if use full answer.

Multiple python loops in same process -

i have project i'm writing in python sending hardware (phidgets) commands. because i'll interfacing more 1 hardware component, need have more 1 loop running concurrently. i've researched python multiprocessing module, turns out hardware can controlled 1 process @ time, loops need run in same process. as of right now, i've been able accomplish task tk() loop, without using of gui tools. example: from tk import tk class hardwarecommand: def __init__(self): # define tk object self.root = tk() # open hardware, set self. variables, call other functions self.hardwareloop() self.udplistenloop() self.eventlistenloop() # start tk loop self.root.mainloop() def hardwareloop(self): # timed processing hardware sethardwarestate(self.state) self.root.after(100,self.hardwareloop) def udplistenloop(self): # listen commands udp, call appropriate functions

How can I run a Ruby script from command line and get the response using Java code? -

i need run ruby script using command line java code. for example file in path d:/myproject/myruby.rb i want run file command line , response that. how can achieve this? also, how can return response in myruby.rb caught in command line. you can use this: string[] commands = {"ruby","d:/myproject/myruby.rb"}; runtime rt = runtime.getruntime(); process proc; try { proc = rt.exec(commands); bufferedreader stdinput = new bufferedreader(new inputstreamreader(proc.getinputstream())); string s; while ((s = stdinput.readline()) != null) { system.out.println(s); } } catch (ioexception e) { e.printstacktrace(); }

java - Can't start another activity in Android -

i'm learning android developpement, , wrote short , easy code, doesn't work. can't start activity,despite many try ! here code of main activity : @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_pageaccueil); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.pageaccueil, menu); return true; } public void oncreate1(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_pageaccueil); final button button = (button) findviewbyid(r.id.button1); button.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent intent = new intent(pageaccueil.this, devise.class); startactivity(intent); } }); } } and button part of xml layout first/main activity : <button android:

sql - Within the same group find and exclude records that have the same parent ID for certain types -

i have table following: groupid parentid type 1 abc ind 1 abc ind 1 cde ord 1 efg std 2 zzz ind 2 zzz ind 2 zzz ind 3 yyy cor 3 yyy cor i need exclude records in same group, having same parent id , type ind or cor. need keep groups have different parent id , type not ind or cor. so result want following: groupid parentid type 1 abc ind 1 abc ind 1 cde ord 1 efg std somehow thinking use rank () over(partition groupid order parentid) , won't give me results want. any thoughts? ps: table has 5 million+ records. looking effective way deal it. thanks the following gives list of groupids want exclude select groupid ( select groupid, count(distinct parentid) pcount, count(distinct typecode) tcount, max(typec

Laravel 4 One To Many relationship Error -

i laravel newbie , trying follow documentation.so have 2 models, 'user' model , 'userphone' model. user has many phones. user model: public function userphone() { return $this->hasmany('userphone'); } userphone model: public function user(){ return $this->belongsto('user'); } on controller trying "copy" documentation: $userphone = user::find(1)->userphone; well result error: trying property of non-object i know missing here , cannot find it. i'm pretty sure don't have user id of 1. $userphone = user::find(1)->userphone; this should work, but, if doesn't find user first part: user::find(1) i return null , null not object, error: trying property of non-object . my advice is, try this var_dump( user::find(1) ); and if receive null, found problem.

skeletal mesh - Looking for skeleton or polygon offset algorithm in R -

Image
i found useful links in question an algorithm inflating/deflating (offsetting, buffering) polygons . sorry - no 'net access sos doesn't work, have implementation of skeleton algorithm in r? edit: generate deflated polygons in stackoverflow link (top image); or seen on http://en.wikipedia.org/wiki/straight_skeleton . gbuffer() , elegant , powerful rgeos package accepts negative values in width argument, returning spatialpolygons 'shrunk' given amount. library(sp) library(rgeos) ## create spatialpolygons object set of x-y coordinates (the hard part!) xy2sp <- function(xy, id=null) { if(is.null(id)) id <- sample(1e12, size=1) spatialpolygons(list(polygons(list(polygon(xy)), id=id)), proj4string=crs("+proj=merc")) } xy <- data.frame(x=c(0,2,3,1,0), y=c(0,0,2,2,0)) sp <- xy2sp(xy) ## shrink spatialpolygons object supplying negative width gbuffer() plot(sp) plot(gbuffer(sp, width=-0.2), add=true, bo

java - How do I encode the url in below code? -

i looking how escape/encode special characters when passing url in request. public static void senddata(string strval) throws ioexception{ string dosend="https://myhost.com/views?strval="+strval; httpclient httpclient = new defaulthttpclient(); try { system.out.println("inside try"); uribuilder builder = new uribuilder(); system.out.println("builder="+builder); builder.setscheme("http"); builder.sethost("myhost.com").setpath("/views?"); builder.addparameter("strval", strval); system.out.println("add param,sethost,setpath complete"); uri uri = builder.build(); system.out.println("uri="+uri); httpget httpget = new httpget(uri); system.out.println("httpget"+httpget); httpresponse response = httpclient.execute(httpget); system.out.println(response.getstatusline().tostring()); if (response.getstatuslin

Is it necessary to logout of SSH? -

if files being edited, know .swp can left, , history of commands not written, there serious drawbacks terminating shell rather exiting cleanly ? from security view nothing @ all. it's question of connection. if goes wrong there can non aligned connection between client , server, in 1 think other connected in fact it's not. in case have wait timeout. know can force client exit enter ~ . but server side think you'll have wait. however normally, closing of client shell heard server.

Copy a PHP array item that contains an object -

i copy array item contains object. $arr = [ 'first_item' => [ 'label' => 'a', 'date' => new datetime('1999-12-30') ], 'second_item' => [ 'label' => 'b', 'date' => new datetime('1999-12-31') ] ]; $copy = $arr['second_item']; $copy['label'] = 'c'; // ok, not affect $arr['second_item'] $copy['date']->setdate(2000, 1, 1); // changes $arr['second_item'] just out of ideas, tried replace $copy = $arr['second_item'] $copy = clone $arr['second_item'] (understandably) fails *"fatal error: __clone method called on non-object"* message.

turn off iCloud backup for my application iOS sdk -

i have problems because of icloud , want turn off app,how can in code of application,i thought problem , decision can turning off icloud, help if store files in documents, backed icloud automatically. if don't want that, easiest way store them somewhere else. library/caches choice. if must store in documents want disable icloud backup can use technique outlined here: https://developer.apple.com/library/ios/#qa/qa1719/_index.html

html - Font changes size depending on looking at site with www or non-www -

i have website seems change size in fonts when looking @ both www version , non www version. i know obvious answer setup 301 redirect, curious why happens have never seen before. examples here http://trentmcminn.com http://www.trentmcminn.com i'm not seeing differences, when zoomed in on 1 site font changed images stayed same. zoomed in/out on 1 of urls? try pressing ctrl/cmd+0 , see if helps.

javascript - Angular sharing data between controllers using service -

i'm using service share data between controllers. in first controller call function this: musclegroupservice.setstate(true); here code function in service : var state; function setstate(x) { state = x; } x becomes true, reason state doesn't become true, stays undefined. how can fix ? edit i believe i've managed find problem is, i'm not sure how solve it. in index.html have line of code: <div class="modal fade" ng-include src="'/content/templates/modals/admin/modalmusclegroup.html'" id="addmodal"> </div> and page ng-include includes modalmusclegroup.html , controller modal window. and modal widnow controller when smth. this: musclegroupservice.isitembeingupdated() it returns undefined don't watch variable state. i believe can fixes using $rootscope , $rootscope.$broadcast , $rootscope.$on. there other way without using $rootscope ? edit 2 here code: part of ctrl

shell - A way not to wait for Heroku to compile/Git pre-receive hook to finish -

i push rails builds heroku via git. unfamiliar, code pushed heroku git push , , pre-receive hook compiles whole thing before validating reception. the thing is, waiting compilation long (typically 2 minutes me) , adds when 1 ends pushing , re-pushing many small changes. 2 minutes can turn fifteen, while i'm being deprived of shell. is there way not have wait after compilation/hook finish gain shell still feedback eg. if fails? i know suspend ( ^z ) command, i'm not sure if halt process/prevent feedback. i imagine if pre-receive hook fails, exits exit code. mean git push exists non-zero exit code. if that's case, can run small wrapper: git push, redirect output file, , when done check exit code. if success, notify (email? beep?). if failure -- same, , can check output in temporary file. that wrapper run "in background": git_push_wrapper.sh mybranch & . if wanted "detach" within script (daemonize it), run without & , not

c++ - Function to find whether a tree is mono (all the elements are unique) or not? -

im trying add total function , ismono functions code. did total already need function ismono returns whether tree mono (all elements unique aka no element appears more 1 time) or not. please #ifndef t_h #define t_h #include <iostream> #include <iomanip> using namespace std; struct tnode { int info ; int count; tnode * right, *left; }; tnode * insert(int target,tnode * t); tnode * makenode(int x); tnode * tsearch(int x,tnode * t); void inorder(tnode * t); int height(tnode * t); int count(tnode * t) ; int total(tnode * t) ; #endif int main() { int n,c; tnode * t = null, *x; while (cin >> n) {t=insert(n,t);cout << n <<' ';} cout << endl; inorder(t); cout << endl; c = count(t); cout << "count: "<< c <<endl; cout << endl; c = height(t); cout << "height: "<< c <<endl; cout << endl; c=200; while (c--&g

vb.net - Extract data from one table to anoher -

i have main database. extraction data datatable , need update private database data avoiding doubling. when use update command, data doubling in private database, in case of fill nothing happens @ all. here code: dim table new datatable cn = new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=c:\main.mdb;jet oledb:database password=123") cmd = new oledb.oledbcommand {.connection = cn} cn.open() cmd.commandtext = "select * catalogue" da = new oledbdataadapter(cmd) da.acceptchangesduringfill = false da.fill(table) da.dispose() cn.close() '-------------- cn = new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=private.mdb;jet oledb:database password=123" cmd = new oledb.oledbcommand {.connection = cn} cn.open() cmd.commandtext = "select * catalogue" da = new oledbdataadapter(cmd) mybuilder = new oledbcommandbuilder(da) da.fill(table) 'add no data da.update(table) 'doubling data da.dispose() cn.close()

flash - Actionscript - listening to property changed event on the object -

in actionscript3, there event can listen whenever property of object gets updated? i found propertychangeevent dealing flex event objects. i'm not familiar flex , mean application use it's components. application writtien strictly in actionscript3. update looks there in actionscript-2 - object.watch in actionscript3, there event can listen whenever property of object gets updated? no, or @ least not default! in flex, custom properties on objects implemented get/set methods , set methods dispatch property change event. this: private var _myvar : someclass; public function myvar():someclass{ return _myvar; } public function set myvar(value:someclass):void{ _myvar = value; dispatchevent(new event('myvarchanged')); } this used binding in flex framework , of these 'propertychanged' events not documented. every once in while become useful. in non-flex code; you're more welcome write properties in same exact manner. no

multiprocessing - Is looping and blocking on recv the best way to handle a long-lived process in python? -

i have set of long-lived process expensive setup want push bank of worker processes doing work parallel. each worker different, building different parts of our database. shut down workers , rebuild them, every 4 hours or so. the python examples i've seen multiprocessing module seem all-the-same, short-lived processes 1 thing once , exit. here's sample came distributing work bank of all-different, long-lived workers. is on track, or there better way this? class worker(process): def __init__(self): process.__init__(self) # ...or super self.parent_side, self.pipe = pipe() def do_super_slow_initialization(self): print 'all work , no play makes jack dull boy' def run(self): self.do_super_slow_initialization() while true: message = self.pipe.recv() if not message: break self.pipe.send({'message': message, 'pid':

iphone - NSURL set to `nil` instead of path -

i have following code: nsurl* savetourl = [[nsurl alloc] initwithstring:[self.recording filepath]]; nslog([savetourl absolutestring]); nslog(@"?"); nslog([self.recording filepath]); which outputs following 2013-08-07 15:51:32.182 spyapp[49799:c07] ? 2013-08-07 15:51:32.183 spyapp[49799:c07] /users/mike/library/application support/iphone simulator/6.1/applications/c9ede058-5c8b-4b75-8638-d5a4265b348f/documents/recordings/ujaxvehvjlgwfuw in debugger, can see savetourl nil , despite fact [self.recording filepath] returns /users/mike/library/application support/iphone simulator/6.1/applications/c9ede058-5c8b-4b75-8638-d5a4265b348f/documents/recordings/ujaxvehvjlgwfuw why that? how fix it? because filepath path, not url. create file url, use different method: nsurl* savetourl = [[nsurl alloc] initfileurlwithpath:[self.recording filepath]]; on side note, first parameter nslog should constant string, never know when filepath have % in it. nslog(@"

amazon web services - IAM allowing a user to access everything for ec2 on a region -

i'm trying allow 1 user actions on us-west-2, policy have. { "version": "2012-10-17", "statement": [{ "effect": "allow", "action": ["ec2:*"], "resource": "arn:aws:ec2:us-west-2:837625274593:*" } ] } i got account number "owner" parameter on instance, not sure if it. { "statement": [ { "sid": "stmt1375943389569", "action": "ec2:*", "effect": "allow", "resource": "*", "condition": { "stringequals": { "ec2:region": "us-west-2" } } } ] } that should enable user have access ec2 in us-west-2 region

c# - Extension Method for Custom Attributes -

i working asp.net mvc4 website , have model & view model layer. because of reasons have different names few properties in model , viewmodel model public partial class project { public string desc {get; set;} } view model public class projectviewmodel { public string description { get; set; } } now @ model layer, need use viewmodel name of property if different. thinking of creating custom attribute can have in models: public partial class project { [viewmodelpropertyname("description")] public string desc {get;set;} } and use @ model layer string.format("viewmodel property name {0}", this.desc.viewmodelpropertyname()) i want generic if there no viewmodelpropertyname attribute on property should return same property name i.e. if desc property has no attribute should return "desc" only. here tried public class viewmodelpropertynameattribute : system.attribute { #region fields string viewmodelpropertyna

javascript - How to design a Map application with Backbone? -

so want build map application backbone(probably using leaflet.js). have few ideas on how design this, , wondering if there common design pattern on how this. the map integrated other visualizations - example if select marker on map happen in visualization. must able conduct geo-searches on markers in map. there 2 ways thought of doing - 1.have backbone model per marker, have collection of markers, have map view works on collection. whenever collection changes, re-render map. 2.have model called mapmodel holds json, , have data function filters json (based on geosearch or something). map renders json. the advantage of 1 think easy selections, map may deal tens of thousands, hundreds of thousands of objects, feel things very slow. is there way this, or 1 of 2 ideas i've had preferable? thanks i've been working on same problem, not claim have found "common design pattern", can tell did. i created mapmodel contains info necessary make map: ins

Trouble in calculating the field while creating view in postgresql -

i have 2 tables q1data , q1lookup in postgres database. q1data contains 3 columns ( postid , reasonid , other ) , q1lookup contains 2 columns ( reasonid , reason ). i trying create view include 4 columns ( reasonid , reason , count , percentage ). count count of each reason , percentage should each count divided total of count(*) q1data (i.e. total rows if reasonid ). but gives error , says syntax error near count(*) . following code using. please help. select cwfis_web.q1data.reasonid reasonid, cwfis_web.q1lookup.reason reason, count(cwfis_web.q1data.reasonid) count, round( ( ( count(cwfis_web.q1data.reasonid) / (select count(0) count(*) cwfis_web.q1data) ) * 100 ) ,0) percentage cwfis_web.q1data join cwfis_web.q1lookup on cwfis_web.q1data.reasonid = cwfis_web.q1lookup.reasonid group cwfis_web.q1data.reasonid; firstl

asp classic - Response.write multi line html for ASP? -

i have asp page displays online form after validating user. i'm using response.write "form goes here" however, form long (100+ lines). is there way can response.write multi-line html? want this: <% if rs.rcount > 0 response.write " <form> <input type="text" id="inputemail"> </form>" end if %> many thanks, use code block, not response.write . <% ...your vb .... if a=b %> <h1> html goes here</h1> <form> <input type="text" id="inputemail"> </form> <% end if ... more vb code %>

WPF datagrid semi-transparent selected cells (like Excel) -

Image
in excel, bluish background selection color appears semi-transparent, user can still see true background color when cell selected. how can same effect achieved wpf datagrid? in particular case, cell's background color binded view model. initial impression use trigger in cell style: <style.triggers> <trigger property="isselected" value="true"> <setter property="background" value="????"></setter> </trigger> </style.triggers> then somehow value should calculate ... combination of blue , unselected background color? tried using brush of transparent blue, result not blend previous cell background color. what have tried should work. look @ example: <grid x:name="layoutroot" datacontext="{binding source={staticresource sampledatasource}}"> <grid.rowdefinitions> <rowdefinition height="*"/> &l

Finding an empty slot in array and using it -

so have problem have been messing while in squirrel. want create goes through inside array, e.g: local array = [1, 2, 3, -1, 5, -1, 7, -1]; and -1, want use 1 of them, 1 comes first (which in case between 3 , 5). in script, when destroys object, sets objects id -1 instead of regular number, because otherwise through out errors when trying use object. don't know if i'm doing job explaining this. another example when players connect game server, have players id 0, 1, 3 , 4 connected, when next player connects id 2. thing i'm after arrays. i have tried several things, thing closest this: for(local i=1; < array.len(); i++){ if(array[i].id != -1){ count++; } else { count = i; } } but problem 1 takes last id , replaces it, have objects 0, 1, 2 , 3 if destroy 3 , create new one, no problem. if destroy either 0, 1 or 2 instead , create new 1 not take slot, instead go number 4, not work. thanks reading, out there can me this. solved:

ios - Issues with UINavigationItem changing properties at runtime -

i have navigation bar, wich contains navigation item, contains 2 bar buttons, these created in storyboard, , wanted change 1 of buttons @ runtime, works: - (void)viewdidload { [super viewdidload]; // additional setup after loading view. uinavigationitem *thisnavbar = [self mynavigationitem]; thisnavbar.rightbarbuttonitem = nil; // works, gets removed uibarbuttonitem *insertbtn = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemedit target:self action:@selector(insertskemaitem:)]; thisnavbar.rightbarbuttonitem = insertbtn; // works, sets btn } now, in other method, called controller, not work - (void)callchildchange { ... // remove old btn uinavigationitem *thisnavbar = [self skemanavigationitem]; thisnavbar.rightbarbuttonitem = nil; // not work? } there nothing wrong method, runs fine, nav btn item not removed ? skemanavigationitem navigation item, declared in .h file links navigation item made via st

signals - Python: Catch Ctrl-C command. Prompt "really want to quit (y/n)", resume execution if no -

i have program may have lengthy execution. in main module have following: import signal def run_program() ...time consuming execution... def exit_gracefully(signal, frame): ... log exiting information ... ... close open files ... sys.exit(0) if __name__ == '__main__': signal.signal(signal.sigint, exit_gracefully) run_program() this works fine, i'd possibility pause execution upon catching sigint, prompting user if quit, , resuming left off in run_program() if decide don't want quit. the way can think of doing running program in separate thread, keeping main thread waiting on , ready catch sigint. if user wants quit main thread can cleanup , kill child thread. is there simpler way? the python signal handlers not seem real signal handlers; happen after fact, in normal flow , after c handler has returned. you'd try put quit logic within signal handler. signal handler runs in main thread, block execution there too. some

statistics - Run Smirnov test in Java -

i'm trying run smirnov test in java, see if 2 sets of data come same distribution. however, getting "cannot find symbol" error. how "construct" smirnov test not error? import java.io.*; import java.util.arrays; import java.util.arraylist; import java.util.list; import java.util.regex.*; import jsc.independentsamples.smirnovtest; import jsc.*; public class test{ public static void main(string[] arg) throws exception { double[] array1 = {1.1,2.2,3.3}; double[] array2 = {1.2,2.3,3.4}; smirnovtest test = smirnovtest(array1, array2); test.getsp(); } } two possible issues, not mutually exclusive , 1 of them definitely issue. your classpath wrong. make sure jsc.jar in classpath. you need invoke constructor smirnovtest using instance creation expression requires use of keyword new . that is smirnovtest test = new smirnovtest(array1, array2); ^^^ the second definitely issue code. without using key

multiple curves on single vPython plot -

i put 2 curves on 1 vpython plot. possible? i opening curve with: gd = gdisplay(x=300, y=0, width=600, height=600, title='entropy', xtitle='time', ytitle='n', foreground=color.black, background=color.red, xmax=250, xmin=0, ymax=400, ymin=0.) funct1=gcurve(color=color.white) i updating single curve inside while loop funct1.plot(pos=(bigindex,entropy)) along plotting entropy on graph, i'd plot number of particles in particular position. 1 set of axis, 2 curves. each curve undated inside loop students can see 1 curve grow other decreases. is possible? simply create gcurve object. update both curves simultanously in while loop using plot command. example: from visual import * visual.graph import * gd = gdisplay(x=300, y=0, width=600, height=600, title='entropy', xtitle='time', ytitle='n', foreground=color.black, background=color.white, xmax=250, xmin=0, ymax=400, ymin=0.) funct1=gcurve(color=color.

Netty Worker Executor pool size and number of Netty I/O workers -

i using fixed thread pool of size 8 netty worker executor. tried send same curl requests again , again server. find curl requests hang after 7 or 8 times consistently. tried increase worker executor pool size 16 , able more curl requests earlier still hangs after 15 18 times. these questions: is minimum limit worker executor thread pool size internal netty? is number of netty i/o workers same worker executor thread pool size? if not how these 2 sizes related ? thanks, sudha you should use executors.newcachedthreadpool() , limit number of workers int in *channelfactory instance

java - Programming a recursive method to calculate number of groups with n elements and k groups -

precondition: 0 < k <= n method needs return number of ways k groups can formed out of n distinct items. example, there 3 ways form 2 groups out of 3 items: 1. (a) (b,c) 2. (b) (a,c) 3. (c) (a,b) , there 6 ways form 3 groups out of 4 items: 1. (a) (b,c) (d) 2. (a) (b) (c,d) 3. (a) (c) (b,d) 4. (a,b) (c) (d) 5. (b) (a,c) (d) 6. (b) (c) (a,d) so far have public static int groups (int n, int k){ if(n==k){ return n; }else if(n>1 && k==1){ return 1; }else return n*groups(n-1, k-1); } i don't know go recursive on this. see no way break down smaller subproblems because once start counting possibilities twice. appreciated. you write: i see no way break down smaller subproblems because once start counting possibilities twice. this not true. once create first group, items in first group no longer in set of candidate items , , subproblem becomes counting possible groupings of remaining items - which,