Posts

Showing posts from March, 2010

PayPal - OAuth2 API Access? -

i have big question: first time create application, okay - thats cool. use client_id , secret key authentication... ok, done - works fine sandbox. but yet have problem set public: how can create application (to become client_id , secret key) production websites? on account have "old data" when go profile > api access. can say, how can use paypal oauth2 without sandbox? doc: https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/ in same application you've created on developer.paypal.com, see both test , live credentials. if reason need verified, show button started verification process, enable live credentials.

css - Multiple selectors in loop in LESS -

i using following code generate column layout using less css: .columnbuilder (@index) when (@index =< @columncount) { .container_@{columncount} .grid_@{index} { width: unit(((@basewidth / @columncount) * @index)-10, px); } .columnbuilder(@index + 1); } which gives me output: .container_24 .grid_1 { width: 69px; } .container_24 .grid_2 { width: 148px; } .container_24 .grid_3 { width: 227px; } etc... how create new less function give output of: .grid_1, .grid_2, ...., .grid_n { display: inline; float: left; margin-left: 5px; margin-right: 5px; } where n defined @columncount: 24; , though column count not set, can changed number. aware create body each grid_x avoid keep clutter down. using :extend() in less 1.4+ this seems accomplish more elegantly. first define initial values want extended in hard coded .grid_1 class (at present, less not extend dynamically generated classes), add extender mixin in loop extend class. so: .

java - Android daily notification shows up multiple times at the wrong time -

