Posts

Showing posts from June, 2011

python - Split array into evenly-distributed chunks -

i'm looking efficient way split array chunks have similar histogram. for example, given array: l = np.array([1, 2, 3, 4, 1, 1, 1, 2, 3, 4, 55, 5, 5, 5, 5, 5, 3, 2, 2, 21, 2]) i obtain: c1 = np.array([1, 4, 1, 5, 5, 3, 2]) c2 = np.array([2, 1, 3, 4, 5, 5, 2]) c3 = np.array([3, 1, 2, 55, 5, 2, 21]) not each chunk should have similar size , similar sum on given function f: 1. |sum(ci, f) - sum(cj, f)| < e, != j 2. |len(ci) - len(cj)| < e, != j where sum(c, f) = f(c[0]) + ... + f(c[len(c)]) edit: clarify intention of this. want parallelize process on list n sub-processes cost has distributed among each sub-process evenly. cost of processing element in list function f of integer @ same position in array l , f computational complexity of process. example, f(i)=i^2 . so, want processes have same computational cost , not have processes finish while others last forever. let's start weak assumption similar histograms defined in following rudimenta...

android - Error: hide list View child Item -

i have listview childitems.when press listview child item's got imageview when press on want remove expandable listview item.please find below code snipped used. code snippet used hide list item expandablelistview remov = (expandablelistview) v.findviewbyid(r.id.lvexp); remov.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub removimg.setonclicklistener(new onclicklistener() { @suppresslint("newapi") @override public void onclick(view v) { // todo auto-generated method stub toast.maketext(v.getcontext(), "hello", toast.length_short).show(); addcadschildadoptor.remove(1); addcadschildadoptor.notify(); } }); return false; } }); return v; } i used expandable list adopter snippet @suppresslint("newapi") private void preparelistdata() { listdataheader = new arraylist<s...

mysql - How to calculate age from date of birth and group each member into age range in sql -

i have sql table stores people's details i.e id, name, dob, registration_date , address. calculate age of each individual , group them these ranges: 20-30, 31-50, 51 & over. i know can age doing: ( https://stackoverflow.com/a/1572257/3045800 ) select floor((cast (getdate() integer) - cast(date_of_birth integer)) / 365.25) age i need figure out how group people thier respective range. thanks help use case produce age group description: select *, case when datediff(now(), date_of_birth) / 365.25 > 50 '51 & over' when datediff(now(), date_of_birth) / 365.25 > 30 '31 - 50' when datediff(now(), date_of_birth) / 365.25 > 19 '20 - 30' else 'under 20' end age_group person note simpler way calculate age.

android - Getting value of scanning at Motorola TC55 -

i want scan barcode in app. start scan not know how detect scanned value. code looks like public class myfragment extends fragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { return inflater.inflate(r.layout.pick, container, false); } @override public void onviewcreated(view view, bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); // scan this.getactivity().findviewbyid(r.id.scan).setonclicklistener(new onclicklistener() { @override public void onclick(view view) { // start scanner in example: https://developer.motorolasolutions.com/docs/doc-1874#programming%20interface intent intent = new intent(); intent.setaction("com.motorolasolutions.emdk.datawedge.api.action_softscantrigger"); intent.putextra("com.motorolasolutions.emdk.d...

javascript - Angular JS with Twitter Bootstrap JS -

i expecting architectural perspectives people decide whether can go angular + bootstrap model or not. can please share experience me? 1. pros using angularjs + bootstrap: 2. cons using angularjs + bootstrap: 3. other comments/remarks/findings: as of principle of separation of concerns, styling app (css) independant of structure. you can use whatever css framework want : foundation, twitter bootstrap, knacks, blueprint, etc... or no framework @ all and can use angular, backbone, emberjs or whatever js framework want. but frameworks have angular modules create interface. it's case of : twitter bootstrap , angular module : http://angular-ui.github.io/bootstrap/ foundation , angular module : http://madmimi.github.io/angular-foundation/ ionic framework optimized angularjs : http://ionicframework.com/ hope helps

jquery - Find font-family of the html element on which mouse is currently pointing? -

i want find out font family of html element on mouse hovering. please not suggest chrome/ff plugin this, want create 1 myself :p here have been trying: http://jsfiddle.net/c2duz/ html : <div id="a">hasdashd kjsa sdkjsahd kjahdkjsahd kjahdkjahd kja hdkja hdkjahdskjahdkja</div> <div id="b">hasdashd kjsa sdkjsahd kjahdkjsahd kjahdkjahd kja hdkja hdkjahdskjahdkja</div> <div id="c">hasdashd kjsa sdkjsahd kjahdkjsahd kjahdkjahd kja hdkja hdkjahdskjahdkja</div> <div id="message"></div> css: #a {font-family: arial;} #b {font-family: tahoma;} #c {font-family: georgia;} jquery $('*').hover(function() { hoverelem = var font = hoverelem.css("font-family"); $("#message").append(font); }); please advice. change js thus: hoverelem = $(this); in order ensure referencing jquery object , have access css method

