Posts

Showing posts from July, 2012

postgresql - Play framework configuration for connection limit 60 of postgreql on heroku -

i have set 3 play 2.1.1 application (api, admin panel , website) on heroku postgresql database. out of these api , admin panel accessing database. postgresql package have set consists of following configurations: connection limit : 60 row limit : unlimited ram : 410 mb i have following configurations in play application database in both api & admin panel: db.default.url=database_url db.default.partitioncount=1 db.default.maxconnectionsperpartition=10 db.default.minconnectionsperpartition=5 db.default.driver="org.postgresql.driver" db.default.idlemaxage=10 minutes db.default.idleconnectiontestperiod=30 seconds db.default.connectiontimeout=20 second db.default.connectionteststatement="select 1" db.default.maxconnectionage=30 minutes i getting timeout exception connecting database of bonecp. want verify if above configurations right can debug in right way. please me same. thank you. heroku close connections after 30 seconds maxconnectionage has...

java - Increacing the speed of thread -

after every call of thread it's speed increased (specifically - firstcirclerepaintthread, secoundcirclerepaintthread, linerepaintthread). main thread's speed normal. i've read this question, thread's speed always increasing. github , jar on dropbox p.s. sorry bad english the problem is, each time unblock creating new instance of threads, you're not stopping old ones, still running, updating ui public void block() { setvisible(true); // create bunch of new threads... firstcirclethr = new firstcirclerepaintthread(); firstcirclethr.setpriority(thread.max_priority); firstcirclethr.start(); secoundcirclethr = new secoundcirclerepaintthread(); secoundcirclethr.setpriority(thread.max_priority); secoundcirclethr.start(); linethr = new linerepaintthread(); linethr.setpriority(thread.max_priority); linethr.start(); } public void unblock(){ setvisible(false); // dereference old ones, still runnin...

java - some problems in EditText in ListView -

i new in android , working on simple andriod apps. i'm writing listview , want put edittext , textviews it. idea put 1 textview followed 1 edittext in every items on listview. can values edittext make calculations , result. can make listview , handle calculations. cannot make listview own. have been searched google instructions make cannot find resources. can please give me sample codes can have guide follow... thank that here partial code public void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.infmain); listview lstview; lstview = (listview) findviewbyid(r.id.listview1); arrayadapter<string> listadapter = new arrayadapter<string> (this, android.r.layout.simple_spinner_item,list); lstview.setadapter(listadapter); spinner spinner = (spinner) findviewbyid(r.id.planets_spinner); integer[] items = new integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }; arraya...

javascript - Is this possible to detect a colour is a light or dark colour? -

Image
consider these 2 pink square: and this: as may know, 1 lighter , 1 darker or more sharp. problem is, can tell human eyes, possible use system way or programme way detect information? @ least, possible have value tell me colour more white or colour less white? (assume got rgb code of colour.) thanks. since haven't specified particular language/script detect darker/lighter hex, contribute php solution this demo $color_one = "fae7e6"; //state hex without # $color_two = "ee7ab7"; function conversion($hex) { $r = hexdec(substr($hex,0,2)); //converting rgb $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); return $r + $g + $b; //adding rgb values } echo (conversion($color_one) > conversion($color_two)) ? 'color 1 lighter' : 'color 1 darker'; //comparing 2 converted rgb, greater 1 darker as pointed out @some guy , have modified function yielding better/accurate result... (added luminance) ...

asp.net - Error about local variable in Entity Framework -

error message: local variable named 'e' cannot declared in scope because give different meaning 'e', used in 'parent or current' scope denote else. why i'm seeing error? how remove. please help. i'm new. happy see elaborate answer. protected void buttondeleteprofile_click(object sender, eventargs e) { string inputstring; inputstring = textboxinputemployeeid.text; int inputemployeeid; int.tryparse(inputstring, out inputemployeeid); tbl_employee deleteprofile = new tbl_employee(); tbl_employee_education deleteeducation = new tbl_employee_education(); tbl_leaveapplication deleteapplication = new tbl_leaveapplication(); tbl_login deletelogininfo = new tbl_login(); deleteeducation = hrmsdb.tbl_employee.where(e => e.employeeid==inputemployeeid).firstordefault(); } you've got method parameter called e , can't introduce lambda expression parameter cal...

reading consecutive array elements of a structure and printing it immediately until it reaches end of file in c -

i making simple game using c programming our project. information of players (player number such 1 2 or 3, name of player, , score) stored in text file through structures. want "load" information of previous players before game starts current player knows his/her player number getting player numbes file , printing out. using while(!feof(fp)) i'm getting trouble because prints first player number. please me. while(!feof(fp)) { fp = fopen("scores.txt","a+"); fscanf(fp, "%i \n", &p[load].nth); printf ("loading player no. %i...\n", p[load].nth); fscanf(fp, "%s \n", p[load].name); fscanf(fp, "%i \n", &p[load].score); load++; } count=load; p[count].nth=count; printf("you player no. %i", p[count].nth); your code has few errors. you can't use feof(fp) before opening file , assigning value fp . that's undefined behavior. you shouldn't use "a+" mode when open...

javascript - Toggle from Left to Right issue -

Image
i trying have navigate toggle list left right side .if click button,the list should come native android app in css ,but list should slide left right. $(".logo").click(function() { $(".sidebar_list").toggle('slide'); }); fiddle example image: you can use jquery mobile's slider panel. check link: http://demos.jquerymobile.com/1.3.0-beta.1/docs/panels/

asp.net mvc - use linq in operator -