i trying android notification show @ noon every day. notification seems show once whenever device started, sporadically afterwards. here service: public class myservice extends service { public static final string tag = "locationloggerservicemanager"; @override public void oncreate() { // todo auto-generated method stub super.oncreate(); log.v(tag, "on oncreate"); } @override public int onstartcommand(intent intent, int flags, int startid) { pendingintent contentintent = pendingintent.getactivity(this, 0, new intent(this, loginactivity.class), 0); notificationcompat.builder mbuilder = new notificationcompat.builder(this) .setsmallicon(r.drawable.ic_launcher) .setcontenttitle("app name") .setcontenttext("notification") .setcontentintent(contentintent) .setdefaults(notification.default_sound) .setautocancel(true); notificationmanag

java - Play Framework ManyToMany Association Access -

i have following 2 models in project: @entity public class reports extends model{ @id @generatedvalue public int id; @manytomany(cascade = cascadetype.all) public list<tags> tags; and @entity public class tags extends model{ @id public string name; @manytomany(cascade = cascadetype.all) public reports reports; since these 2 entities have @manytomany association, play! automatically creates table in postgresql database: create table reports_tags ( reports_id integer not null, tags_name varchar(255) not null, constraint pk_reports_tags primary key (reports_id, tags_name)) ; and here sample data of reports_tags should like: reports_id tags_name 1 pie 1 bar 1 line 3 plot 3 bar 4 scattered 4 plot what i'm having problem want find reports tags_name = 'bar'

android - Titanium listen for silent input event -

i developing application has listen input hardware qr code scanner, , card swiper (both hid devices). want listen input , evaluate input. thinking of textarea input has focus rather not that. there simple way 1 can think of have sort of event listener listening on input. also, there other way of listening on ports in android such /dev/hidraw1...etc? able input fine via in text-area great listen specific device well. the thing pops in head trying write native module implements intent-filters launch broadcastreciever take input , pass app.

nameerror - Why can I not determine my ruby installation's version? -

when run ruby -version get: ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0] -e:1: undefined local variable or method `rsion' main:object (nameerror) what wrong? use either ruby -v or ruby --version. it's parsing -version rsion. either of these 2 work. count number of dashes: ruby -v ruby --version when provide single dash "version", ruby sees this: ruby -v -e rsion

regex - Increase / Decrease Mac Address in Python from String -

i have mac address in string form. interested in taking mac string , increasing / decreasing 1 value while keeping integrity of hex in python ex: 000000001f -1: 000000001e +1: 0000000020 parse it, change it, print it! def change_mac(mac, offset) return "{:012x}".format(int(mac, 16) + offset)

Can a python module read variables from the main program -

i started learning python, , language. have quick question i'm hoping can answer (forgive stupidity, still learning python). how can program module read variables program imported it? if example.py says import mymodule example = raw_input(' example ') how can how can program mymodule read value of example ? does not require programming, and, in mymodule's source can type print (example) or there code have use module can value of variable in program imported it? p.s. brand new python, , first stackoverflow post, please forgive stupidity on no doubt simple question. thanks!! the functions in module should able take in arguments. can pass example variable parameter. e.g in mymodule.py: def foo(x): print(x) in example.py: import mymodule example = raw_input(' example ') mymodule.foo(example)

ruby on rails - Return list based on has_many relationship -

a state can have many units. unit can have 1 state. on home page want return list of states have units. right listed name. so if arizona , colorado ones units...they show on home page. i'm new rails , i've searched , searched. but, i'm missing something. seems sort of query or filter on controller? returning states have units? appreciated. static page controller def home @units = unit.all @states = state.order('long_name') end home view <% @states.each |state| %> <%= link_to state.long_name, state %> <% end %> join should enough: @states = state.joins(:units).order('states.long_name asc') or, can move model scopes: scope :with_units, joins(:units).order('states.long_name asc') and call in controller with: @states = state.with_units

PDO errors not showing when php file accessed by ajax -

i have php file uses pdo access sql. using ajax run php script. like, (on button click ajax function). when run through ajax, pdo errors don't show. however, if run php file without ajax, errors reported fine. example if go directly php url. my question is, how stop php script , display errors, when accessed ajax. die() not work. i don't want echo error through ajax, want entire script die, , echo error. thanks the error page getting returned, being returned javascript, not browser window. most the ajax call not interpreting error because page status 200, i.e, php error page valid html, if isn;t supposed returned. two options. don't ajax call until you've got sorted. if get pretty simple, plug address in browser window , see outputting. if can't/don't want turn off ajax call, in dev tools in browser, can see resources being returned (in chrome network tab example), show output.

python - Scipy special.chdtr error -

i performing iterative process on vector. i have done many many datasets (which images). , have never encountered error. on totally random image following error after many successful iterations: wt = 1-stats.chi2.cdf(chisqr,[bands]) file "c:\python27\lib\site-packages\scipy\stats\distributions.py", line 1347, in cdf place(output,cond,self._cdf(*goodargs)) file "c:\python27\lib\site-packages\scipy\stats\distributions.py", line 2540, in _cdf return special.chdtr(df, x) typeerror: ufunc 'chdtr' not supported input types, , inputs not safely coerced supported types according casting rule ''safe'' [finished in 2640.6s exit code 1] chdtr(v, x) returns area under left hand tail (from 0 x) of chi square probability density function v degrees of freedom. i'm not sure have encountered this? have clue? because runs smoothly many iterations. have idea on provoke error?

Gradle - use folder name within task -

in jsf project i'm using https://github.com/obecker/gradle-lesscss-plugin compile less files css. css files placed in src/main/webapp/resources/default/1_0/css folder. after updating css files version number 1_0 needs increased. possible make script below folder highest number inside src/main/webapp/resources/default , , use in dest variable instead of hard coding version number? lesscss { source = filetree("src/main/scripts/less") { include "foo.less" } dest = "src/main/webapp/resources/default/1_0/css" compress = true } given, need find greatest number, plain old groovy can here: sort directory names, , take last one. def resources = file("src/main/webapp/resources/default") //choosing latest happens here def latest = resources.list().sort().last() //take 'css' dir relative project root dest = file(new file(latest, 'css')).tostring() using gradle's file method, make sure

C++: "expected ;" in declaration in template -

i've been running following problem inside member function of templated class: #include <map> using std::map; template <typename a,typename b> class c { public: b f(const a&,const b&) const; private: map<a,b> d; }; template <typename a,typename b> b c<a,b>::f(const a&a,const b&b) const { map<a,b>::const_iterator x = d.find(a); if(x == d.end()) return b; else return x->second; } when have g++ compile following error: bug.c: in member function 'b c<a,b>::f(const a&, const b&) const': bug.c:12: error:expected ';' before 'x' bug.c:13: error: 'x' not declared in scope however, when make non-templated version of class , function, , b both being int compiles without problem. error little mystifying since can't imagine why wants ';' before 'x'. you're missing typename : typename map<a,b>::const_iterator x =

database - Android: cursor.getCount() -

i'm wondering if there alternative cursor.getcount() way expensive! goal run 1 query first, if cursor null or cursor.getcount() <=0 need run query. but since underlying data can large, getting application not responding getcount() call. better solution it? if cursor empty, movetofirst false

SAS: Replicate PROC MEANS output in PROC TABULATE -

i replicate output of proc means using proc tabulate. reason have profit percentage (or margin) 1 of variables in proc means output, suppress calculation 1 or more of statistics i.e. there '-' or similar in 'margin' row under 'n' , 'sum. here sample data: data have; input username $ betdate : datetime. stake winnings; dateonly = datepart(betdate) ; format betdate datetime.; format dateonly ddmmyy8.; datalines; player1 12nov2008:12:04:01 90 -90 player1 04nov2008:09:03:44 100 40 player2 07nov2008:14:03:33 120 -120 player1 05nov2008:09:00:00 50 15 player1 05nov2008:09:05:00 30 5 player1 05nov2008:09:00:05 20 10 player2 09nov2008:10:05:10 10 -10 player2 15nov2008:15:05:33 35 -35 player1 15nov2008:15:05:33 35 15 player1 15nov2008:15:05:33 35 15 run; data want; set have; retain margin; margin =

JQuery UI Tabs activate event is not firing -

var activetab = $('#tabs ul li[name=<%= this.activetab %>]'); var activetabindex = activetab.length > 0 ? activetab.index() : 0; $("#tabs").tabs({ selected: activetabindex, create: function (e, ui) { alert('create!'); console.log("create!"); }, activate: function (e, ui) { alert('here!'); console.log("test"); } }); the activetab variable meant activate same tab after post (it works). create event firing expected. activate event not, , don't understand why. i'm missing something. i'm using following documentation: http://api.jqueryui.com/tabs/ small skeleton of tabs div. <div id="tabs"> <ul> <li name="admin"><a href="#admin-tab">admin</a></li> </ul> </div> determine version of jquery ui using. since using 1.8, must use show instead. see jquery ui 1.8 docs .

disqus - Display comments count display unnecessary information -

i placed disqus on website, , when trying display comments count, display this: 0 и 0 reactions need 0. didnt founded options in settings page @ disqus account, can me this. have comment count link section, , don't have reaction count link section. question: need make looks this: 0 , not 0 и 0 reactions tnx

servlets - How can I get path of resource under WEB-INF/class folder (java ee web dynamic project) -

i develop web dynamic project in eclipse. 1 file, file named 'users.txt' located under classes folder (web-inf/classes/users.txt). how can relative path of file in class (base class, not servlet class)? use path append several lines of text. christian code works reading. problem don't know how create object writing (output) in same file relative path. public products(){ try{ inputstream in = getclass().getclassloader().getresourceasstream("products.txt"); bufferedreader br = new bufferedreader(new inputstreamreader(in)); readproducts(br); in.close(); br.close(); }catch(exception e){ system.out.println("file doesn't exists"); } } public void readproducts(bufferedreader in) throws numberformatexception, ioexception{ string id=""; string name=""; double price=0; stringtokenizer st; string line;

java - How to print statement outside loop to avoid duplicates? -

i print statement outside loop statement doesn't print same thing on , over. loop below checks number 1 array against find out how many matches have been found. defining variables above , printing statements below results in "variable not initialised error" understandable. for (int = 0; < 6; i++) { int chknum = myarray[i]; int lottmtch = count(chknum, rndnum); if (lottmtch > 0) { system.out.println(lottmtch + "matches found"); system.out.print(chknum); } else { system.out.print("no matches found"); } } this not make sense .. if want try ... int lottmtch[]=new int[myarray.length]; arrays.fill(lottmtch, 0); (int = 0; < 6; i++) { int chknum = myarray[i]; lottmtch[i] = count(chknum, rndnum); } (int = 0; < 6; i++) { if (lottmtch[i] > 0)

svn server - SVN Checkout Errors on "Format 6" -

when try checkout repository svn error: e160043: expected fs format between '1' , '4'; found format '6' i've read has mismatched versions, both svn server , client running version 1.8.1. (edit:) i've been following tutorial: http://jason.pureconcepts.net/2012/10/updating-svn-mac-os-x/ started prebuilt macports version of svn, built own see if fix issue. i serving svnserve. testing server on server, client , server same instance. here exact versions (i believe 1 package): svn --version svn, version 1.8.1 (r1503906) svnadmin --version svnadmin, version 1.8.1 (r1503906) svnadmin --version svnadmin, version 1.8.1 (r1503906) if create repo --compatible-version 1.7 , seems silly since version 1.8+. any appreciated. this may or may not relevant throw out here in case helps. having similar problem using checkout feature ('open version control...') delphi xe5 & xe6. here's how fixed in both. step 1: update

jquery - GET not redirecting the page nodeJS/mongo -

i have post ajax post based on button , form has it's own post. every time button clicked post made not redirect userprofile page tho calling , returning 304 it. here script file: $('.removeemail').click(function() { $.post('/removeemailpost', {usere: $(this).data('user')}); }); here routes file: exports.newemailpost = function(req, res) { if(req.body.emailnew === '') { console.log('blank'); res.redirect('edituserprofile'); } else { user.findbyidandupdate(req.signedcookies.userid,{ $addtoset: {emaillist: req.body.emailnew} }, function(err, userx) { if(err) { console.log(err); } else { res.redirect('userprofile'); } console.log(userx); }); } }; add type="button" attribute <button> , doesn't auto-submit form whe

ruby - Sikuli on Ubuntu : cannot load such file -- sikuli (Load Error) -

sikuli on ubuntu : cannot load such file -- sikuli (load error) error message : /.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require': cannot load such file -- sikuli (loaderror) /home/ashrivas/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:inrequire' ruby version 2.0.0p247 sikuli version 0.3.0 i not see sikuli when gem list also. when install, says installed.

sql - CreateSQLQuery() not executing -

i attempting delete specific row w/ session.createsqlquery("delete [dbo].[usertable] id = '00000000-0000-0000-0000-000000000000' ").executeupdate(); but not seem execute command, ideas? you need use transaction , commit after executeupdate . see nhibernate reference docs or this ayende post example usage. if still no luck after that, try profiler see sql, if any, nhibernate executing. note: it's recommended use transaction w/ nhibernate, if you're reading data.

android - AlphabetIndexer.getSectionForPosition() Always Returns 0 -

i trying make letters appear when fast scrolling on listview. reason, letter appears first letter in alphabet (a space). appears getsectionforposition() returns 0, though should not. below code: activity_host.xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".hostactivity" > <listview android:id="@+id/song_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fastscrollenabled=&q

d - Array of concrete class not covariant with array of interface -

i'm having little problem in providing abstract base layer dataaccess.mysqlclient module have defined bunch of interfaces minimum requirements , bunch of classes implement them. now dmd compiler complains: error: function dataaccess.mysqlclient.mysqlreader.columns of type @property mysqlcolumninfo[]() overrides not covariant dataaccess.dbclient.idbreader.columns of type @property idbcolumninfo[]() exit code 1 the relevant lines of code this: idbreader: interface idbreader { @property idbcolumninfo[] columns(); // ... } mysqlreader: class mysqlreader : idbreader { private mysqlcolumninfo[] _columns; @property public mysqlcolumninfo[] columns() {return _columns;} // ... } there few ways work around compiler issue; declare concrete property of idbcolumninfo[] wrap array in list class and couple more if think bit longer. none of seem quite elegant though. here come big questions: am overlooking simple? can arrays of implementation

jquery - Slide Toggle doesnt works some time -

can 1 tell me why piece of code doesn't work time.. sliding doesn't takes place every time, sometime stays still after clicking... works in 21" pc screen in mini laptop doesn't triggered. i tried putting script document.ready function doesnt work @ all... <div id="aboutus" onclick="showlayer('aboutus-sub');"> <img src="more.png" id="more" title="more here.." style="width:25px;height:25px;"/></div> <div id="aboutus-sub" style="display:none;"> <ul><li><a href="chatroom.php">chat room</a></li> <ul><li><a href="album.php">album</a></li> <ul><li><a href="studentsarea.php">settings</a></li> <ul><li><a href="studentsarea.php">i student</a></li> </ul>

Wordpress get_categories can not find out children directory -

i had wordpress problem troubled me lot. writed php script can insert specific data database of wordpress. actually, deleted initial data of wordpress , used script scan directories initialize tables in database. however, encounterd problem used get_categories() function find out children directories failed. following code: $args = array('parent'=>'1', 'hide_empty'=>0); echo count(get_categories($args)); the fact there directories in category number 1, prints 0. used cat_is_ancestor_of function test: echo cat_is_ancestor_of(1, 2); it prints 1 shows category 2 children of category 1. watched mysql database, category 2 indeed son directory of category 1. why get_categories returns wrong answer? puzzled me lot! me solve it? you can child category of parent category following way <?php $subcategories = get_categories('&child_of=1&hide_empty'); // list subcategories of category '4' (even

java - Decision of control mechanism (Necessity of if condition?) -

suppose have profile page has these values: name, last name, username, follower , following counts. they may updated after user logged application. there refresh button. when user clicks refresh button, calling web service new values. in return, 5 values. here example: suppose have called web service , parsed return values response class. // here first approach. if (!response.name.equals(name)) { name = response.name; } if (!response.lastname.equals(lastname)) { lastname = response.lastname; } // here second. name = response.name; lastname = response.lastname; in first approach, believe if condition required because if values same, won't lose time assign operation. , know if condition fastest operation can computer does. in second approach, believe if condition not required because access both values in if condition ( name , response.name ), instead of losing time accessing them, not consider same or not. make assignment. now, want know faster way?

JQuery datepicker does not respond to click event of after clearing the textbox -

i have tried rahul's code. looks this $("input:text.inputtypedate").datepicker({ dateformat: "dd/mm/yy", changemonth: true, changeyear: true }); }); asp <asp:textbox id="txtdt" runat="server" width="120px" class="inputtypedate"> </asp:textbox> it works fine on page load, when clear textbox, stops working.

c# - BulletedList in Reapeter -

i have 2 tables in database w/c connected tblpackage id name 1 package 2 package b tbldetails id packageid details 1 1 packagedetails11 2 1 packagedetails12 3 1 packagedetails13 4 1 packagedetails14 5 2 packagedetails21 6 2 packagedetails22 7 2 packagedetails23 now want manipulate on repeater html <asp:repeater id="rptrpackage" runat="server"> <itemtemplate> <asp:label id="pack" runat="server" text='<%# bind("pack") %>'></asp:label> <asp:bulletedlist id="details" runat="server"> </asp:bulletedlist> </itemtemplate> </asp:repeater> asp private void populate() { datatable dtpackage = tblpackage(); datatable dtdetails = tbldetails(); rptrpackage.datasource = dtpackage; rptrpackage.databind(); } try this aspx <asp:repeater id=&q

snort was alive, but now she's dead. no clue. :( -

i got snort , running other , since attempt barnyard2 working, snort no longer sniffing. fires error free, port monitoring still blasting traffic @ her, no errors in logs. custom google access rule fails fire off in buffer. went seeing seeing nothing overnight , didn't compiled barnyard2 mysql support last worked??? new server, new install. #-------------------------------------------------- # vrt rule packages snort.conf # # more information visit at: # http://www.snort.org snort website # http://vrt-blog.snort.org/ sourcefire vrt blog # # mailing list contact: snort-sigs@lists.sourceforge.net # false positive reports: fp@sourcefire.com # snort bugs: bugs@snort.org # # compatible snort versions: # versions : 2.9.5.3 # # snort build options: # options : --enable-gre --enable-mpls --enable-targetbased --enable-ppm --enable-perfprofiling --enable-zlib --enable-active-response --enable-normalize

How do I display a word diagonally in Java? -

i trying make program accepts word displays word diagonally. far i've gotten display vertically. the scanner accepts "zip", outputs: z p how make go this: z p here code: import java.util.scanner; public class exercise_4 { public static void main(string [] args) { scanner scan = new scanner(system.in); system.out.println("please enter words"); string word = scan.nextline(); (char ch: word.tochararray()) { system.out.println(ch); } } } you can try this:- string s = "zip"; string spaces = ""; (int = 0; < s.length(); i++) { system.out.println(spaces + s.charat(i)); spaces += " "; }

iphone - Move Background CCSprite repeatedly like a moving road -

i'm new cocos2d , have image 640 x 1136 pixel , set background sprite statically. want move sprite, continuously moving background in upward direction. set code below in init method. here code : background = [ccsprite spritewithfile:@"bgimagevertical.png"]; background.scalex = 1; background.scaley = 1; nslog(@"size x :: %f && y :: %f",size.width,size.height); background.position = ccp(size.width/2,size.height/2); [self addchild:background]; lot of parallax scrolling tutorials available on internet. try searching right term. here 1 you: http://www.learn-cocos2d.com/2012/12/ways-scrolling-cocos2d-explained/

handlebars.js - How to get reference to json key name inside {{#with}} helper? -

i want draw fields using handlebars partial have key name , value. json this: { "someknownfield" : { "textvalue" : "the value want" } } i want label someknownfield text, , input value of textvalue in it. use partial because have hundreds of these fields , don't want have hard code names. here's partial code, called textfield <div class="control-group"> <label class="control-label" for="input{{@key}}">{{@key}}</label> <div class="controls"> <input type="text" id="input{{@index}}" placeholder="{{@key}}" value="{{textvalue}}"> </div> </div> now, can't use {{#with}} helper, a-la {{#with someknownfield}}{{> textfield}}{{/with}} since doesn't give @key . {{#each}} has @key of context within each node ( textvalue ); how key key name of each node itself? this not work, demonstrates need grab:

c# - Ideas about Generating Untraceable Invoice IDs -

i want print invoices customers in app. each invoice has invoice id . want ids be: sequential (ids entered lately come late) 32 bit integers not easily traceable 1 2 3 people can't tell how many items sell. an idea of own: number of seconds since specific date & time (e.g. 1/1/2010 00 am). any other ideas how generate these numbers ? i don't idea of using time. can run sorts of issues - time differences, several events happening in single second , on. if want sequential , not traceable, how generating random number between 1 , whatever wish (for example 100) each new id. each new id previous id + random number. you can add constant ids make them more impressive. example can add 44323 ids , turn ids 15, 23 , 27 44338, 44346 , 44350.

Does the version of IE included with Windows Mobile 6.1 support "new tab" or "new window"? -

i'm developing small web app using asp.net (vb). windows mobile 6.1 browser support "new tab"? how "new window"? here's code i'm using: <img src="image/specs.jpg" style="cursor: hand;" title="define serial number" onclick="javascript: window.open('dialog_window.aspx?p=request_line_specs.aspx&appid=<%=appid.text%>&linenum=<%#databinder.eval(container.dataitem, "linenum")%>&apptype=<%=apptype.text%>&itemcode=<%#databinder.eval(container.dataitem, "itemcode")%>&t=define serials', 'scroll:no; status:no; address: no; dialogwidth: 700px; dialogheight: 500px;')" /> the version of internet explorer came windows mobile platforms not support tab browsing. tab browsing came out around ie 8, , widows mobile includes cut down version of ...ie6, believe. so, basically, tab browsing not developed yet. to kno

python - Counting how many specific items exist in a YAML file? -

i'm attempting find out how many "usernames" exist. there two, , can loop on users this, feels clunky. there way how many usernames exist in user? open('file.yaml', 'r') f: file = yaml.safe_load(f) # count number of usernames in user...? file.yaml: host: "example.com" timeout: 60 work: - processes: 1 users: - username: "me" - username: "notme" if want counts specific structure: sum([len(x["users"]) x in d["work"]]) for general solution, like: f = open("test.yaml") d = yaml.safe_load(f) # d dict - {'host': 'example.com', 'work': [{'processes': 1, 'users': [{'username': 'me'}, {'username': 'notme'}]}], 'timeout': 60} def yaml_count(d, s): c = 0 if isinstance(d, dict): k, v in d.iteritems(): if k == s: c += 1 c += yaml_count(v, s)

c# - How to add multiple email address receipients retrieved from MySQL? -

i'm getting error on line below :- email = mydatareader.getvalue(i).tostring(); what i'm trying retrieve multiple email addresses mysql , send email. based on example have found, stores in arraylist, in case gives me error. i have on google still not able correct error. could 1 me out please ? thanks. protected void searchemail () { mysqlconnection con = new mysqlconnection("server=localhost;userid=root;password=;database=obsystem"); con.open(); mysqlcommand cmd = new mysqlcommand("select cusemail,cusfname,newbalance monthlytracker month(paymentdate)='" + mm + "' , year(paymentdate)='" + year + "'and status='" + unpaid + "'",con); mysqldatareader mydatareader = cmd.executereader(); //arraylist list_emails = new arraylist(); int = 0; //string email = string.empty; list<custinfo> list_emails = new list<custinfo>(); custinfo cus

delphi - How do I write to StdOut from a GUI app started from the command line? -

i writing standard windows app in delphi 7. if writing console app, can call following output cmd line or output file. writeln('some info'); if standard gui app have started command line error. i/o error 105 there must simple solution problem. want app have 2 modes, gui mode , non-gui mode. how set correctly can write cmd window? this question similar (if not same) trying accomplish. wanted detect if app executed cmd.exe , send output parent console, otherwise display gui. answers here helped me solve issue. here code came experiment: parentchecker.dpr program parentchecker; uses vcl.forms, sysutils, psapi, windows, tlhelp32, main in 'main.pas' {frmparentchecker}; {$r *.res} function attachconsole(dwprocessid: integer): boolean; stdcall; external 'kernel32.dll'; function freeconsole(): boolean; stdcall; external 'kernel32.dll'; function getparentprocessname(): string; const buffersize = 4096; var handle

scripting - Selecting "" links with mechanize in ruby -

i made script in ruby uses mechanize. goes google.com, logs in , image search cats. next want select 1 of results links page , save image. my problem links of results shown empty strings im not sure how specify , click them. here output of pp page can see links im talking about. note first link suggested links, can click because have title "past 24 hours" second link actual result search cannot click. #<mechanize::page::link "past 24 hours" "/search?q=cats&hl=en&gbv=1&ie=utf8&tbm=isch&source=lnt&tbs=qdr:d&sa=x&ei=t8kduu7ab4f8iwkzx4hobg&ved=0ccqqpwuoaq"> #<mechanize::page::link "" "http://www.google.com/imgres?imgurl=http://jasonlefkowitz.net/wp-content/uploads/2013/07/cute-cats-cats-33440930-1280-800.jpg&imgrefurl=http://jasonlefkowitz.net/2013/07/slideshow-20-cats-that-suck-at-reducing-tensions-in-the-israeli-palestinian-conflict/&usg=__1yeuvke4a9r6iirkcz9pu6ahn8q=&h=8

c# - Keeping Data in GridView after PostBack -

i have gridview associated sqldatasource . when click button , change selectcommand , use databind update gridview . after postback, want latest data remain, don't want gridview loaded original selectcommand . i know done called viewstate , didn't manage implement in right way. i tried both enableviewstate="true" , enableviewstate="false" on grid itself, no luck. code <asp:gridview id="gridview1" ...... datasourceid="userssource" > <asp:sqldatasource id="userssource" ... selectcommand="select * users"></asp:sqldatasource> on startup, gridview filled results of select * users . now click button , following: userssource.selectcommand = "select * users user_id = 1"; gridview1.databind(); the gridview filled new data. now let's say, click on header sort table, there postback, , after it, data in table contain results of first query. what needs done here?

c++ - Type casting when exceeding the limit -

i want multiply 2 int numbers and, in order prevent exceeding int limit (2147483647), result saved in long long variable. so, try piece of code: int a, b; long long result = * b; and it doesn't work! if a=50000 , b=50000 result=-1794967296 . therefore, have apply type casting a , b : int a, b; long long result = (long long)a * (long long)b; why necessary apply type casting in case? note: don't want change data type of a , b , need keep them int . since a , b int , product a*b int also. product big overflows , incorrect value.the cast needed product long long . by way, don't need cast both operands. 1 enough: long long result = * (long long)b; the other 1 promoted long long also. see this online demo . by way, prefer c++-style cast on c-style cast: long long result = * static_cast<long long>(b); hope helps.

XPATH : replace every ohter whitespace -

i'd replace every other (odd?) space x . result should be: axb axb axb axb axb i tried like: replace ("a b b b b" , " " , "x")[position() mod 2 = 0] -- no result. first of all: fn:replace requires xpath 2.0 (or xquery) compatible query processor. you cannot use fn:replace predicate this. there no array-like access characters in xpath (like you're used eg. c). solve using fn:tokenize , for-loop, that's getting things rather complicated. your query did not return result, there 1 result (single element string sequence), predicate returns every second. use regular expression instead. expression matches on non-space ( \s ) , space ( \s ) , replaces patterns version x in between. star quantifier in end important odd number of match groups (like in example). replace("a b b b b" , "(\s+)\s+(\s+\s*)", "$1x$2")

iphone - How to make my navigationbar,and toolbar at the bottom to be a single color? -

Image
i have application in using both navigation bar,and toolbar(at bottom).both having shade center bottom.this how creating toolbar` [self.navigationcontroller settoolbarhidden:no animated:yes]; self.navigationcontroller.toolbar.barstyle = uibarstyleblackopaque; self.navigationcontroller.toolbar.frame=cgrectmake(0, [[uiscreen mainscreen] bounds].size.height -12, [[uiscreen mainscreen] bounds].size.width,30); self.navigationcontroller.toolbar.tintcolor=[uicolor colorwithpatternimage:[uiimage imagenamed:@"top_bar.png"]]; and doing navigation bar this uiimage *navbar = [uiimage imagenamed:@"top_bar.png"]; [[uinavigationbar appearance] setbackgroundimage:navbar forbarmetrics:uibarmetricsdefault]; ` can point me in going wrong? i think easiest way create 1x1 uiimage , set background image navigation bar , toolbar. eliminate gradient , make both bars 1 solid color of choosing. here's example: uiimage *image = [self imagewith

ios - Audio Queue Service Example using How to record sound in mp3 format in iPhone -

i new in ios developement.i have downloaded sample audio recorder project https://github.com/vecter/audio-queue-services-example using audio queue service of audiotoolbox framework .in sample project recorded audio format .aif. while run downloaded sample project working fine.in sample example project using how record audio .mp3 format .how can this? simply have changed kaudiofileaifftype kaudiofilemp3type getting message nslog //---------nslog message-------------- not recording, returning writing buffer 0 //------------------ - (void)startrecording { [self setupaudioformat:&recordstate.dataformat]; recordstate.currentpacket = 0; osstatus status; status = audioqueuenewinput(&recordstate.dataformat, audioinputcallback, &recordstate, cfrunloopgetcurrent(), kcfrunloopcommonmodes, 0,