javascript - Pay access to HTML file -

i have site tool on it. tool html form clients save local pdf after filing out. form works. paypal can integrated payment. all of code run on client side via javascript. not want store data or credentials on server. what don't understand how protect particular html file until has paid it. hoping maybe randomized string file name lasts 48 hours or something. not sure search @ point. the site backend node.js , using foundation css if helps. thanks in advance. if use unique/random filename mentioned, , have expire after x amount of time, obfuscate, not protect/secure. obfuscation more enough needs, not should providing official stackoverflow answer... continue. it sounds have 1 of those, excuse wording here, "cheap self-help/how-to/etc pdf sale should free , somewhere" type of websites. sure product fantastic , of utmost quality, if know sites i'm referring to, , assumptions correct, information below should helpful. as far understand needs...

visual c++ - What do these common C++ compiler flags do? -

i'm starter in c++. i'm still confused flags in makefile. -c. -o. -wall. -g. -std=c++0x. can 1 tell me these common flags do? only last flag (compiler command option) compiler-specific. first 3 or 4 have been de facto standard since, well, or mid 1980s, think. of course there’s no guarantee particular compiler understand them, they’re not uncommon. note: while visual c++ accepts - flag prefix notation, used / flag prefix, since that’s common convention in windows. -c compile only, don't link. -o specifies output file, e.g. executable. unfortunately deprecated visual c++ compiler. visual c++ use e.g. /fe . -wall g++ practical warnings. visual c++ warnings including sillywarnings, , that's bunch! -g generate debug information. supported many compilers not visual c++. then, -std=c++0x g++ compiler-specific option specifies sort of c++11 standard. recall difference -std=c++11 , newer compiler versions accept both, former still permit...

android - Java Thread Signalling does not return execution to loop -