i want in operator in mvc linq. like sql (stud_id int, primary key , auto increment): select * student stud_id in (1,4,6,10,5); how can adapt linq sql? like list<int> nl = new list<int>(); nl.add(1); nl.add(4); nl.add(6); nl.add(10); nl.add(5); list<student> students = db.student.where(a => a.stud_id.in(nl)).tolist(); //this code fitting mind :d or other scenario list<student> st = db.studentorderby(x => guid.newguid()).take(5); //only create auto list student type list<student> students = db.student.where( => a.stud_id.in(st.select(b => b.stud_id).tolist()) ).tolist(); //again fitting i can this list<student> students = new list<student>(); foreach(var item in nl) { students.add(db.student.where(a => a.stud_id == item).first()); } but dont want use or foreach or do-while or while :d try this: list<student> students = db.student.where(a => nl.contains(a.stud_id)).tolist(); thi...

php - Need some undertanding of multi level cache scenario -

i aware of how use cache mysql(using views , few other technology), php(using smarty), web pages(writing web pages once limited time , loading them whenever required). now have come across term called multi-level cache think not aware of it. it great if can give me head start on it. i not asking give complete details @ all. few bullet points enough. i have researched on google , did not find article. any appreciated. here small info on multi-level caching a multilevel cache spreads cached data contents across several servers across network. the top level caching server holds commonly accessed pages, , lowest-level caching server holds least commonly accessed pages. the various levels combine in network of cache servers called web caching mesh. the caches communicate among themselves, using http , special cache-coordination protocols, divide contents appropriately , maintain consistency among servers more info can referred here , here , here , here ...

ruby on rails - Rabl Api and preventing code duplication -

