Posts

Showing posts from September, 2012

iphone - How do you add a resource to a .bundle/wrapper.plug-in? -

sorry n00b question, have no more hair pull. =( i'm building ios project using xcode , have reference xcode project, make work need reference bundle-file. developer built project , bundle wanted organize things , put images inside of .bundle-file. now question this: how add file/resource .bundle file? -> http://grab.by/7p3y the file type of bundle is: wrapper.plug-in -> http://grab.by/7p3w the files add right-clicking , selecting add existing files end in project not in bundle resource. any kind of appreciated! indication if common or custom solution? best regards abeansits update: as usual problem me, i'm blaming on low sugar levels. =( need add file bundle manually , show in xcode. as wrote in question, solution simple. add files need inside project bundle. since bundle folder, can right click select show content. later add folder show in project. i guess confused me since when add resources project need through xcode.

javascript - escape HTML chracters -

i need html encode chracters input <test> expected output &lt;test&gt; . how can this? var encoded = htmlencode('<test>'); // returns "&lt;test&gt;" // ... function htmlencode(str) { var div = document.createelement('div'); var txt = document.createtextnode(str); div.appendchild(txt); return div.innerhtml; }

Doctrine Behavior / Templates: Is there a way overwrite or load data into the invoking Doctrine_Record from a Doctrine_Template? -

hy! i'm new doctrine library. i'm trying take advantage of doctrine behavior (templating) system build authenticable behavior ran few problems. this how wanted declare it: class baseadminuser extends doctrine_record{ public function settabledefinition(){ // ... } public function setup(){ // ... $this->actas(new doctrine_template_authenticatable()); } } this how wanted use it: in admin bootstrap file: // ... $admin = new adminuser(); if(!$admin->login_check()){ redirect("login.php"); }else{ // $admin->id available } in admin login.php page: // ... if($data = $_post){ $admin->login($data); } i wanted template use native php sessions (using $_session ) following: upon login set session , save record doctrine_core::hydrate_array in upon instantiation of record , template check if session data exists , load invoking record id session one approach tried re-route $invoker. doesn't work. class doctri

user controls - c# usercontrol transparency -

it's possible have usercontrol on form , set transparency percentage? wish have background of usercontrol 70% transparent, buttons , rest of components 100% it's possible? thanks try adding following control's constructor: base.createparams.exstyle |= 0x20; setstyle(controlstyles.supportstransparentbackcolor, true); backcolor = color.fromargb(0x80,0xff,0xcc,0x33);

java - How do I create a FieldDeclaration given an IField (Eclipe plugin) -

given have access ifield field (parsed java file), how create fielddeclaration in order add ast? string varname = field.getelementname(); string typename = signature.tostring(field.gettypesignature()); variabledeclarationfragment fieldfrag = ast.newvariabledeclarationfragment(); fieldfrag.setname(ast.newsimplename(varname)); fielddeclaration field = ast.newfielddeclaration(fieldfrag); type fieldtype = ast.newsimpletype(ast.newsimplename(typename)); field.settype(fieldtype); field.modifiers().add(ast.newmodifier(modifierkeyword)); the above type fieldtype = ast.newsimpletype(ast.newsimplename(typename)); only works if typename not java keyword. there way create fielddeclaration ifield info (modifier, type, variable) thanks i've found way using copysubtree: ast ast = targetcompilationunit.getast(); fielddeclaration oldfielddeclaration = astnodesearchutil.getfielddeclarationnode(field, sourcecompilationunit); type

c++ - Sleep for milliseconds -

i know posix sleep(x) function makes program sleep x seconds. there function make program sleep x milliseconds in c++? note there no standard c api milliseconds, (on unix) have settle usleep , accepts microseconds: #include <unistd.h> unsigned int microseconds; ... usleep(microseconds);

algorithm - mersenne twister - is there a way to jump to a particular state? -

i little unsure right forum question. between theoretical comp. sci./math , programming. i use mersenne-twister generate pseudo random numbers. now, starting given seed, jump n-th number in sequence. i have seen this: http://www-personal.umich.edu/~wagnerr/mersennetwister.html , , 1 scheme follows: suppose, need first n numbers in complete random sequence particular seed s . split sequence in p subsequences, march through n numbers, , save state vector of random number generator @ beginning of each subsequence. reach n -th number, i'll see n falls in k -th subsequence , i'll load state vector subsequence , generate m consecutive random numbers m-th number in k-th subsequence same n-th number in complete sequence ( n = m + (k-1) * n/p ). but state vector 624 x 4 bytes long! wonder if practically possible jump arbitrary element in mersenne-twister generated sequence. yes possible! it's called jump ahead . you can find details mersenne twister

php - Is it possible to insert values from one table into another AND update field values in same query? -

i have 2 tables. 1 table meant serve transaction history , other log of member details. when report run, want move pieces of member details transaction history update field records not otherwise exist. is possible select records meet specific criteria, insert pieces of matching row table , update other fields in single query? for example: in table 2, have member name, date registered, , memberid. want move above records table 1 update field (status) equal 'processed'. note: using php , pdo connect mysql database. is possible within single query? you didn't specify whether rows want update same ones inserting. assuming are: insert table1 (member_name, date_registered, memberid, status) select member_name, date_registered, memberid, 'processed' table2 somefield = mycriteria

SQL Inner Join Returns WAY More Rows Than Expected -

the following query returns >7000 rows when each table has 340 rows. select config.spec, temptable.spec confg inner join temptable on config.spec = temptable.spec why happen? if inner join returns row if there match in both tables why return multiple rows match. if there more 1 row same spec value in temptable same spec value in confg , duplicate rows, , vice versa.

android - How to start new activity on button click -

in android application, how start new activity (gui) when button in activity clicked, , how pass data between these 2 activities? easy. intent myintent = new intent(currentactivity.this, nextactivity.class); myintent.putextra("key", value); //optional parameters currentactivity.this.startactivity(myintent); extras retrieved on other side via: @override protected void oncreate(bundle savedinstancestate) { intent intent = getintent(); string value = intent.getstringextra("key"); //if it's string stored. } don't forget add new activity in androidmanifest.xml: <activity android:label="@string/app_name" android:name="nextactivity"/>

java - Custom Domain for Google AppEngine Apps -

i have been fooling around google app engine few days, question wanted ask was, if want deploy web app custom domain server need hosted on windows server??? no, not need windows server. need sign-up google apps , add application domain. if using google apps for, free version fine. i think might have misunderstandings app engine . app engine, applications run on google's servers, not yours. also, believe servers linux, not windows. if wanting run own servers 'using' app engine java check out appscale .

php - Counting all results of MySQL query for paging -

i building search page, each page featuring 10 results. purpose, display pages numbers @ bottom (like in google example) user can jump specific page result. in order need know overall count of query (e.g., if show 10 results per page , specific query returns 73 rows in table, need display links 8 pages). the way can think of using following (obviously inefficient) query: // query current page $res = mysql_query("select * table col='sample' limit $offset,10"); // geeting total count can build links other pages $res2 = mysql_query("select count(*) fromtable col='sample'"); is way it? thanks, danny you can use sql_calc_found_rows mysql> select sql_calc_found_rows * tbl_name -> id > 100 limit 10; mysql> select found_rows(); sql_calc_found_rows tells mysql calculate how many rows there in result set, disregarding limit clause. number of rows can retrieved select found_rows()

android - Droid Incredible Headphones Detection -

i'm developing android application droid incredible. when plug in headphones, icon appears on status bar, presume phone must know headphones present. my code produces beeps in response various user inputs, discovered today that's bad idea when user wearing headphones. ow. does have suggestions how can detect presence of headphones programmatically, in android?? thanks, r. i found audiomanager class on developer site, looks have helpful method this, have not tested it: audiomanager = getsystemservice(context.audio_service); bool headsetenabled = am.iswiredheadseton();

c# - Can I use some other class's function as a delegate? -

say have 2 classes, class , class b. class creates instance of class b. class has function pass method class b. class { void main(string[] args) { b classb=new b(); delegatecaller(new delfunction(classb.thefunction()); // <-- won't compile (method name expected) delegatecaller(new delfunction(b.thefunction()); // <-- won't compile (object reference req'd) } public delegate string delfunction(); public delegatecaller(delfunction func) { system.console.writeline(func()); } } class b { public string thefunction() { return "i'm printing!!!"; } } i'm not sure if syntax issue or it's can't do. maybe need define delegate in b, reference in a? b's this pointer? it's syntax issue; rid of parentheses after classb.thefunction - indicate wish invoke method. delegatecaller(new delfunction(classb.thefunction)); do note there implicit conversion available method-group, can do:

php - Convert Timestamp to Timezones -

i have timestamp user enters in gmt. i display timestamp in gmt, cet, pst, est. thanks post below have made, works perfectly! public static function make_timezone_list($timestamp, $output='y-m-d h:i:s p') { $return = array(); $date = new datetime(date("y-m-d h:i:s", $timestamp)); $timezones = array( 'gmt' => 'gmt', 'cet' => 'cet', 'est' => 'est', 'pst' => 'pst' ); foreach ($timezones $timezone => $code) { $date->settimezone(new datetimezone($code)); $return[$timezone] = $date->format($output); } return $return; } you use php 5's datetime class . allows fine-grained control on timezone settings , output. remixed manual: $timestamp = .......; $date = new datetime("@".$timestamp); // snap utc because of // "@timezo

why doesnt it stay highlighted in jQuery? -

i have jquery $(function() { $('.count_links').hover( function(){ $(this).addclass("highlight"); }, function(){ $(this).removeclass("highlight"); }); $('.count_links').click(function(){ $('.count_links').not(this).removeclass('highlight'); $(this).addclass("highlight"); }); }); but link class never stays after clicked i want hover effect , click effect you're removing highlight class when cursor leaves element. it doesn't matter whether add class on click or on hover, second function passed .hover (which called on mouse-out) removes class. you might consider adding different class on click, 'selected'.

debugging - Android Maps NullPointerException ItemizedOverlay -

this not refer anywhere in code @ all. how go getting bottom of it? java.lang.nullpointerexception @ com.google.android.maps.overlaybundle.draw(overlaybundle.java:42) @ com.google.android.maps.mapview.ondraw(mapview.java:494) @ android.view.view.draw(view.java:6739) @ android.view.viewgroup.drawchild(viewgroup.java:1648) @ android.view.viewgroup.dispatchdraw(viewgroup.java:1375) @ android.view.viewgroup.drawchild(viewgroup.java:1646) @ android.view.viewgroup.dispatchdraw(viewgroup.java:1375) @ android.view.view.draw(view.java:6742) @ android.widget.framelayout.draw(framelayout.java:352) @ android.view.viewgroup.drawchild(viewgroup.java:1648) @ android.view.viewgroup.dispatchdraw(viewgroup.java:1375) @ android.view.view.draw(view.java:6742) @ android.widget.framelayout.draw(framelayout.java:352) @ com.android.internal.policy.impl.phonewindow$decorview.draw(phonewindow.java:1872) @ android.view.viewroot.draw(viewroot.java:1422) @ android.view.viewroot.performtraversals(viewroot.ja

javascript - Chrome not recognizing jquery plugin -

i trying use jquery autocomplete plugin in application. it works on ie , ff chrome behaving wierdly , not calling function. <script type="text/javascript" src="/gim-webui/jquery/jquery-latest.js">jquery.noconflict();</script> <link rel="stylesheet" href="/gim-webui/jquery/autocomplete-main.css" type="text/css" /> <script type="text/javascript" src="/gim-webui/jquery/autocomplete.js"></script> i kept alert dialog box in autocomplete function. both ff , ie pop alert message not chrome. doing wrong here? its erroring out when call .autocomplete on dom element. thank you. i suspect problem here: <script type="text/javascript" src="/gim-webui/jquery/jquery-latest.js">jquery.noconflict();</script> -^- -^- a script tag may either have src attribute or have code conte

is a BLOB more secure than allowing write permission to a directory on a web server -

i building system allows entry database (think user accounts if want) have image associated it. these small images , there won't many of them. i know general pros/cons of using blob , doesn't seem problem in case. security on project important though. more secure set directory on windows server site can store images uploaded user instead of sticking image in db blob? so potential security concerns on web users loading image server significant enough take small performance hit or being on cautious? the site built in asp.net 4.0 , database sql server 2008, server using host site windows server 2003 or 2008. yes using blobs in sql database store sensitive information safe. 1)completely eliminates problem of directory traversal. 2)easy apply access control on file file basis , link users/groups. 3)the database has built in encryption. alternatively safe , faster approach store files outside of web root. change file name primary key , store metadata (su

eclipse - How to create multiple Android apps from one code base -

i have android code base uses apis settings different data several apps. apps use same code base 1 or 2 design tweaks. how re-use main code base without having copy whole android project each time? iphone uses multiple targets in same project works well. if android cant need compile binaries of code base in 1 project , import each new app project? if how? i'm using eclipse , intermediate java developer. any appreciated! doug check out "working library projects" android documentation. should you're looking for: http://developer.android.com/tools/projects/projects-eclipse.html#settinguplibraryproject

ios4 - iPhone - fast-app switching and iOS 4 -

i'm trying following functionality in iphone app: when backgrounded, stays running (doesn't have background work) when resumed, app picks left off i'm wanting same screen on app still up, there several uinavigationcontrollers within uitabbarcontroller. i have done of following: made sure i'm compiling 4.1 sdk set uiapplicationexitsonsuspend false handle didenterbackground , willenterforeground in appdelegate call beginbackgroundtask in didenterbackground, attempt keep app open i'm using monotouch, beside point. can take answers in obj-c, sure. i've tested app on jailbroken phone backgrounder, , see "app in background" badge disappear after pushing home button. tried setting uibackgroundmodes in info.plist, no avail. is there i'm missing? or have implement on own resume previous state of app? everywhere i've read talks should work automatically. if don't want doing work in background, don't call be

Circular gradients in .NET WinForms app -

in winforms app (c#) have circle (defined rectangle ) presently filling solid color. fill circular (not linear) gradient (so 1 color in center fades color uniformly around edges). i have experimented pathgradientbrush , having no luck (i still see solid color). if has sample code this, terrific! i found solution here . private void label1_paint(object sender, painteventargs e) { graphicspath gp = new graphicspath(); gp.addellipse(label1.clientrectangle); pathgradientbrush pgb = new pathgradientbrush(gp); pgb.centerpoint = new pointf(label1.clientrectangle.width / 2, label1.clientrectangle.height / 2); pgb.centercolor = color.white; pgb.surroundingcolors = new color[] { color.red }; e.graphics.fillpath(pgb, gp); pgb.dispose(); gp.dispose(); }

Plotting 3D scatter with python? -

Image
is there module aid me in producing this? like this , say? matplotlib 3d scatter plot http://matplotlib.sourceforge.net/_images/scatter3d_demo.png the matplotlib examples gallery wonderful thing behold. code copied linked example. import numpy np mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot plt def randrange(n, vmin, vmax): return (vmax-vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(111, projection='3d') n = 100 c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]: xs = randrange(n, 23, 32) ys = randrange(n, 0, 100) zs = randrange(n, zl, zh) ax.scatter(xs, ys, zs, c=c, marker=m) ax.set_xlabel('x label') ax.set_ylabel('y label') ax.set_zlabel('z label') plt.show()

Ubuntu proc_root_driver missing from <linux/proc_fs.h> -

i trying compile kernel module in ubuntu 10.04 kernel 2.6.35-22 , complaining proc_root_driver missing. did searching , found supposed define in version of linux-headers, isn't defined. there global variable supposed use in place or there way can define somewhere kernel module can compile? proc_root_driver used pointer proc_dir_entry created proc_mkdir("driver", null); . removed in april 2008 in commit: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=928b4d8c8963e75bdb133f562b03b07f9aa4844a also, don't think ever supposed part of kernel api, afaik internal thing. it doesn't much, really. need use full path under /proc, i.e. replace code looks like proc_array = proc_mkdir("drvnamehere", proc_root_driver); with code looks like proc_array = proc_mkdir("driver/drvnamehere", null); and should fine.

ruby - Rails on Netbeans: Uncaught exception: no such file to load -- script/server or script/console -

i'm trying initiate rails 3 console netbeans 6.9.1 (just upgraded) , fail uncaught exception: no such file load -- script/console the debugger fails on similar error ( ... -- script/server ). the project i'm trying run on rails 2.3.8 app upgraded, , netbeans still tries old ruby script/console command rather rails c . i tried install the patch described here , didn't work. gem list returns: *** local gems *** abstract (1.0.0) actionmailer (3.0.1, 3.0.0.rc2) actionpack (3.0.1, 3.0.0.rc2) activemodel (3.0.1, 3.0.0.rc2) activerecord (3.0.1, 3.0.0.rc2) activeresource (3.0.1, 3.0.0.rc2) activesupport (3.0.1, 3.0.0.rc2) archive-tar-minitar (0.5.2) arel (2.0.2, 1.0.1, 1.0.0.rc1) builder (2.1.2) bundler (1.0.5, 1.0.0.rc.6) columnize (0.3.2) crack (0.1.8) erubis (2.6.6) httparty (0.6.1) i18n (0.4.2) jrails (0.6.0) linecache19 (0.5.11) mail (2.2.9) mime-types (1.16) minitest (2.0.0, 1.6.0) mysql (2.8.1 x86-mingw32) mysql2 (0.2.6 x86-mingw32) nokogiri (1.4.3.1 x86-min

asp.net - MVC Items on paged ListView -

i'm using mvc , load data listview. works fine, here's view: <% dim vardatasource new isam.entityisamrepository listviewdatos.datasource = vardatasource.listarcrucecertificadosprecancelados listviewdatos.databind() %> <asp:listview runat="server" id="listviewdatos"> <layouttemplate> <table id="listviewdatos" class="tablesorter" style="width:100%"> <thead> <tr> <th style="width:2%"> </th> <th style="width:6%" align="left"> <a href="#" style="text-decoration:none"><font color="black">póliza</font></a> </th> </tr> </thead> <tbody> &l

Best way to Merge 2 tables in SQL Server 2008 -

i trying merge 2 similar tables (not exact) 1 table. getting lots of errors ideas on best way this? i see there not type field in tbldvpage hold tbldvpagecategory.type, if wanted merge latter former, may need create new column it, or hold tbldvpagecategory.type tbldvpage.pagetype. either ways end having similar this: insert tbldvpage(title, parentid, pagetype, menuorder) select title, parentid, type, menuorder tbldvpagecategory obviously old ids in tbldvpagecategory gone, , regenerated when items merged tbldvpage. if might want differentiate what new column, depends on scenario.

Howto merge a svn repository with a git cloned repository (imported from SVN via github) -

in past i've have used github's import functionality import svn repository. repository same bare git without connection svn history. commits don't include svn-id information. some time has passed , commits added svn repository expected git repository remained same. so 'update' git repository commits added original svn. i've tried git-svn couldn't make git recognize common history between cloned svn , cloned git. i've considered using format-patch , believe action should solve problem looking more automated way of doing it. the restriction git history should maintained (no rebase 'ing) , commits faithful svn repository possible (no svn-id added commit message). as guessed, getting commits "merge" isn't going work here. have use format-patch . here how it: $ git svn clone --no-metadata svn://.../ new-svn-repo $ cd new-svn-repo $ git log (you may wish add -a option git svn clone rewrite svn authorship infor

bisect and lists of user defined objects (python 3) -

before python 3, used bisect insert user-defined objects list. bisect happy because user-defined object had def __cmp__ defined how compare objects. i've read rationale not supporting cmp in python 3 , i'm fine that. thought fix old code 'decorate' user-defined object turning tuple (integer, user-defined object). however, if have list of tuples, , try ... i = bisect_left([list_of_tuples], (integer, user-defined object)) then error "builtins.typeerror: unorderable types ..." so, (in python 3) how use bisect lists of items aren't made entirely of things natural sort order? you need add __lt__ method; used comparisons instead of __cmp__

c# - Is it a code smell to return a delegate that leaks implementation details? -

i have class called mapbuilder<t> internally uses dictionary<propertyinfo,string> class used build mapping of properties proxied. class looks this:: public class mapbuilder<t>{ private dictionary<propertyinfo, string> m_map = new dictionary<propertyinfo,string>(); public mapbuilder<t> add<tproperty>(expression<func<t, tproperty>> property){ argumentvalidator.assertisnotnull(()=>property); var propertyinfo = reflect.property<t>.infoof(property); m_map.add(propertyinfo, propertyinfo.name); return this; } public mapbuilder<t> add<tproperty>(expression<func<t, tproperty>> property,string columnname){ argumentvalidator.assertisnotnull(() => property); argumentvalidator.assertisnotnull(() => columnname); var propertyinfo = reflect.property<t>.infoof(property); m_map.add(propertyinfo, columnname); r

LINQ to SQL - Group By/Where -

i'm trying implement group messaging feature in asp.net mvc. want display list of threads specific contactid, displaying latest message in thread (no matter it's from). i've set table below: messageid threadid messagebody contactid 10000004 300152,300160, msg1 300160 10000005 300152,300160, msg2 300160 10000008 300152,300160, msg3 300152 i able display latest message grouped threadid. ex: threadid count latestmessage 300152,300160, 3 10000008 however, if add clause before group (see below), it'll filter on contactid first before doing group by, , producing result: threadid count latestmessage 300152,300160, 2 10000005 here's code: var result = s in pdc.messages s.contactid == contactid group new { s } new { s.threadid } d let maxmsgid = d.max(x => x.s.messageid) select new { threadid = d.key.threadid, coun

c# - What it the easiest way to make LINQ to process all collection at once? -

i have similar constructions: var t = in enumerable.range(0,5) select num(i); console.writeline(t.count()); foreach (var item in t) console.writeline(item); in case linq evaluate num() function twice each element (one count() , 1 output). after such linq calls have declare new vatiable: var t2 = t.tolist(); is there better way this? you can call tolist without making separate variable: var t = enumerable.range(0,5).select(num).tolist(); edit : or, var t = enumerable.range(0,5).select(x => num(x)).tolist(); or even var t = (from in enumerable.range(0,5) select num).tolist();

c# - DeepCopy A SortedDictionary -

i have following : sorteddictionary<int, sorteddictionary<int, volumeinfoitem>> that want deepcopy. volumeinfoitem following class : [serializable] public class volumeinfoitem { public double = 0; public double down = 0; public double neutral = 0; public int dailybars = 0; } i have created following extension method : public static t deepclone<t>(this t a) { using (memorystream stream = new memorystream()) { binaryformatter formatter = new binaryformatter(); formatter.serialize(stream, a); stream.position = 0; return (t)formatter.deserialize(stream); } } i can't figure out how deepcopy working ? your code looks in 1 of answers of question: how do deep copy of object in .net (c# specifically)? but, since know type of dictionary's contents, can't manually? // assuming dict original dictionary var copy = new sorteddictionary<int, sorteddictionary<int, volumeinfoi

Does Git, SVN, etc do this type of "branching & merging" or something like this? -

client has different versions of same code based, copy template code base, edit copy, , use copy in production instance of code. meaning there's 20 versions of code base running, 80% of code same. without changing workflow there way merge source code , builds of code if code changes in vcs each of builds/branches. code in perl if matters. if so, called, , vcs manage "builds" (it's perl, versions of code). visual: a,b,c custom code branches; x shared code | | x | /|\ / | \ b c \ | / \|/ | | x | | |\ | \ a,b c | / |/ | | x | | /| / | b,c \ | \| | | etc... x = 80% of code. | | yes can, before explain it, have recommend not this. better separate variable stuff shared stuff, , turn shared stuff kind of framework, simple moving variable stuff "sites" directory (i'm guessing building canned web sites) 20 subdirectories framework chooses (adds mo

How would I make a C-function that I can call from Lua? -

i know how make c-function , able tell lua it, call lua. have lua libraries installed on mac osx 10.4 computer. there's excellent example of lua-c integration here , here . if need export function global namespace, then: declare function (let's call f ) signature lua_cfunction . call lua_register(l, "myfunc", f) , l being lua state, , function = f . run lua code. f available in global namespace myfunc . if you're going use stock interpreter might want make library. this guy wrote article lua programming gems explains how it. sources available online.

ruby - Which style,lambda..should or expect..to, is preferred for testing expectations in RSpec? -

i have seen both styles used widely: #1 lambda { raise "boom" }.should raise_error , #2 expect { raise "boom" }.to raise_error . expect..to more reads better , hides creation of proc. i looked @ rspec code , seems expect..to suggested , regularly come across libraries using lambda..should. expect..to newer , hence not "famous" yet? expect used since rspec-2, lambda had used. rspec "officially" recommends use expect , possible decide "obsolete" lambda syntax. the lambda syntax used in of libraries started life in rspec1 days. haven't yet migrated (and why if still supported). so, use expect instead of lambda .

html - tooltip when max input length reached -

can give tooltip input type text in case max length of textbox reached in html??? yes, can set tooltip text box /* txtname id of youe textbox val value of textbox ccount max length of textbox. if ccount set 4 if value of textbox exceed 4 show tooltip */ function txttooltip(txtname, val, ccount) { var txttool = document.getelementbyid(txtname); if (txttool.value.length > ccount) { //setting tool tip value. txttool.title = txttool.value; } } your input box is <input type="text" name="txtnm" id="txtnm" onkeyup="txttooltip(this.id, this.value, 4);"/>

How to send money to paypal using php -

i have stored customers paypal email address in database , want send them money using email address. using php. anyone please suggest how that. i looking same issue, here's working me. tested in 'sandbox' mode , using nvp (instead of soap). server must support curl, in order verify use: <?php echo 'curl extension/module loaded/installed: '; echo ( !extension_loaded('curl')) ? 'no' : 'yes'; echo "<br />\n"; phpinfo(info_modules); // sure ?> if not loaded or installed ask hostmaster or get here , otherwise go ahead: <?php // code modified source: https://cms.paypal.com/cms_content/us/en_us/files/developer/nvp_masspay_php.txt // documentation: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_id=developer/howto_api_masspay // sample code: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_id=developer/library_code // email subject receivers $vemailsubject = 'payp

Question about Windows API and C/C++ run-time library function -

when write c/c++ code windows platform, use windows apis necessary. when comes multi-threading, read following quotaion < windows via c/c++ > the createthread function windows function creates thread. however, if writing c/c++ code, should never call createthread. instead, should use microsoft c++ run-time library function _beginthreadex. if not use microsoft's c++ compiler, compiler vendor have own alternative cratethread. whatever alternative is, must use it. afaik, language run-time library platform implemented platform's apis. think totally possible call createthread() c/c++ code. , quite did that. don't understand why above rule should followed. many insights. of course it's possible use windows api's createthread directly. but leaves runtime library uninformed new thread. for multi-threading support in runtime library (and includes functions rely on static storage, e.g. imagine includes strtok ) need kee

What exactly is One Definition Rule in C++? -

what 1 definition rule in c++ say? trustworthy occurence can find in the c++ programming language, 3rd. ed., p. 9.2.3 . there official definition of rule except that? the truth in standard (3.2 1 definition rule) : no translation unit shall contain more 1 definition of variable, function, class type, enumeration type or template. [...] every program shall contain 1 definition of every non-inline function or object that used in program ; no diagnostic required. definition can appear explicitly in program, can found in standard or user-defined library, or (when appropriate) implicitly defined (see 12.1, 12.4 , 12.8). inline function shall defined in every translation unit in used.

c# - Create a windows service from windows application -

i have windows application built c# , need run every , then, create windows service. how possible create windows service existing soluion? maybe it's easier call scheduled task, way won't need coding.

Question regarding iPhone error -

when run below code gives response on device.... - (void) requestproductdata { // nsstring *str = [[nsstring alloc] initwithformat:@"com.mycompany.inapppurchasetesting.productid"];//same product id displayed in itunes connect//"]; skproductsrequest *request= [[skproductsrequest alloc] initwithproductidentifiers:[nsset setwithobject:str]]; request.delegate = self; [request start]; // //nsset *productids = [nsset setwithobjects:@"com.mycompany.inapppurchasetesting.productid", nil]; //skproductsrequest *request = [[skproductsrequest alloc] initwithproductidentifiers:productids]; //request.delegate = self; nslog(@"requesting"); //[request start]; } - (void)productsrequest:(skproductsrequest *)request didreceiveresponse:(skproductsresponse *)response { nsarray *myproduct = response.products; nsarray *myinvalidproducts = response.invalidproductidentifiers; nslog(@"did recieve response"); nslog(@"respons

css - How to solve the problems that html page works well in firefox and chrome, but wrong with IE? -

i meet problem page works in firefox , chrome(almost same , feel) bad in ie. it's time consuming adjust differences. there research has been done tell differences, or automation tool examine uncompatibilities? btw: tool guys using when debugging in ie(like firebug ie)? your best starting point use kind of "reset mechanism" eric meyer's css reset or framework html5 boilerplate , in reducing differences between browsers (not all, of it). if not possible (project in finishing phase, etc.) can ask questions here, check position everything description of bugs, quirks mode , sitepoint reference , various other sites (google friend :)). hope helps. there "debugging" tool ie - ie developer toolbar - it's usefulness can't compare of firebug, dragonfly , such. ie8+ have better support debugging, though… there articles suggest using visual studio , haven't tried it. it's trial , error ie :).

How to get the number of sent SMS messages between specific dates in android -

is there way retrieve number of sent sms messages between specific dates in android? i prefer officially supported sdk functionality, stating in answer whether part of official sdk helpful. i aware of this stack overflow question seems use not officially supported android.provider.telephony.sms_received , content://sms/sent , rather not use (please correct me if i'm wrong being unsupported). i know old question, came across , spotted unanswered. please not downvote me because of it. maybe need answer. all have query phone content provider (i used calllog.calls constants instead hardcoded strings columns names) string[] projection = { calllog.calls.date }; uri smscontenturi = uri.parse("content://sms/"); cursor cursor = this.getcontentresolver().query(smscontenturi , selection,where, null, null); simpledateformat format = new simpledateformat("dd-mm-yy"); cursor.movetofirst(); log.d("sms count", ""+cursor.getc

boot - Why is the root filesystem is loaded into a ramdisk? -

i studying boot process in linux. came across sentence "ram several orders of magnitude faster floppy disk, system operation fast ramdisk" the kernel anyway load root filesystem in ram executing it. question why need ramdisk loading the root filesystem, if kernel loads root file system ram ? the documentation suse linux provides explanation of why linux booted ramdisk: as linux kernel has been booted , root file system (/) mounted, programs can run , further kernel modules can integrated provide additional functions. to mount root file system, conditions must met. kernel needs corresponding drivers access device on root file system located (especially scsi drivers). the kernel must contain code needed read file system (ext2, reiserfs, romfs, etc.). conceivable root file system encrypted. in case, password needed mount file system. for problem of scsi drivers, number of different solutions possible. kernel cont

.htaccess - Remove www site-wide, force https on certain directories and http on the rest? -

firstly, remove www. domain name http://www.example.com => http://example.com i directories secure (https), while rest remain http http://example.com/login => https://example.com/login obviously needs work conditions, example if types in: http://www.example.com/login => https://example.com/login also when people navigate away login page returns http. in .htaccess following done automatically software using , suppose needs there work: rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule .* ./index.php any ideas on how can achieve dream control these things? thanks in advance! =================== @gumbo following advice complete .htaccess rewriteengine on # remove www host rewritecond %{http_host} ^www\.(.+) rewritecond %{https}s/%1 ^(on(s)|offs)/(.+) rewriterule ^ http%2://%3%{request_uri} [l,r=301] # force https rewritecond %{https} =off rewriterule ^(login)$ https://%{http_host}%{request_uri} [l,r=301] # force

android - Call (and get the response for) a USSD Code, in the background? -

i'm wanting write widget displays users' prepay balance, remaining data etc. i'm thinking of automatically calling ussd code returns data (will have have regex each network), @ intervals (not often, save battery). have done in background. have app @ moment runs ussd code , returns result, think should possible - i'm not sure how done in background. i've seen intents calling number, i'm not sure how result, , i'm thinking that intent cause call screen come foreground? the other option data screen-scraping result carrier's website/maybe wap site result in data charges user, prefer solution using ussd code. thanks in advance - started working on understanding android today got quite lot learn :) ussd not yet supported on android. there feature request it: http://code.google.com/p/android/issues/detail?id=1285

problem with uploading and downloading xml document from Datastore using google app and python -

i creating 1 xml document in google app , storing blob while fetching datastore how convert again xml doc class xmlstore(db.model): xmlref=db.blobproperty() creating xml doc this: docref=document() fp=docref.createelement("client") fp.setattribute("id","21783") docref.appendchild(fp) storing datastore: x=xmlstore(xmlref=str(docref)) x.put() while retriving back: result = db.gqlquery("select * xmlstore").fetch(1) while printing on webpage: for response in result: self.response.out.write(response.xmlref) its giving me xml.dom.minidom.document instance @ 0x6a2bddb0b5aef438 how in xml.. have @ python's documentation xml.dom.minidom toxml method . you say: its giving me xml.dom.minidom.document instance @ 0x6a2bddb0b5aef438 call .toxml() method of object.

java - Hunting for “too many files” cause -

we hit strange issue on 1 of customers servers, java encounters "too many files", checking descriptors via lsof produces large list of "sock" descriptors "can't identify protocol". i suspect happens due sockets opened time, our thread dump contains lot of them, have no clear idea culprit. is there method detect threads open these sockets? thanks. is there method detect threads open these sockets? not threads per se . one approach run application using profiler. find problem if cannot reproduce customer's problem. (@syber reports yourkit profiler has specific support finding socket leaks ... see comment.) a second approach tweak test platform using ulimit reduce number of open files allowed. may make easier reproduce "too many files open" scenario in test environment. finally, i'd recommend "grepping" codebase find places socket objects created. examine them make sure use correctly try /

process - how can run this cmd command "bcdedit /set testsigning on" by c#? -

how can run cmd command "bcdedit /set testsigning on" c#? code - no run : string strcmdline; strcmdline = "bcdedit /set testsigning on"; process.start("cmd.exe", strcmdline); missing details on actual issue here... here's guess, think missing /c flag. string strcmdline; strcmdline = "/c bcdedit /set testsigning on"; process.start("cmd.exe", strcmdline); see of cmd.exe more details on /c flag (cmd /?).

c# - How to get BinaryFormatter to deserialize in a different application -

i using binaryformatter serialize array of class instances file. can deserialize fine within same application. when try same deserialization in different application (that pulls in common file work) following error: {"could not load file or assembly 'pmlscan, version=1.0.0.0, culture=neutral, publickeytoken=null' or 1 of dependencies. module expected contain assembly manifest."} where pmlscan name of original application. how binaryformatter not try , load pmlscan? you can achieve using custom serializationbinder. see here: advanced binary serialization: deserializing object different type 1 serialized into

xamarin.ios - Add project to an existing Monodevelop (Mono Touch) solution -

where command/button/dialog add project existing mono touch solution? e.g. have monotouch app , want add class library solution. it seems if imac not responding in normal fashion ctrl click. got around double click context menu

java - Sending commands to server via JSch shell channel -

i can't figure out how can send commands via jsch shell channel. i this, doesn't work: jsch shell = new jsch(); string command = "cd home/s/src"; session session = shell.getsession(username, host, port); myuserinfo ui = new myuserinfo(); ui.setpassword(password); session.setuserinfo(ui); session.connect(); channel = session.openchannel("shell"); fromserver = new bufferedreader(new inputstreamreader(channel.getinputstream())); toserver = channel.getoutputstream(); channel.connect(); toserver.write((command + "\r\n").getbytes()); toserver.flush(); and read input this: stringbuilder builder = new stringbuilder(); int count = 0; string line = ""; while(line != null) { line = fromserver.readline(); builder.append(line).append("\n"); if (line.endswith(".") || line.endswith(">")){ break; } } string result = builder.tostring(); consoleout.printl

python - Exclude system paths from django_coverage -

i'm running django_coverage on project command test_coverage . it's working, it's including in output , final calculation code in /usr/local/lib/python2.6/dist-packages . i'm not interested in knowing coverage of modules, test coverage project. see in django_coverage documentation on bitbucket there coverage_path_excludes , seems apply subdirectories of project , not absolute system paths. also, see default coverage_module_excludes exclude imports "django" in it, i'm still getting output /usr/local/lib/python2.6/dist-packages/django . any thoughts on how fix this? do have 'django' listed in coverage_path_excludes? have similar setup (django 1.1.2, python 2.6) don't see output django packages in test coverage results. can post using excludes?

iphone - Special UIScrollView with multiple objects (3) on each page -

Image
what want accomplish this: two different scrollviews, , each 1 scrolls horizontically. each showing 3 images, , half 1 (or 1/3th) piece of next image in datasource of scrollview. does know how accomplish such scrollview? i want able tap image flip , show information , button detail. (see lower scrollview). tapping again show image, coverflow ui inside itunes, without coverflow being 3d... any welcome :) thanks in advance, lewion scroll view doesn't have datasource. looking standard scrolling , nothing special.. doable... check scrolling , photo scroller sample codes apple developer samples. more implementations of scroll view check scroll view suite sample code , read scroll view programming guide . the flip animation standard animation view , doable. example, create utility application iphone. has flip side view. see how animation done.

Flex/Actionscript Function to Calculate Random Point IN Circle -

not sure i'm doing wrong here looking see if had thoughts or suggestions. i'm trying create function returns random point within circle. following code gives me random points along edge of circle. thoughts on i'm doing wrong here? thanks! private function getpointincircle(tmpradius:int):point { var x:int; var y:int; var a:number = math.random() * 360; x = radius * math.cos(a * (math.pi / 180)); y = radius * math.sin(a * (math.pi / 180)); trace("x: " + x + "y: " + y); return new point(x, y); } you need 2 degrees of freedom, 1 angle, had, , other distance center: var d:number = math.random()*radius var a:number = math.random()*2*math.pi; x = d*math.cos(a); y = d*math.sin(a); if have circle centered in (x0,y0) , not in (0,0) modify this: x = x0 + d*math.cos(a); y = y0 + d*math.sin(a); trivia: circle border line. if want refer area delimited border, disk .

ruby - Get list of gems being used by a Bundler project -

is there way list of gems or paths gems being loaded current project bundler (it's rails 3) project. i'm looking like: gem.path but returns ones being actively required bundler in gemfile. what looking this: gem.loaded_specs.values.map { |g| g.full_gem_path }

Google Chrome Textbox focus bug -

hi guys , girls of stackoverflow, got 1 you, i'v had happen couple of times , i'm not 100% sure of why. have normal textbox (code below) <input id="ddbox" type="text" /><span id="ddbutton"></span><div id="dropdown"></div> which inside floating div (jquery dialog precise). in every single browser (including ie) chrome can select text pipe (|) is, in other text program, on chrome not let me this, i'll give example: this test text| now want move pipe after test this test| text i click there (basic stuff know), in chrome ignores click completely, jquery .live(), .click(), , .bind() functions nothing text box whatsoever. i can type text box , if press delete can remove text box, not select pipe is. running chrome 9.0.576.0 dev ubuntu 10.10 bug apparent on: chrome (stable - latest release) windows xp pro sp3 if can me appreciate bug making me tear hair out.

c# - FieldConverter ConverterKind.Date "dd/MM/yyyy" exception -

i try read csv file. fifth record contans date: 03/11/2008 this piece of code: [fieldconverter(converterkind.date, "dd/mm/yyyy")] public datetime datum_5; my code crashs on this: result[] results= (result[])engine.readfile(@"..\data\expo.txt"); and exception: line: 1. column: 41. field: datum_5. error converting '03/11/2008' type: 'datetime'. using format: 'dd/mm/yyyy' when this: [fieldconverter(typeof(convertdate))] public datetime datum_5; with this: internal class convertdate : converterbase { /// <summary> /// different forms date separator : . or / or space /// </summary> /// <param name="from">the string format of date - first day</param> /// <returns></returns> public override object stringtofield(string from) { datetime dt; if (datetime.tryparseexact(from, "dd.mm.yyyy&q

audio - Android recording and playing +speakerphone as an option -

i programming sip application android. during call must record microphone input , play incoming audio. there must optional using of speakerphone. must android 1.5+ (1.5, 1.6, 2.0, 2.1, 2.2, future versions) compatible , device portable. ok. using audiotrack play incoming audio, audiorecord record data microphone , audiomanager.setspeakerphoneon() enable or disable speakerphone. sounds simple not simple should be. audiomanager.setspeakerphoneon(false) not work unless audiomanager.setmode(audiomanager.mode_in_call) called. have in mode_in_call. still ok , simple , works on g1 android 1.6, older samsung phone, emulators, many our customer devices etc. not work everywhere :( on samsung tablet gt-p1000 stream of 0, 0, 0, 0, ... microphone input. think same problem on motorola phones (customers complain). after test realised caused audiomanager.setmode(audiomanager.mode_in_call). causes microphone not work on devices. have call because otherwise can not disable speakerphone. is