i have class instantiated in tread , started. code goes this: private class startcycle implements runnable { @override public void run() { ... while(pomodoroleft > 0) { ... synchronized(runnable){ try{ runnable.wait(); } catch(interruptedexception e){} } runtime = shortlength * one_minute; //these statements not getting runnable = new clock(); //executed runnable.run(); } } } the clock class instance name runnable follows: private class clock implements runnable { public void run() { ... synchronized (this) { runnable.notifyall(); } //here goes alarm. } } } for reason execution of first thread not return path , statements after. did mess notification? or there other reason that? if yo...

android - how to assign edit text value in spinner select value for specific item inspinner -

i make spinner in impliment when select specific item spinner edit text visible other wise invisible.here fine there problem want when user choose specific item value of edit text store in variable otherwise sppiner item value store means if user select "oth-other" edit text value store in spinnerselectedid otherwise move in else. elese part work nice in if part not store edit text value in spinnerselectedid varible. arraylist<string> faulttypespinner = new arraylist<string>(); faulttypespinner.add("xl-cross level"); faulttypespinner.add("al-alignment"); faulttypespinner.add("un-unevenness"); faulttypespinner.add("xl-cross level"); faulttypespinner.add("al-alignment"); faulttypespinner.add("un-unevenness"); faulttypespinner.add("bd-ballast deficiency"); faulttypespinner.add("se-super elevation on curve...

android - db.trasaction doesnt wait for callback. Intel Xdk -

i working on creating mobile app web sql database. trying return array 1 function below getcheckeditems:function(type,itemid){ var optarr=[]; var sql ="select optionid opt mytable familymemberid=" + this.memberid+ " , questionid="+itemid mydb.runquery(sql, function(optionrecords) { if(optionrecords.length>0) { if(type==2) { var optionid=optionrecords[0].opt; optarr.push(optionid); alert(optarr); // alert(optionid+"hello"); } else { for(var i=0;i<optionrecords.length;i++) { optarr.push(optionrecords[...

Setting up Macvim for python development on OSX -

sorry know there wealth of resources on topic, particularly there post here , here . now complete beginner when comes installing source , intricacies of setting environment variables, path , whatnot. feel goal rather simple: i want set python development environment in terminal image showed in second link i.e from terminal should able call mvim (or vim whatever works best python dev.) , stay within terminal (i'm not sure if there reason staying within terminal guess means less mouse clicking needed) there should file drawer (i heard "alloy" 1 preferred on "nerdtree") available the text editor should good, transparent background , color scheme in second link again. i read stuff "janus" being beginners myself, nice have. that pretty it. give idea of ideal answer: need spoon-fed on one; give idea have no idea or "path" or ".profile" or ".bashrc" love if explain little bit reason need run commands in installa...

node.js - Appropriate structure for storing images with metadata/other information? -

say wanted create web app save , display images , retrieve information them - description, title, year etc. my first assumption store of data in file structure, e.g. img\year\title.jpg but how store things such description? info take form of text file or there more efficient way of going things?

jquery - Dynamic javascript function -

this question has answer here: javascript window resize event 11 answers i have javascript function want execute if browser screen bigger 1024px. if ($(window).width() > 1024) { the problem code if user first load webpage in browser screen 800px , rescale browser screen 1024 (or more) function not executed. in order executed screen needs refreshed. do have suggestion how fix it? jquery resize $(document).ready(function() { if ($(window).width() > 1024) { my_awesome_window_above1024_function(); } }); $(window).resize(function() { if ($(window).width() > 1024) { my_awesome_window_above1024_function(); } });

asp.net - How to pass the end of the URL to a Value=“” -

i want pass value url , value session... m using following syntax... <a href="registration.aspx?userid=<%convert.toint32(session["userid"]); %>">link</a> so solution??? you don't need onvert.toint32 the url doesn't mind type is.eventually - it's string. try : <a href='registration.aspx?userid=<%=session["userid"].tostring() %>'>link</a> safer way : <a href='registration.aspx?userid=<%=session["userid"]+"" %>'>link</a>

keyboard - application to fake keybord strike (for slides' scroll) with python? -

i computer science student , working, electronic engineer on gloves recognize hand's motions (vertical, horizontal ones). to present project, thought making little application control power point slides. concept simple: when move 1 hand left, slides passes next one, , when move right, goes previous one. to that, thought simulating keyboard right , left arrows (that's use change slides). the question is: possible that? or think there better idea? thank reading i found script wanted. it based on linux command line generates fake inputs xte (use sudo apt-get install xte in debian based distribution download it. i'm using system call in python job. in example, generating 2 right arrow strikes each 2 seconds. can test positioning cursor in text document, launch script, , watch cursor move. from subprocess import popen, pipe import time def keypress(sequence): p = popen(['xte'], stdin=pipe) p.communicate(input=sequence) time.slee...

html - Floated list lowered below container when viewport resized in Chrome -

i'm experimenting responsive design , media queries create containers cater different viewport sizes. navigation bar consists of logo div , floated list container. the issue i'm having when viewport less 640px , resize more 640px, floated list disappears - refreshing fixes though. i'm still trying head around media queries , how use them site... suggestions appreciated! jsfiddle html <div class="navigation"> <div class="container"> <div class="logo"> <img src="http://www.placehold.it/100x54"/> </div> <ul> <li><a>services</a></li> <li><a>work</a></li> <li><a>contact</a></li> </ul><!-- --></div> </div> <div class="container"> lorem ipsum dolor sit amet, consectetur adipisicing elit, sed ei...

Excel Formula "if F1>20% then G1=C" -

what formula in exel2007 below mentioned question: if cell f1>20% cell g1 automatically give value alphabet c what put in cell g1 : if(f1>20%,"c","") note not stackoverflow question , moved elsewhere

ios - Updating UIButton State in TableViewCell Changes other Rows -

my table view contains uibutton inside each row , depending if user has redeemed change it's image , whether disabled or enabled. when user purchases item (say item 0 first row @ times) want notify app should switch image , disable button @ specific row. i'm using nsuserdefaults alert tableview. in other words if user clicks on item 0 asked if redeem or cancel, if user presses redeem, following: [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"itemzeroredeemed"]; [storetableview reloaddata]; in cellforrowatindexpath do: if([[nsuserdefaults standarduserdefaults] boolforkey:@"itemzeroredeemed"]) { if(indexpath.row == 0) { [cell.productinfobutton setbackgroundimage:[uiimage imagenamed:@"itemunlocked"] forstate:uicontrolstatenormal]; cell.productinfobutton.enabled = no; } } it works in updates tableview , row correctly, when coming later. issue farther down list item 5 being updated new button state. h...

r - How to transfer variable value from one dataframe to another dataframe by two conditions? -

i have 2 data follows. want transfer value of change in first dataframe second dataframe date , code. > date code change 1 2013-12-27 000586 0.990099012851715 2 2013-12-26 000616 9.97067451477051 3 2013-12-25 300295 10.0013799667358 4 2013-12-23 000968 -8.1564245223999 5 2013-12-19 600023 60.5786628723145 6 2013-12-18 600855 -7.69696950912476 > b code date company 1 000586 2013-12-27 2 000616 2013-12-26 b 3 300295 2013-12-25 c 4 000968 2013-12-23 d 5 600023 2013-12-19 6 600023 2013-12-19 b 7 600855 2013-12-18 c the final result should like: > c code date company change 1 000586 2013-12-27 0.990099012851715 2 000616 2013-12-26 b 9.97067451477051 3 300295 2013-12-25 c 10.0013799667358 4 000968 2013-12-23 d -8.1564245223999 5 600023 2013-12-19 60.5786628723145 6 600023 2013-12-19 b 60.5786628723145 7 00...

objective c - sql returning values in a list -

i have sql database in xcode project, can read data no problem @ all. database has 15,000 rows 1 of columns has handful of different entries. what want list of different options in list. currently i'm reading entire database , if nsmuatablearray* doesn't contain feedback adding it. is there anyway can create sql syntax, different values returned. seems current way seems waste of resources. thanks i'm using hermanns example: if table has name example , field values "level x" has name useroptions. if want list of distinct values of column useroptions can use keyword distinct : select distinct useroptions example;

matplotlib - How to close a python figure by keyboard input? -

i'm trying write python program displays figure indefinite time , closes after keyboard key pressed. in fact, python program should same matlab code: t = 0:0.01:2; s = sin(2 * pi * t); plot(t,s) pause close in python i'm able plot figure nothing happens after keyboard input. import numpy np import matplotlib.pyplot plt t = np.arange(0.0, 2.0, 0.01) s = np.sin(2*np.pi*t) #plt.ion() fig = plt.figure() plt.plot(t,s) #plt.show() plt.draw() raw_input("press key continue.") plt.close(fig) so far observed plt.close(fig) not in conjunction plt.show() . however, when use plt.draw() instead, plt.close(fig) closing figure. yet, when add raw_input("press key continue.") program, figure not appear @ all. what doing wrong? i tried experimenting plt.ion() , without success. something maybe ? import numpy np import matplotlib.pyplot plt t = np.arange(0.0, 2.0, 0.01) s = np.sin(2*np.pi*t) fig = plt.figure() plt.plot(t,s) #plt.show() ...

Trouble with HyperV. How to lauch both a virtual machine using Vmware and debug a windows phone application with Visual Studio 2013 -

i have trouble hyperv. here problem. i developing application windows phone requests web server. in case web server debian vmware virtual machine. , because of hyperv cannot launch both vmware , windows phone emulator on computer. don't have windows phone device. nobody has solution problem on internet. is there solution problem ? thank you

crash - C++ Program crashes while reading from file using fstream fin -

final project programming class due tomorrow, appreciated, program crashes in module, after accepting file name. crash mean outputs "this application has requested runtime terminate in unusual way" , usual windows "cotd.exe has stopped working" : void load(vector<fish>& stock) { char c; { cout << "welcome catch of day, enter (f) choose file load from, otherwise enter else load default file.\n"; cin >> c; if (c == 'f' || c == 'f') { cout << "enter file name\n"; cin >> file; } ifstream fin(file.c_str()); if (fin.fail()) { cout << "could not open " << file << " check directory location of cotd.exe , try again\n"; } else { while (!fin.eof()) { fish f; string blank; ...

How to insert Integer value in DB - PHP -

i have using php inserting integer value in database. iam using this $postcode = $_post['postcode']; $mysql_user_resultset = mysqli_query($con, "insert user (postcode) values ($postcode)"); i have several field in db. name, username, etc. defined varchar, postcode defined int. if not enter value postcode, doesn't insert database you cast variable int: $postcode = (int) $_post['postcode']; $mysql_user_resultset = mysqli_query($con, "insert user (postcode) values ($postcode)"); note you're not using precautions regarding sql injections, suggest bind parameters before query them, using pdo class .

loops - Create a program with php that will find the missing number in the series of numbers -

i need question, need write code in php find missing number in sequence, regardless of numbers position in sequence. the numbers increase same amount each time. the output must number missing initial list, not list number in (i have worked out myself). example number sequence, $sequence = 3, 5, 9, 11, 13 number 7 missing, don't know how code, im assuming use loops, wouldn't know start, must in php a more simple way missing number(s) sequence, way see it: <?php $sequence = array(3, 5, 9, 11, 13); $numbers = array(7, 9, 15); $single_nr = 7; function getmissingnumber(array $sequence, $single_nr = null, $numbers = array()) { // check if exists in sequence array // check single number if($single_nr) { if(!in_array($single_nr, $sequence)) { echo $single_nr . " not in array" . "<br />"; } } // check array of number...

.profile not getting executed on chef client -

i have following recipe on chef-server: # insert environment variables in .profile execute "set-env-path" command "echo 'export java_home=/home/node/jdk1.6.0_45' >> /home/node/.profile && echo 'export path=$path:$java_home/bin' >> /home/node/.profile" end # execute .profile execute "execute .profie" command ". $home/.profile" end when running recipe on client, environment variables gets inserted .profile not getting set. node@node-virtual-machine:~$ sudo chef-client [2014-04-07t14:59:57+05:30] info: forking chef instance converge... starting chef client, version 11.10.4 [2014-04-07t14:59:57+05:30] info: *** chef 11.10.4 *** [2014-04-07t14:59:57+05:30] info: chef-client pid: 24177 [2014-04-07t14:59:57+05:30] info: run list [recipe[remote_file]] [2014-04-07t14:59:57+05:30] info: run list expands [remote_file] [2014-04-07t14:59:57+05:30] info: starting chef run node-virtual-machine [2014-04-07t14:...

javafx 2 - How can I make error dialog always stay on top -

i developing javafx 2.2 application background threads may trigger error dialog show until close button pressed. if other background threads trigger message dialogs not urgent error, these dialogs must not placed on top of error dialog. in other words, want error dialog blocks else, , never hidden other popups, or main window. i have tried setting modality application_modal error dialog, , window_modal other, lesser dialogs, lesser dialogs still appear above error dialog if triggered while error dialog showing. i not in position can use java 8 , dialogsfx , controlfx , other libraries out of question. in swing, used use layers log, popup_layer , alert_layer , error_layer , can't find similar in javafx . regards, fredrik if using additional stage show dialogs can use method stage.showandwait(); which blocks event till close stage again. hope helps.

c# - How to keep observing the dictionary? -

i have dictionary : public dictionary<string, string> fields { { } set { } } how can fire event keep listening dictionary? , changed in event event handler should called. possible without making dictionary observable? private int _age; public event system.eventhandler agechanged; protected virtual void onagechanged() { if (agechanged != null) agechanged(this,eventargs.empty); } public int age { { return _age; } set { _age=value; onagechanged(); } } i don't want above implementation. you'll need custom class. wrap dictionary in class , create event track when dictionary changes. need override existing add / remove etc , when called, have them raise event. here's question may help. .net observabledictionary

c# - how to use timer in foreach loop -

in company i'm working want build automation tool should run script written in text. i'm new timers, , want make foreach (not must) run line after line in script , call parser later use. want this: atimer = new system.timers.timer(10000); // hook elapsed event timer. // set interval 2 seconds (2000 milliseconds). atimer.interval = 2000; atimer.enabled = true; foreach (scriptcell cell in scriptlist) { //fire method when time atimer.elapsed += new elapsedeventhandler(doscriptcommand(cell.celltext)); } i know wrote doesnt make allot of sense , i'm bit clueless here ps. looking in other topics before posting q , didnt find nothing seems fill gap the introduction of await makes acting on each item in sequence, while waiting period of time between each item, easy: foreach(var cell in scriptlist) { doscriptcommand(cell.celltext) await task.delay(timespan.fr...

Uploading Files To Web Server Without Using FTP - VB.NET -

application stores data in database , want able create remote backup. however, client's network blocks ftp. know there must way upload files server without ftp dropbox application works fine on system, i'm unsure method is. i've tried google haven't had success. out there can me. in advance, craig you can use php script on server move file , in vb.net upload it my.computer.network.uploadfile("local path","remote location") then php side <?php if (!empty($_files["file"])){ move_uploaded_file($_files["file"]["tmp_name"],"images‌​/" . $_files["file"]["name"]); ?>

limit - Outputting the top 10% in SAS -

how can limit number of observations output in sas top 10%? know obs= function, haven't been able figure out how make obs= lead percentage. thanks in advance! as far know there's not direct way you're asking. pretty write macro this, though. assuming you're asking view first 10% of records in proc print, this. %macro top10pct(lib=work,dataset=); proc sql noprint; select max(ceil(0.1*nlobs)) :_nobs dictionary.tables upcase(libname)=upcase("&lib.") , upcase(memname)=upcase("&dataset."); quit; proc print data=&lib..&dataset.(obs=&_nobs.); run; %mend top10pct; dictionary.tables has of proc contents information available it, including number of logical observations (nlobs). number not 100% guaranteed accurate if you've been doing things dataset deleting observations in sql, sas datasets accurate, or close enough. rdbms tables may undefined or may not accurate.

Java Instant Messenger - Connecting multiple clients to server and oneanother -

i have written simple client/server instant messaging program, has basic functionality. as stands, can send/receive messages between server , 1 connected client. however, subsequent clients not connect server. i wish implement features allow following: successful connection of 2+ clients server; multiple clients connecting server , communicating each other , server. i think need setup new thread each connection, i'm unsure how go this. please advise (see code below). any appreciated. many thanks. client.java: import java.io.*; import java.net.*; import java.awt.*; import java.awt.event.*; import java.util.date; //timestamp functionality import javax.swing.*; public class client extends jframe { //inherits jframe //1. creating instance variables private jtextfield usertext; //where user inputs text private jtextarea chatwindow; //where messages displayed private string fulltimestamp = new java.text.simpledateformat("dd/mm/yyyy hh:mm:s...

powershell - Check for file creation in a loop -

can run script 1 time automate when .exe show on folder? get-childitem -filter *.exe | foreach { &$_.fullname /s i want script check if .exe file shows on folder, run commands, else check again .exe file. you can use filesystemwatcher listen these events. get-eventsubscriber -sourceidentifier execreated -erroraction silentlycontinue | unregister-event; $watcher = new-object -typename system.io.filesystemwatcher; $watcher.filter = '*.exe'; $watcher.path = 'c:\test'; $action = { write-host -object ('new file created: {0}' -f $event.sourceargs[1].name); }; register-objectevent -inputobject $watcher -eventname created -action $action -sourceidentifier execreated;

php - How to pair items in array -

how pair items in array $array= array(1,2,3,4,5,6,7,8,9); i display array as 12 23 34 45 56 67 78 89 how can achieve this? this code looking for: $array= array(1,2,3,4,5,6,7,8,9); for($i=0;$i<count($array);$i++){ if (isset($array[$i+1])) // mentioned in comments, avoid "php notice: undefined offset: 9" echo $array[$i].$array[$i+1] .'<br>'; }

android - Orientation change increases TextView's text size -

i want save current text size sharedpreferences , , set when screen orientation changed. i use code, when change screen orientation makes textsize bigger... package com.example.zz; import android.app.actionbar; import android.app.activity; import android.content.sharedpreferences; import android.content.sharedpreferences.editor; import android.os.bundle; import android.util.typedvalue; import android.view.menu; import android.view.menuitem; import android.widget.textview; public class mainactivity extends activity { textview text; float size; actionbar actionbar; private final string text_size = "textsize"; final string mypref = "preference"; sharedpreferences settings; editor editor; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); text = (textview) findviewbyid(r.id.textview1); settings = this.ge...

Master is not ready HBase -

i'm using hbase on standalone mode. and got error when acceed localhost:60010 : http error 503 problem accessing /master-status. reason: master not ready how can resolve problem ? check logs. if don't find relevant (i.e. no errors , no shutdwon) may waiting resource (i did notice while waiting hdfs safemode, since you're in standalone mode that's not case).

multithreading - Getting Job id in do subroutine of Thread::Pool in Perl -

i not able job id inside subroutine thread::pool in perl. below code. can please me? use strict; use warnings; use thread::pool; sub printnumbers( $ ) { $num = shift; $id = thread::pool->jobid; print "$id => $num\n"; } $pool = thread::pool->new( { optimize => 'cpu', => \&printnumbers, workers => 2, maxjobs => 4 } ); $pool->job( $_ ) foreach ( 1..100 ); $pool->shutdown; i got answer. instead of $id = thread::pool->jobid; add $id = threads->tid(); and working correctly..

php - How to Delete MSSQL Table Rows if they are Older than One Year/One Day -

i trying create php query delete sql table rows if order_date column on year old. second query table rows deleted if same column day old. to go more in depth, order_date column in current table, tracking_orders , , created using part of query: order_date datetime not null default getdate(), . tracking_orders table looks this: order_date tracking_order account_id apr 7 2014 3:49pm 1 1 apr 7 2014 3:51pm 2 1 the day asking question april 8th 2014, trying make query delete rows if order_date data apr 7 2013, , query delete rows if order_date data apr 7 2014. also, if data more 1 year old, still delete. example, apr 7 2012. for code example, looking this: $sql = 'delete * tracking_orders order_date == date_sub(getdate(), interval 1 year)'; and this, delete after 1 day: $sql = 'delete * tracking_orders order_date == date_sub(getdate(), interval 1 day)'; note: above doesn't work because date_sub mysql syntax, , working mssql. thank hel...

ruby on rails 4 - JQuery doesn't work unless I refresh -

i'm trying fadein circle in rails 4 app , works when refresh page. jquery far $(document).ready(function() { $(".circle-div").hide().fadein(2000); }) i tried using doing $(document).ready(function() { location.reload($(".circle-div").hide().fadein(2000)); }) and reloads pages non stop. appreciated. give whirl: $(document).ready(function() { $(".circle-div").hide().delay(500).fadein(2000); });

c++ - What are std::initializer_list constructors used for, except for filling some container with values? -

one main , obvious meaning, found in standard library - "initializing collection list of elements": std::vector<int> v = {1, 2, 3}; another meaning can found behind link on std::bitset below - "the single value assembled elements of initializer_list". the third example in standard library std::piecewise_constant_distribution, hesitate semantic has, not collection of elements. what other use cases std::initializer_list constructors? if possible, examples real code. it's question class design. because of pecularities of list-initialization adding std::initializer_list constructor existing class can easily surprisingly breaking change , when writing new class should know in advance if ever need std::initializer_list constructor. so, i'm trying simulate ability see future writing out use cases std::initializer_list constructors. the primary question is: how determine class have (not surprising users) std::initializer_list constructors in...

asp.net - Page.Load runs every time and takes too long -

i have asp.net page this: protected sub page_load(sender object, e system.eventargs) handles me.load 'page load code here. call service layer, calls business layer. end sub protected sub button1_click(sender object, e system.eventargs) handles button1.click 'button code here end sub the code in page_load takes long because has connect lots of different databases (code contained in business layer). best way cache page code in page_load not run before click event? code in page_load required generates controls. button1_click loops through these controls. i tend focus on business layer , data layer. realize basic question. page_load run before click event. need familiarize asp.net page lifecycle model , how postbacks work. most of code runs in page_load shouldn't run again on postback, use if statement check if it's postback. loading of controls etc update viewstate , wont necessary reinitialize on postback.

asp.net mvc - Searching with paging in telerik mvc grid -

actually related telerik mvc extension grid.in telerik grid have search text box.i write in text box , press enter,fire java script function,from function call...ajaxrequest function of grid rebind grid search.that simple process. ok.suppose in last page in grid.then write in search textbox , press enter,the search ok.but paging not in correct position.i need go first page in situation...keypresss enter event bellow function listsearch(keycode, gridobj) { window.currentlist = gridobj; var id = '#' + $(gridobj).attr('id'); var searchtxt = $(id + " .watermark-list-search").val(); var searchlist = $(id + " .watermark-list-search").attr('listtype'); var filterid = $(id + " .watermark-list-search").attr('filterid'); window.currentlist.data("tgrid").ajaxrequest({ name: searchtxt, data: searchlist, id: filterid }); } i modified code include page in ajaxrequest like window.currentlist....

c++ - Draw rects specific color OpenCV -

Image
i using following code find of blobs in image: quad.convertto(quad, cv_8uc1); findcontours( quad, contours, hierarchy, cv_retr_tree, cv_chain_approx_simple, cv::point(0, 0) ); vector<vector<cv::point> > contours_poly( contours.size() ); vector<cv::rect> boundrect( contours.size() ); for( int = 0; < contours.size(); i++ ) { approxpolydp( mat(contours[i]), contours_poly[i], 3, true ); boundrect[i] = boundingrect( mat(contours_poly[i]) ); } mat drawing = mat::zeros( quad.size(), cv_8uc3 ); for( int = 0; i< contours.size(); i++ ) { scalar color = scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) ); drawcontours( drawing, contours_poly, i, color, 1, 8, vector<vec4i>(), 0, cv::point() ); rectangle( drawing, boundrect[i].tl(), boundrect[i].br(), color, 2, 8, 0 ); } i getting result , seems working great, how can draw of bounding boxes in bright green? white , yellow , 1 green. way can make of them green? blobs of erode...

javascript - script does not work on multiple forms jsp -

i using script validate form function validate() { if(trim(search.parola.value)==="") { alert("va rugam introduceti o parola"); search.parola.focus(); return false; } if(search.parola.value === search.utilizator.value) { alert("parola trebuie sa fie diferita de utilizator"); search.parola.focus(); return false; } if(search.parola.value.length < 7) { alert("parola trebuie sa contina minim 7 caractere"); search.parola.focus(); return false; } re = /[0-9]/; if(!re.test(search.parola.value)) { alert("parola trebuie sa contina cel putin un numar"); search.parola.focus(); return false; } re = /[a-z]/; if(!re.test(search.parola.value)) { alert("parola trebuie sa contina cel putin o litera mica"); search.parola.focus(); return false; } re = /[a-z]/; if(!re.test(search.parola.value)) { alert("parola trebuie s...

JAVA : How to make SSL connection with public certificate and private key -

i hoping if regarding issue have been facing today: i trying authenticate client server of 1 of our clients, able issuing following command: curl -v -k -h "content-type:application/json" --key privkey.pem --cert pub.cer --data @search.json https://.... as can tell command above have following: public certificate private key keystore now, trying same thing in java, have no clue how done. guides have read tell me should use keystore have. hit roadblocks when following guides. i or point me direction, appreciate it. thanks in advance, peter it sounds need use https url connection connect server requires client authentication. you'll need 2 things there are. first, you'll need create java style keystore private key , public certificate. detailed instructions can found in answers question: importing existing x509 certificate , private key in java keystore use in ssl you'll need import server's certificate keystore. second, ...

objective c - How to close first window programmatically in Cocoa Mac? -

i want click button on first window open second window , close 1st window @ same time similar one. button handler in appdelegate class , doesn't have [self close] how close window programmatically in cocoa mac? how close 1st window? should create xib 1st window , load appdelegate? if app delegate doesn't have iboutlet ivar or property first window add 1 , use reference close first window. create new window (ether programaticly or using makekeyandorderfront method on iboutlet ivar or property second window (which shouldn't have it's "visible @ launch" behavior set)). // close front window… nsarray *orderedwindows = [nsapp orderedwindows]; nswindow *frontwindow = orderedwindows[0]; [frontwindow close]; // create new window… nsrect windowrect = nsmakerect(0., 0., 640., 480.); nsuinteger stylemask = nstitledwindowmask | nsclosablewindowmask | nsminiaturizablewindowmask | nsresizablewindowmask; nswindow * newwindow = [[nswindow alloc] initwithco...

c++ - Do default constructors need to call base class default constructors? -

was reading this answer , surprised me, suggestion must always call base class constructor in derived class constructor. if working default constructors, consider: class bar : public foo { private: int y; public: bar() : foo(), y(0) { } ... is call foo() necessary here? you not need explicitly call base class constructor in constructor, in case compiler implicitly calls default constructor, or compile-time error, if none callable. same applies members non-pod. an alternative member initialiser list only consisting of delegation constructor of class, creating delegating constructor.

angularjs - How to dynamically change input value -

i'm trying show editable results users, show them through input field. basic example of i'm doing: <div class="form-group"> <label>first number</label> <input type="text" ng-model="first" ng-required="true" class="form-control"> </div> <div class="form-group"> <label>second number</label> <input type="text" ng-model="second" ng-required="true" class="form-control"> </div> <div class="form-group"> <label>the sum is: {{first + second }}</label> <input type="text" ng-model="result" ng-required="true" class="form-control"> </div> in result's div, used label test if result being obtained correctly, , is. if edit first or second values, input's result doesn't update. this controller used (yeah, for...

c - Declaring and accessing 2D array -

how can use array pointer (int *) create , print kind of 2d array: 0 1 2 3 4 5 6 7 8... 1 2 3 4 5 6 7 8 9... 2 3 4 5 6 7 8 9 10... 3 4 5 6 7 8 9 ... 4 5 6 7 8 9... 5... i have code: #include <stdio.h> #include <stdlib.h> void creatematrix(int * matrix, int row, int column) { puts("begin creating matrix."); int i, j; for(i = 0; < row; i++) { for(j = 0; j < column; j++) { *(matrix) = + j; matrix++; } } puts("success!"); } int printmatrix(int * matrix, int row, int column) { puts("begin printing matrix!"); int i, j, valuesprinted; for(i = 0; < row; i++) { for(j = 0; j < column; j++) { printf("%5d ", *(matrix + * j)); valuesprinted++; } puts(""); } puts("printing success!"); return valuesprinted; } int main() { int row = 11; int colu...

css - @font-face on local IP only displaying in chrome -

i want friend able check out wip site i've been developing locally using chrome (localhost/sitename/, or myip/sitename). got work , realized fonts weren't loading, , checked other browsers on computer , noticed same thing. i've done absolute paths , tried adding permissions .htaccess file no avail. below code. suggestions? nothing live yet. @font-face { font-family: 'arvo'; src: url('/arvo-regular-webfont.eot'); src: url('/arvo-regular-webfont.eot?#iefix') format('embedded-opentype'), url('/arvo-regular-webfont.woff') format('woff'), url('/arvo-regular-webfont.ttf') format('truetype'), url('/arvo-regular-webfont.svg#arvo') format('svg'); font-weight: normal; font-style: normal; }

routing - How does the "Random Walk" algorithm work? -

the algorithm below written in pseudocode , simplicity storage of actual route in data structure not included. lengthfromsrc = 0; lengthfromdest = 0; totalnumberhops = 0; x = src; /*last node visited random walk starting @ src;*/ y = dest; /*last node visited random walk starting @ dest;*/ /* randomly select route length */ { length = rand( ) % max; while( length < min ); while( totalnumberhops < length ) { next = toss coin pick random walk src or dest; if( next == randwalkfromsrc ) { z = randomly select adjacent node x; totalnumberhops = 1 + lengthfromsrc + lengthfromdest + shortest-path z y; if( totalnumberhops > length ) break; x = z; /*include node in route*/ store x in route data structure lengthfromsrc++; } else { /* next = randwalkfromdest */ z = randomly select adjacent ...