i working on simple api rails project should able versioning. using rabl-rails gem. to prevent code duplication, wanna able use controlleractions (ex. usercontroller#search) twice. 1 time normal webusers, , 1 api. i saw people writing controllers this: class api::v1::userscontroller def list @user = user.all end end do have namespace controllers rabl? or possible "route or delegate" json requests existing controllers? for example regular userscontroller action "list" has this: def list respond_to |format| format.html format.json { render @user } end end views/users/list.json.rabl exist , works in case. now try move rabl files into /api/v1/users/list.json.rabl i provide route: namespace :api, :defaults => {:format => :json} namespace :v1 match 'users/list', to: 'users#list', as: 'users', via: [:get, :post] end end at moment not provide api::v1::userscontroller. what best approa...

Android Titanium Twitter Integration -

suggest working examples android titanium twitter integration. i tried sample birdhouse , social java script file didn't required output. i want post text through titanium android app twitter. may know correct way achieve objective? in advance use social_plus.js works both android , ios https://github.com/aaronksaunders/test_social thanks

android - Multiple consecutive adapter notifyDataSetChanged calls do not refresh ListView -

this very serious buggy behavior , have no idea why not work. my adapter (extending baseadapter ) combines 2 independent types of data. 1 cursor, other takes list of elements. setters both take data , force notifydatasetchanged() : public void setinformationscursor(final cursor newcursor) { log.d(tag, "setinformationscursor called"); if (newcursor == informationscursor) { return; } informationscursor = newcursor; // work on cursor here extract data notifydatasetchanged(); } public void setrides(final list<ride> newridelist) { log.d(tag, "setrides called"); ridelist = newridelist; notifydatasetchanged(); } the data these elements gathered using 2 independent asynctaskloader using loader framework. more specificly, these setters called corresponding loadercallbacks.onloadfinished methods. when user chooses display different data, both loaders fired in fragment : getloadermanager().restartloader(ride...

python - self argument not defined when calling method? -

hi developing system making use of phidget sensors , having issues trying write variables database. have read around fair amount on classes , calling variables cannot code run. my code below, can see have put 'self' argument when database method called complaining 'self' not defined. if don't have self in there complaint 'database() missing 1 required positional argument: 'self'' connection = sqlite3.connect('testing.db') cursor = connection.cursor() class sensors(): def interfacekitattached(self, e): attached = e.device print("interfacekit %i attached!" % (attached.getserialnum())) def sensorinputs(self, e): temperature = (interfacekit.getsensorvalue(0)*0.2222 - 61.111) self.sound = (16.801 * math.log((interfacekit.getsensorvalue(1))+ 9.872)) light = (interfacekit.getsensorvalue(2)) print("temperature is: %i " % temperature) print("...

sql - how to stop the Plsql procedure block -

i wants stop plsql procedure if exception happens on calling sub procedure. for below example , i wants stop entire process if first_sub_proc gives exception. had used "return" statement here. there no use. always,if thing happens on first_sub_proc, execute exception block of first_sub_procdure. hence after, go main function , start processing second_sub_proc. any suggestion ? create or replace package body testing_pk procedure first_sub_proc begin dbms_output.put_line('entering first sub'); execute immediate 'truncate table not_present'; exception when others dbms_output.put_line('first sub procedure exception '); -- *****need stop entire process here **** end; procedure second_proc begin dbms_output.put_line('entering second sub'); execute immediate 'truncate table not_present'; exception when others dbms_output.put_line('second sub procedure exception '); end; pro...

python - Initializing a variable with a nested dictionary literal -

i unsorted plain list of subsubobjects database (coachdb) , want sort objects in object tree using dictionaries. my object tree looks this: object.subobject.subsubobject each object type has id unique within object level. idea ids document , insert object in object tree: oid = doc.getid("object") soid = doc.getid("subobject") ssoid = doc.getid("subsubobject") objtree[oid][soid][ssoid] = doc would work? if yes, how should initialize objtree variable using such nested indexing? i've tried objtree = {{{}}} but didn't work. you can use collections.defaultdict : >>> collections import defaultdict >>> objtree = defaultdict(lambda: defaultdict(dict)) >>> objtree[1][2][3] = 1 >>> objtree defaultdict(<function <lambda> @ 0x99a0ed4>, {1: defaultdict(<type 'dict'>, {2: {3: 1}})}) >>> objtree[1][2][3] 1

java - Hibernate batch insert a list into a table which has unique column -

i hava list contains 1,000,000 records. i want insert list table have 5,000,000 records. the code: sample s = null; for(int i=0,len=list.size();i<list;i++){ s = new sample(); session.save(s); if(i%20==0){ session.flush(); session.clear(); } } a column in table unique column. some records in list same records in table. like this: list : ['a','b','c']... table : ['a','d','e']... 'a' duplicate, code can't word well. exception: don't flush session after exception occurs it's sloooooooooooow use this: string sql = 'insert ignore xxxxx'; session.createsqlquery().executeupdate(); how should do? me, please~~~

jquery - Resizing popup window with resizeTo is working when I type directly on console but not in the JavaScript code -

i google , tried many things still don't understand why resizeto isn't working in case. found resizeto working when popup created window.open , respected rule. , problem, have popup window created window.open in page named a.aspx. var mywin = window.open(myurl, '', "width=400,height=250"); then tried resize popup using resizeto in page named b.aspx. <body bgcolor="white" ms_positioning="gridlayout" onload="javascript:resizepopup();"> .... </body> <script type="text/javascript" language="javascript"> function resizepopup() { var targetwidth = document.body.scrollwidth + 80; var targetheight = document.body.scrollheight + 80; window.resizeto(targetwidth, targetheight); } </script> this not working @ all. tried resize popup typing directly on console resizeto(1000,1000); but resizes popup. tried same thing make sure on master window page , ...

PHP task queue creation sample (google app engine) -

i cannot seem figure out how can create task task queue, tried failed , task not show in queue. any suggestions or php sample? edit: source code comment. $task = new pushtask( '/workers/worker1.php', ['var1' => 'this one', 'var2' => $seconds], ['delay_seconds' => $seconds] ); $queue = new pushqueue('notify'); $queue->addtasks([$task]); try following using push queues in php in separate project. if you've been having problems there may unwanted interaction rest of software. also, if simple example fails can add source code question here discussion. edit: adding source code. leads 2 suggestions. first, pushtask documentation packs optional parameters single array. pushtask call passes 2 arrays, might not work properly. therefore combine parameters single array. second, queue.yaml file requested amy u. still absent, lacking entry looks - name: notify . show file too?

javascript - applying jquery code to more than one class -

i have little snippet of code applied 1 class function replacesf(foo,bar) { j$('.labelcol').children().each(function(){ console.log('i on children each labelcol'); console.log('foo: '+foo); console.log('bar: '+bar); console.log('jsthis.text: '+j$(this).text()); if(j$(this).text() == foo) { j$(this).html(''+bar); } else if(j$(this).text().trim().replace('\*','').replace('\n','') == foo) { j$(this).html(j$(this).html().replace(foo,''+bar)); } }); j$('.labelcol').each(function(){ if(j$(this).text() == foo ) { j$(this).html(''+bar); } }); } but need use code 10 classes. what's best approach this? trying rewrite function replacesf(classname,foo,bar) didn't results. thanks. you can modify selector like: j$('.labelcol, .labelcol2, .labelcol3, .l...

java - How to return the generic type of an object inside generic class? -

i'd write generic service should work object of specific type. when write custom implementation of service, i'd object variable. therefore wanted override method creates object. but won't work. impossible in java achieve following? class myservice<t extends foo> { //type mismatch: cannot convert foo t public t createobject() { return new foo(); } public void run() { t t = createobject(); //work object } } class bar extends foo; class customservice<bar> { @override public bar createobject() { return new bar(); } } class newarraylist extends arraylist { } abstract class myservice<t> { public abstract t createobject(); public void run() { t t = createobject(); //work object } } class customservice extends myservice<newarraylist> { @override public newarraylist createobject() { return new newarraylist(); } }

Draw Line on Firebreath Plugin -

i want draw line on firebreath plugin. while searching have came acrossed link fb::rect used display text. tried fb::line not available. should use d2d1 firebreath? please let me know same. you have not sufficiently read code understand going on. fb::rect structure containing dimentions. drawing in firebreath using appropriate platform apis draw. on windows means gdi. learn draw line using gdi , you'll able draw firebreath on windows.

arrays - how to load a stack of images on matlab -

i have 170 png images in folder. want load , store them in matrix/array/cell array, can access , modify them i'm stuck @ beginning. how can it? best structure? assuming same size, in folder containing images: list=dir('*.png'); % read .pngs in folder image1=imread(list(1).name); % read first image calculate dimentions of stack imsize=size(image1) imagestack=zeros(imsize(1),imsize(2),length(list)); % preallocate stack zeros ii=1:length(list) image=imread(list(ii).name imagestack(:,:,ii)=rgb2gray(image); % copy image in each step of third dimsion of stack end if need color information add dimension imagestack , forget rgb2gray() . hope helps!

How to perform sorting based on Comparator keeping original sort intact in Java -

i've been going through implementation examples of comparable vs comparator interface. but, i've been stuck @ 1 point in it's implementation : suppose, i've simple class : employee has default sorting mechanism based on employee name. public class employee implements comparable<employee> { private int empsalary; private string empname; @override public int compareto(employee e) { return this.empname.compareto(e.empname); } } but, let's say, i've sort based on employee name first, , if 2 employess have same name, i've sort them according salary. so, wrote custom comparator sort based on salary below public class salarycomparator implements comparator<employee> { @override public int compare(employee e1, employee e2) { return e1.empsalary - e2.empsalary; } } but, when ran test class sort based on name first, salary second, output not expected. collections.sort(employeelist, ...

javascript - Replace text on page on form submit -

i have form let people submit news articles site (a company intranet). form submission takes few seconds resolve due actions have in place on relevant model save method. wanted replace text on form page message saying "sending article. may take few seconds, please not refresh page." hits submit. i've seen these on number of websites when buying things online. my first attempt @ doing add onclick event form button. submitting replaced text did not submit form. had @ this answer on binding 2 events 1 submit button doesn't seem address need looks php-specific. i'm javascript right tool job can't think of how other binding clicking submit button. know correct way this? javascript indeed right way so. if using jquery can go ahead , use like: $('form#your-form-id').submit(function(){ $(this).hide().after('loading, please wait...'); }); where #your-form-id id of form. function hiding form content , showing text, instead actua...

Pivot like number manipulation in R -

Image
i trying nest 2 subset data inside aggregate. returns different length of data , hence unable compute. options have? newfile<- aggregate(cbind(subset(iva,iva$ivr.agent =="agent"),subset(iva,iva$ivr.agent=="ivr")) ~ iva$orderno, fun = length, rm.action = true) below error got error in data.frame(..., check.names = false) : arguments imply differing number of rows: 25039, 4585 i trying make pivot table show agent count , ivr count in separate columns in excel, if specific order there no ivr shows null otherwise count. dataset looks this orderno ivr/agent a1 ivr b1 agent a2 agent b2 ivr a3 agent b3 agent a4 agent b4 agent a5 ivr b5 agent so, wanna check out reshape2 package , cast function. check out code below: # install.packages('reshape2') # run if haven't downloaded before library(reshape2) datcast <- dcast(dat, orderno ~ ivr.agent, fun.aggregate = length, margi...

Adding PHP code in extension after every nth list element in TYPO3 -

i'm using old fashion way (kickstarter) build extension in typo3. ad php code after third element of list, don't know how this. my code looks that: protected function makelist($res) { $items = array(); // make list table rows while (($this->internal['currentrow'] = $globals['typo3_db']->sql_fetch_assoc($res)) !== false) { $items[] = $this->makelistitem(); } $out = '<div' . $this->pi_classparam('listrow') . '>list items</div>'; return $out; } and: protected function makelistitem() { $out = 'list item details'; return $out; } if understood correctly, need this: protected function makelist($res) { $items = array(); // make list table rows $i = 0; $out = '<div' . $this->pi_classparam('listrow') . '>'; while (($this->internal['currentrow'] = $globals['typo3_db']->sql_fetc...

mysql - Trying to get property of non-object/ Php codeigniter -

i can't seem figure wrong code. thank yu help. getting error messages: a php error encountered severity: notice message: trying property of non-object filename: views/members.php line number: 24 my model: public function show_user() { $this->db->select(''); $this->db->from('users'); $this->db->where('email',$this->input->post('email')); $q=$this->db->get(''); if($q->num_rows() > 0 ) { $data = array(); foreach($q->result() $row) { $data=$row; } return $data; } } my controller: public function members() { if ($this->session->userdata('is_logged_in')) { $this->load->model('model_users'); $data['member'] = $this->model_users->show_user(); $this->load->view('members', $data); } else { redirect('mai...

group by - sql Left Join, max value -

hi every one, i found similar subjects can't want. i have got 3 tables: message(rows: mid, content, sentdate) received (rows: rid, membre, fk_re_message_id (foreign key: message.id)) group(rows: gid, microid,fk_gr_message_id (foreign key: message.id)) i last message of each group member id based on googling, last request have tried: select * message msg left join received rcd on msg.mid=rcd.fk_re_message_id left join group grp on msg.mid=grp.fk_gr_message_id inner join (select mid, max( sentdate) lastdate message group mid) message on msg.mid=message.mid (rcd .membre)* this returning message in groups chosen membre. please me? you need fix last join condition: select * message msg left join received rcd on msg.mid=rcd.fk_re_message_id left join "group" grp on msg.mid=grp.fk_gr_message_id inner join (select mid, max( sentdate) lastdate message group mid ) message on msg.mid = message.mi...

objective c - How to fix warning 'no explicit ownership' -

i have method takes indirect pointer argument , then, if error, set error object. i'm trying turn on many warning possible. 1 of them - implicit ownership types on out parameters - generates warning in method: - (id)dowitherror:(nserror **)error { ... } how can fix code remove warning? you can fix warning declaring method as - (id)dowitherror:(nserror * __autoreleasing *)error { // ... } the __autoreleasing ownership qualifier implicitly assumed "out-parameters" (see "4.4.2 indirect parameters" in clang/arc documentation ), therefore adding explicitly not change code.

date - How do I get current time in the format "2011-11-03 11:18:04" in javascript? -

i have javascript return current time in format looks "2011-11-03 11:18:04" . i tried var xx = date() returned format not want. looks tue mar 15 2013 06:45:40 gmt-0500 how can format time "2011-11-03 11:18:04" ? thank much. using date functions- //mm-dd-yyyy hh:mm:ss format function formatdatetime(d){ function addzeros(n){ return n < 10 ? '0' + n : '' + n; } return addzeros(d.getfullyear()+1)+"-"+ addzeros(d.getmonth()) + "-" + d.getdate() + " " + addzeros(d.gethours()) + ":" + addzeros(d.getminutes()) + ":" + addzeros(d.getminutes()); } with momentjs - var = moment().format("yyyy-mm-dd hh:mm:ss"); jsfiddle

passing multiple strings to get path but no results in PowerShell -

i have following codes: filter multiselect-string( [string[]]$patterns ) { # check current item against patterns. foreach($pattern in $patterns) { # if 1 of patterns not match, skip item. $matched = @($_ | select-string -pattern $pattern) if(-not $matched) { return } } # if patterns matched, pass item through. $_ } get-childitem -recurse | multiselect-string 'v1','produit','quota'| select -unique path when execute code should give me path + name of file (directory/filename) however gives me no results, when executed same without |select -unique path it gives me results useless me. how directory path , file name. idea ? path not properties fileinfo object . use directory or fullname instead: get-childitem -recurse | multiselect-string 'v1','produit','quota'| select -unique directory # path or fullname path\filenamt.ext

centos6 - how to install wkhtmltopdf 0.12.0 on centos 6 -

how can wkhtmltoimage 0.12.0 installed on centos amd64? thank you! build source. need debian/ubuntu system this. (get free amazon ec2 or something). once download git repo, run command: sudo python scripts/build.py setup-schroot-centos6 and then: python scripts/build.py centos6-amd64 if you're not on debian-based system, you'll "this can run on debian/ubuntu distribution, aborting." otherwise, install big list of rpms etc emulate centos environment, , second command build.

ember.js - Ember without using rest url -

i have strange requirement. 1) backend server talks in terms of custom json. need marshall , unmarshall json in ember rest adapter. not going use ember convert json object , vice versa. 2) our end jax-rs. allowed give single url @ class level. @path \customer allowed. custom framework not allow \customer\create or \customer\1 or of sort. 3) having big debate whether ember can in scenario not able make full use of ember. 4) thinking of doing define requesttype (create, update, query etc.) , send reuesttype element in json structure. 5) possible @ restadapter or controller level. if yes, 1 better place. you would't able use ember data out-of-the-box. not converting json objects pretty render ember (or other client side framework) useless. i'm struggling understand intention using framework ember . i'm working project uses ember without ember data @ moment (because of api limitations). need our own get/create/update/delete handling, pretty easy using ember....

python - wxpython FileDialog open crashes program in windows xp -

i'm trying put simple filedialog application. here's simple example: frame has 1 button , 1 statictext. after button clicking open file dialog appears. when user choose file - it's path , name loaded statictext label: frame1.py: #boa:frame:frame1 import wx def create(parent): return frame1(parent) [wxid_frame1, wxid_frame1button1, wxid_frame1statictext1, ] = [wx.newid() _init_ctrls in range(3)] class frame1(wx.frame): def _init_ctrls(self, prnt): # generated method, don't edit wx.frame.__init__(self, id=wxid_frame1, name='', parent=prnt, pos=wx.point(383, 279), size=wx.size(441, 126), style=wx.default_frame_style, title='frame1') self.setclientsize(wx.size(441, 126)) self.button1 = wx.button(id=wxid_frame1button1, label=u'load', name='button1', parent=self, pos=wx.point(48, 72), size=wx.size(328, 32), style=0) self.button1.bind(wx.evt_button, self.onbutton1b...

gnu make - how to work with list of variables in makefile? -

i have list of variables: var_list= var1 var2 var3 var4 var5 and script ( var_process.py )in recipe uses variable 1 of option. how create recurring instance sequentially process var_process.py using var_list . i have makefile setup this, cant figure out how can setup var_list sequential. target1: $(foreach var, $(var_list), $(var)_process_var.txt) %_process_var.txt:var_process.py %_var.txt python $< -i $(word 2, $^) -var var_list -o $@ doesn't work use $* ? write this: %_process_var.txt: var_process.py %_var.txt python $< -i $(word 2, $^) -var $* -o $@

loops - Handling month in switch case PHP -

i want current month , add next 3 months , show in table header. the code have is: $mon = (date('m')); switch($mon) { case 'mar' : echo '<th>mar</th>'; echo '<th>apr</th>'; echo '<th>may</th>'; break; case 'apr' : echo '<th>apr</th>'; echo '<th>may</th>'; echo '<th>jun</th>'; break; } ............... , on .............. the above switch case job twelve months. there way dynamically single switch case twelve months rather having 12 switch cases? running mad? thanks, kimz you calculate next months on own: $now = time(); $currentmonth = date('n', $now); $year = date('y', $now); $nextmonth = $currentmonth + 1; $secondnextmonth = $currentmonth + 2; echo '<th>' . date('m', $now) . '</t...

typoscript - in TYPO3 6.1 and tx_news, how to enforce language of displayed posts -

i have following ts based on manual display tx_news list / latest view via typoscript. temp.latestnews = user temp.latestnews { userfunc = tx_extbase_core_bootstrap->run extensionname = news pluginname = pi1 switchablecontrolleractions { news { 1 = list } } settings { limit = 5 detailpid = 123 overrideflexformsettingsifempty := addtolist(detailpid) startingpoint = 456 } } in contrary when using plugin, translations displayed. there should posts current language. can't find setting enforce that. or wrong?

How to force Git to abort a checkout if working directory is not clean (i.e. disregarding the check for conflicts)? -

when git checkout some_branch , , working directory not clean, git check if checkout result in conflicts, , if abort with: $ git checkout some_branch error: local changes following files overwritten checkout: some_file please, commit changes or stash them before can switch branches. aborting however, if checkout not result in conflicts, git switch new branch , carry on uncommitted changes (and listing them, polite git is). $ git checkout some_branch m some_file m some_other_file switched branch 'some_branch' so far ... now, not git users uses cmd line. if use ide (like e.g. eclipse) , checkout of some_branch dirty working directory not result in conflicts, not nicely notified changes working on in previous_branch still present in working directory after changing some_branch . i.e. when compile code uncommitted changes previous_branch still present in working directory on some_branch . question #1: is possible force git abort checkout i...

php - preg_replace make matched hex value appear as text -

how use preg_replace convert matching hex values text representation of hex? $string = 'abcd'.hex2bin(23).'abc'.hex2bin(24); for example str_replace('/[\x20-\x25]/', 'what here?', $string) output like: abcd[hex:23]abc[hex:24] what want do: i'm looking hidden characters, , want display hex values. you need preg_replace_callback() have callback called against matches. try: $string = 'abcd'.hex2bin(23).'abc'.hex2bin(24); $text = preg_replace_callback('/[\\x20-\\x25]/', function($matches) { $string = bin2hex($matches[0]); return "[hex:{$string}]"; }, $string);

android - Java complex object to JSON with GSON -

i need make list of (sub)lists of objects (some mybook ) , save android internal storage. , each sublist has name. mybook: public class mybook implements parcelable{ string name; list<string> authors; string publisher; bitmap preview; string description; list<string> isbn; list<string> isbntype; //string isbn; string imglink=""; string googlelink =""; string publisheddate; listofmybook (sublists): public class listofmybook extends arraylist<mybook>{ public string listname; @override public string tostring() { // todo auto-generated method stub return listname; } } my current code serialization , deserialization: public static final string my_list_file = "mylist.json"; public static void exporttoxml(context context, list<listofmybook> listlistbook){ gson gson = new gson(); string json = gson.tojson(listlistbook); log.d("gson",json); fileoutputstream ou...

c++ - Tic-Tac-Toe Program -

i'm trying create tic-tac-toe program determine if given playing board won "x" "o" or tie. obviously know games won who, how can program check that? int check(int board[3][3]) { //i've tried putting code here, nothing successful. return 0; } int main() { // three-dimensional array, 3 games of two-dimensional // boards; concern two-dimensional boards int games[3][3][3] = { { { -1, 0, 1 }, //o_x { 0, 1, -1 }, //_xo { 1, -1, 0 } //xox }, { { 0, 1, 1 }, //_xx { -1, -1, -1 }, //ooo { 1, 1, 0 } //xx_ }, { { 1, 1, -1 }, //xxo { -1, -1, 1 }, //oox { 1, 1, -1 } //xxo } }; (int game = 0; game < 3; game++) { if (check(games[game]) == 1) { cout << "player x wins game " << game + 1 << endl; } else if (check(games[game]) == -1) { cout << "player o wins game " ...

breeze: unexpected error in getEntityGraph -

i use getentitygraph extension , works fine except in following scenario: add new entity don't save , call setdeleted on entity call getentitygraph passing entity , np collection parameters when makepathsegmentfn called, crashes on line : grps.foreach(function(grp) { vals = vals.concat(grp._entities.filter(function (en) { return en.getproperty(fkname) === keyvalue; })); }); en null raises exception. i've worked around problem checking if en null , every seems work fine. perhaps should done in original code if it's bug ? note 1 entity null amongst entities in np collection. guess that's 1 deleted, can't tell sure. update 29 april 2014 ok ... now. you're talking deleted child entity, not detached root entity. thanks identifying bug. added test scenario doccode, fixed bug. both changes pushed github. appear in next official release. can get current getentitygraph.js github right now. original answer i...

c# - How to handle similar routes when one has integer parameter and other has string? -

i building set of mvc pages pertaining managing users, , have following routes defined in routeconfig.cs : routes.maproute(name: "users", url: "users", defaults: new { controller = "users", action = "index" }); routes.maproute(name: "user details", url: "users/{id}", defaults: new { controller = "users", action = "edit", id = urlparameter.optional }); routes.maproute(name: "user creation", url: "users/create", defaults: new { controller = "users", action = "create" }); the problem i'm facing when navigate /users/create , following error gets thrown: the parameters dictionary contains null entry parameter 'id' of non-nullable type 'system.int64' method 'system.web.mvc.actionresult edit(int64)' in 'myui.controllers.userscontroller'. optional parameter must reference type, nullable type, or declared optional par...

Android: Google Analytics availability in Google Play Services? -

google analytics has been announced become part of rolling out google play services 4.3, not yet included in google play services packages list: http://developer.android.com/reference/gms-packages.html any idea when become available, , safe used straight away, or better wait time make sure every user has google play services 4.3 installed? i've noticed other differences. tracker to new tracker , use newtracker() method (accepts both string value , int value [for xml configuration]): googletracker = gainstance.gettracker(ga_key); // old googletracker = gainstance.newtracker(ga_key); // new easytracker easytracker has disappeared, have use googleanalytics.getinstance(this).reportactivitystart(this) reported paito . setters the googletracker.set() method no longer available. has been replaced more specialised methods, example: googletracker.set(fields.screen_name, null); // old googletracker.setscreenname(null); // new event creation ...

android google maps draw circle with fixed radius in pixels for each zoom level -

sorry english in google maps v2 current location's indicator (small blue point) has same radius in pixels each zoom level. how can draw on map different color (gradient) ? i.e. fixed radius. maybe make own image , create marker ? http://developer.android.com/reference/com/google/android/gms/maps/model/marker.html

filter - Cannot get AngularDart filtering working -

i trying apply angular dart tutorial (recipe book app) real project of mine. working fine, except basic filtering on name. code identical tutorial: <div id="filters"> <div> <label for="name-filter">filter clients name</label> <input id="name-filter" type="text" ng-model="ctrl.namefilterstring"> </div> <input type="button" value="clear filters" ng-click="ctrl.clearfilters()"> <ul class="list-group"> <li class="list-group-item" ng-repeat="client in ctrl.clients | filter:{en_name:ctrl.namefilterstring}" ng-click="ctrl.selectclient(client)"> {{ client.en_name }} ({{ client.acronym }}) </li> but list not displayed @ all. if remove | filter:{en_name:ctrl.namefilterstring} , list of clients displayed. orderby: 'en_name' works fine too. string defined in controller,...

antlr - Antlr4 Can I listen to my own visitor? -

i understand antlr generates tree walker , can sub-class baselistener act when tree walker traverses on key items in parse tree. i understand can create own visitor, sub-class basevisitor navigate parse tree in own way. can have listener responds own visitor? think made boo-boo , placed application code unnecessarily in sub-classed visitor. believe visitor should visit , listener should trigger events in application code. think got little bit muddled in implementation. sure. can create whatever listener interface want , create visitor fires events listener. it's pretty inefficient however. dump visitor , have standard tree walker fire events @ listener :)

beagleboneblack - I am trying to use i2c on the beagle bone black with c++ but I keep getting 0x00 returned -

hi trying read , write data i2c bus on beagle bone black. keep reading 0x00 whenever try access register on mma84152 (or other register matter), constant register means value not change. trying read i2c-1 character driver located in /dev , connect sda , scl of mma852 lines pins 19 , 20 on p9 header. sda , scl lines both pulled high 10 k resistors. both pin 19 , pin 20 show 00000073 pin mux means set i2c functionality , slew control slow, reciever active, pin using pull resistor, , pull enabled. ran i2cdetect -r 1 , device shows 0x1d correct address. ran i2cdump 1 0x1d , 0x2a shows under 0x0d register trying read device , contains correct value according datasheet. when read it returns 0x00 me. running latest angstrom distribution , logged in under root no need sudo.i'm lost now. here code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <linux/i2c-dev.h> #include <linux/i2c.h> #include <sys/ioctl.h> #include <sys/typ...

php - error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[],[] ... at line 1 -

i tried fix code don't know whats wrong code? specific error message is: you have error in sql syntax; check manual corresponds mysql server version right syntax use near '[$message],[$key],[$encrypt_message],[$encrypt_hex])' @ line 1 blockquote and code <?php $password ="abcd"; $iv = '0000000000000000'; $mode =mcrypt_mode_cbc; $cipher = mcrypt_rijndael_128; $message = $_post['message']; $key = $_post['key']; $encrypt_message = mcrypt_encrypt( "$cipher", "$key", "$message", "$mode", "$iv"); $encrypt_hex = bin2hex($encrypt_message); // protect mysql injection (more detail mysql injection) $message = stripslashes($message); $key = stripslashes($key); $message = mysql_real_escape_string($message); $key = mysql_real_escape_string($key); $encrypt_message = stripslashes($encrypt_message); $encrypt_message = mysql_real_escape_string($encrypt_message); $encrypt_hex = stripsla...

spring - Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: sessionFactory -

i getting following error org.springframework.beans.factory.beancreationexception: error creating bean name 'roledaoimpl': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private org.hibernate.sessionfactory com.quad.dao.roledaoimpl.sessionfactory; nested exception java.lang.noclassdeffounderror: lorg/hibernate/cache/cacheprovider; my sessionfactory configuration in mvc-dispatcher-servlet.xml is <bean id="sessionfactory class="org.springframework.orm.hibernate3.annotation.annotationsessionfactorybean"><property name="datasource" ref="datasource" /> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.hbm2ddl.auto...

keyword - What is the use case for "pass" in Python? -

this question has answer here: how use pass statement in python 12 answers based on answers this question , pass keyword in python absolutely nothing. indicates "nothing done here." given this, don't understand use of it. example, i'm looking @ following block of code while trying debug script else wrote: def dccount(server): ssh_cmd='ssh user@subserver.st%s' % (server) cmd='%s "%s"' % (ssh_cmd, sub_cmd) output=popen (cmd, shell=true, stdout=pipe) result=output.wait() queryresult="" if result == 0: queryresult = output.communicate()[0].strip() else: pass takedata(server, "dc", queryresult) is there purpose @ having else: pass here? in way change way function runs? seems if / else block rewritten following absolutely no change: if result == 0:...

c++ - Is it possible to use std::make_unique in Xcode 5.1? -

Image
since xcode 5.1 includes clang 3.4, should possible use std::make_unique . seems defined in memory.h . however, needs have _libcpp_std_ver > 11 still set 11 because of value of __cplusplus macro (still 201103l ). is there way change this? as specified in clang website , need enable -std=c++1y . xcode not include option choice in "c++ language version" option, need manually enter it. this, need go "editor" menu while project definition open , press "show definitions". should able manually change "c++ language dialect" option c++1y :

php - insert into table implode array -

i've got var implode result form...(i think called) , need insert on table other "fixed values"... like : $dx = $_post['cid']; $vat = implode("', '", $dx); also have var1= $_session['loginuser']; var2= $_session['formuser']; and need insert in table : var1+var2+vat each value in vat variable i think i'm going need create var $dx imploding coma i'm not shure if i'm correct... , i'm lacking code can give me hand? ok need correct syntaxe code insert values table.. something like: for each value in $vat insert table_name (var1, var2, vat )....

java - Could not find main class:program will exist (Exception in main() thread NoClassDefFoundError) -

import java.security.*; import java.math.*; public class md5 { public static void main(string args[]) throws exception{ string s="anand"; messagedigest m=messagedigest.getinstance("md5"); m.update(s.getbytes(),0,s.length()); system.out.println("md5: "+new biginteger(1,m.digest()).tostring(16)); } } in code fine plus working before wen i'm running above code mentioned exception occurs... adding installed jdk few seconds ago.. done path java_home.. still exception.. help...!!!!! java_home= c:\program files\java\jdk1.6.0_45\ java installed.. path= c:\program files\java\jdk1.6.0_45\bin; classpath= %catalina_home%\lib\servlet-api.jar;c:\program files\java\jdk1.6.0_45\bin; compiling command: javac md5.java running command: java md5 you need tell java can find classes (or rather, roots of package trees). sinc eyour class in default package, , located in directory run java command, need ja...

c# - The operand '+' can't be applied to operands of type string and method group -

i have problem in query code string reqsql = " update client set codclt = " + myclient._codclt + ",nomclt = '" + myclient._nomclt + "', prenclt =' " + myclient._prenclt + " ' ,adressclt =' " + myclient._adressclt + " ',numcin= " + myclient._numcin + " ,datdelivcin = '" + myclient._datdelivcin + "' , datnaiss = '" + myclient._datnaiss + "',lieunaiss = '" + myclient._lieunaiss + "',myclient.etatciv = '" + myclient._etatciv + "',myclient.profclt = '" + myclient._profclt + "',myclient.numtelclt = '" + myclient.numtelclt + "' (codclt=" + myclient._codclt + ")"; i error the operand '+' can't applied operands of type string , method group myclient object. you forgot write () after method name. if had gu...

javascript - Function to retrieve items from a lists on SP -

i'm trying extract data sharepoint list create graphs , i'm in need of function extract items list can insert in parameters such name of list, , column names want extract. instantiate function: extractdata (listname, columntitle1, columntitle2)to extract different lists instantiating function. function retrievelistitems() { var clientcontext = new sp.clientcontext(siteurl); var list1 = clientcontext.get_web().get_lists().getbytitle("list_name"); var camlquery = new sp.camlquery(); camlquery.set_viewxml('<view><query><where><geq><fieldref name=\'id\'/>' + '<value type=\'number\'>1</value></geq></where></query><rowlimit>200</rowlimit></view>'); this.colllistitem = list1.getitems(camlquery); clientcontext.load(colllistitem); clientcontext.executequeryasync(function.createdelegate(this, this.onquerysucceeded), function.createdelegate(this, this.onque...

javascript - set cookie on local host -

i have done quite researches on topic, answers got cookie not work on localhost since cookie expects domain contain @ least 2 dots. question is, since asp.net websecurity class able set authentication cookie server side, , javascript able set cookie on client side when using localhost domain. there must way it, know how done server side. update: trying java server. cookie tokencookie = new cookie("token", token); /* work if include line , use 127.0.0.1 access page usernamecookie.setdomain("127.0.0.1"); */ tokencookie.setpath("/"); response.addcookie(tokencookie); return response.ok().build(); i have no idea why there 2 people trying close question duplicate. please read people, said know reason why cookie not being set, know , want know how!!!

Passing XHTML mimeType to Android WebView -

i need load local xhtml file .html extension correct mimetype "application/xhtml+xml" in android webview control. being webview has load javascript interface have call webview.loaddata("","text/html",null) first, , call webview.loadurl(localurlstring) i have pass right mimetype because of wrong behaviour of js functions when self-closing tags encountered but webview.loaddata("", "application/xhtml+xml", null); just causes webview display error message: "this xml file not appear have style associated it. document tree shown below". how can achieve goal?

javascript - Adding option values to a select box by comma spaced values -

how can code below modified, such able add single , comma separated values select box? example 1: orange [select box] orange example2: red,blue,green,yellow [select box] red blue green yellow here html <!doctype html> <html> <head> <script type="text/javascript"> function add() { var select = document.getelementbyid('list') var option = document.getelementbyid('reference').value select.options[select.options.length] = new option(option, option) } </script> </head> <body> <input type="button" value="add" onclick="add()"> <input type="text" id="reference"> <br><br> <select style="width: 200px;" id="list"><option> </body> </html> simply split value comma, , loop through each of strings, appending option go: function add() { var select = document.getelementbyid(...

javascript - Trying to attach JQuery on another page attached through data attribute -

i have slider attaches slides through external page attached through data attributes. here what's happening:- main page <div id="sitewrapper"> <section class="sliderwrapper"> <div id="slider" data-source="slides-page.html" data-speed="500" data-easing="swing"> <ul> </ul> </div> <div id="loader"><span id="load"></span></div> <a class="button" id="back"></a> <a class="button" id="next"></a> </section> <!--end sitewrapper--> </div> <script> $(function() { //run when dom ready $('.internalclick').click(function(e) { alert("i clicked area tag" + $(this).attr('data-direct')); }); }); </script> slides page (slides-page.html...