Posts

Showing posts from January, 2013

c# - Dynamic Load of a DLL after ILMerge -

in project, dynamically load .dll based on objects settings. prior ilmerge, worked fine. used ilmerge , created 1 .dll, load fails. how dynamically load .dll after ilmerged? using vs2008 , c#. dlls: common.dll, commonmedical.dll new dll: dmcommon.dll current code fails load .dll: asm = assembly.loadfrom("commonmedical.dll"); what doing wrong? tried .load, , not see issues name space because works without ilmerging. in advance, craig the obvious answer, change code to: asm = assembly.loadfrom("dmcommon.dll"); you've created new merged assembly file , you're using loadfrom loads using filename.

How to make a chrome plugin -

i curious how make chrome plugin loads js on every page - i've seen done before, want make first chrome plugin, 1 changes fonts on websites comic sans ms. yep, prank pull on friends computers. i assume take 4 lines? http://www.google.com/support/chrome/bin/answer.py?hl=en&answer=95416 not plugin, however, work if change want. i've tested on stackoverflow , google. if want build extension http://code.google.com/chrome/extensions/getstarted.html

perl - Converting text file to html -

i have plain text file looks - 234234 text 345435 text 23423 text i convert html either vbscript, perl or else looks nice when emailed out. maybe can make numbers bolded etc. any ideas on how can this? thanks if file simple have written, perl -ne 'chomp; s!^(\d+)!<b>$1</b>!; print "$_<br />\n"' inputfile.txt have asked. however if source more complex this, 1 of many html formatting modules on cpan

Interpret differences in prstat vs. 'prstat -m' on Solaris -

i've been using prstat , prstat -m lot investigate performance issues lately, , think i've understood differences of sampling vs. microstate accounting in solaris 10. don't expect both show same number. today came across occasion 2 showed vastly different outputs, have problems interpreting them , making sense of output. machine heavily loaded 8-cpu solaris 10, several large websphere processes , oracle database. system practically came halt today 15 minutes (load averages of >700). had difficulties prstat information, able outputs "prtstat 1 1" , "prtstat -m 1 1", issued shortly 1 after another. the top lines of outputs: prstat 1 1: pid username size rss state pri nice time cpu process/nlwp 8379 3208m 2773m cpu5 60 0 5:29:13 19% java/145 7123 3159m 2756m run 59 0 5:26:45 7.7% java/109 5855 app1 1132m 26m cpu2 60 0 0:01:01 7.7% java/18 16503 monitor 494m 286m run 59 1

eclipse - Figure out what Activity is currently active in Android (non-programmatically) -

a lot of time when i'm debugging app, click around , end in activity, i'm not 100% sure one. happens in latest project, inherited else. i want easy method of figuring out activity i'm in, not programmatically program know, brain. see activitymanager "displayed activity foo" in logcat, message goes away because of other logging. ideally, current activity class displayed somewhere @ times, or there similar firebug's inspect button activities. looked around ddms perspective , didn't find there either. any ideas? the hierarchyviewer fine this, perhaps bit heavy duty. try command line: adb logcat |grep "starting activity" every time start new activity there line printed.

PHP array_slice() null length results in empty array -

i have array want use array_slice remove first element of array. here's command: $myarray = array_slice($myarray, 1); now, array_slice has 4th argument, when set true, preserves array keys instead of resetting them. need option set true. the 3rd argument specify length of resulting array. supposed leave argument out if want array sliced end of array instead of specifying length. so tried this: $myarray = array_slice($myarray, 1, null, true); and results in empty array. doing wrong? there way "leave out" length argument without setting null? because setting null seems empty array completely. also, workaround this: $myarray = array_slice($myarray, 1, count($myarray)-1, true); but doesn't seem should have that... update this appears bug php 5.1.6 i tested code: $myarray = array( 'test1' => 'test1', 'test2' => 'test2', 'test3' => 'test3', 'test4' => 'test4', );

activerecord - Problem updating a record that has an association in Rails -

i'm not able update record has association in rails. for example, have post model , user model. in post.rb i've included association belongs_to :user . if want change user_id field existing post record, doesn't work. p = post.find(1) p.user_id = 5 p.save the above doesn't change post record's user_id field 5. when remove association, above code works. is there way update user_id field without removing association? thanks! tim you wrote: these examples should work reason user_id remains unchanged. maybe has validations you can verify if it's due validations replacing "save" "save!" the former returns false if of validations fail, whereas latter raise exception: p = post.find(1) p.user = user.find(5) p.save! alternatively, can following in rails console: >> p = post.find(1) ... >> p.user = user.find(5) ... >> p.valid? ... >> # either true or false, depending on validations &

html - What is a straightforward solution to vertically centering on a webpage? -

i've seen lot of discussion , debate on solutions pure css pure html. can pretty complicated, nesting divs within divs, using pretty intense looking css. figured i'd ask though, because need straightforward solution problem, , needs not rely on css tables (i.e. {display:table;} because i'm using show/hide entire div , solutions using never seem work nicely other code. how should this? i came solution. i'm not sure it's best or compatible, here is: <style type="text/css"> table.center { width: 100%; height: 100%; } h1.center { text-align: center; } </style> <div id="hide-able"> <table class="center"> <tr><td><h1 class="center">i'm centered!</h1></td></tr> </table> </div> if have better solution, please share!

iphone - Limitation in EAGLView -

can increase frame of eaglview(i setting cgrectmake(0,0,320*3,480*3) above 1024, if set frame above 1024 works correctly in ios 4.2 in ios 4.1 devices not working if set frame above 1024. do need add code 4.1? why textures not displaying in ios 4.1 devices if set frame of eaglview above 1024? updated : created sample opengl project , replaced didfinishlaunchingwithoptions following code.... works in simulator not displaying on devices < ios 4.2 . #define viewsizefactor 3 // our eaglview nees multiple of 320x480 maintain aspect ratio. - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { cgrect rect = [[uiscreen mainscreen] bounds]; [self.viewcontroller.view setframe:cgrectmake(-500, -500, rect.size.width*viewsizefactor, rect.size.height*viewsizefactor)]; //changesize [self.window addsubview:self.viewcontroller.view]; return yes; } could ios 4.2 device more recent 1 ios 4.1 device? more mod

About Wi-Fi connection after screen is locked of iPhone 3.1.3 and later -

i studied ios programming guide in ios sdk. in in "tuning performance , responsive ss" section having problem. in subsection named "using wi-fi" under above section there 1 note below: note: note when uirequirespersistentwifi has value of true, has no effect when device idle (that is, screen-locked). application considered inactive, , although may function on levels, has no wi-fi connection. according interpretation note says once screen locked of iphone there no wi-fi connection iphone. check did is, implemented 1 simple application sends 1 udp packet every 6 minutes , sleeps using usleep function of c. after starting application lock iphone button above iphone, still can send packet every 6 minute. if wi-fi connection gets closed according above note how can send packet. seen packet in wireshark, having ip address wi-fi router provided it. think documentation of iphone sdk wrong. you didn't if iphone in dock when did test. screen locked , chargi

java - How do I use getOutputStream() and getWriter() in the same servlet request? -

how use getoutputstream() , getwriter() in same servlet request? you can't use them both @ same time. if first did getoutputstream() can't consequently in same request getwriter() , vice versa. can wrap servletouptputstream in printwriter same kind of writer have getwriter() . servletoutputstream out = response.getoutputstream(); // notice encoding here, important matches of // response.setcharacterencoding(); printwriter writer = new printwriter(new outputstreamwriter(out, "utf-8")); another solution not using getwriter() use printstream similar, don't have type compatibility writer or printwriter . // encoding again important match of output. printstream print = new printstream(os, true, "utf-8");

.net - SMTP send email failure by SmtpClinet (SmarterEmail server) -

i have configured , running smarteremail server, running smtp service 25 port, configured email account. i've created simple .net application send email email server, simple: public void sendemail(emailmessage message, string username, string password, string host, int port, bool enablessl) { mailmessage mm = new mailmessage(message.from, message.to, message.subject, message.message); networkcredential credentials = new networkcredential(username, password); smtpclient sc = new smtpclient(host, 25); sc.deliverymethod = smtpdeliverymethod.network; sc.usedefaultcredentials = false; sc.enablessl = enablessl; sc.credentials = credentials; sc.send(mm); } this application failed exception: unhandled exception: system.net.mail.smtpexception: failure sending mail. ---> s ystem.net.webexception: unable connect remote server ---> system.net.s ockets.socketexception: connection attempt f

Windows 7 Phone Application XML Reading -

how read xml document in windows 7 phone application using c# here's working sample wp7 app reading xml using linq , databinding listbox. binding linq datasource listbox

regex - Counting dots with javascript returns half -

i've written small function count amount of occurrences of character within string. it's been working fine. until tried count dots, keeps giving me half number should. doing wrong? not escaping dots in right manner? function count(s1, letter) { return (s1.length - s1.replace(new regexp(letter, "g"), '').length) / letter.length; } var loc = 'http://www.domain.com/page' // i'm using window.location.href in practice. var somestringwithdots = 'yes. want. to. place a. lot of. dots.'; var somestring = 'abbbcdefg'; count(somestring, 'b'); //returns 3 - correct count(somestringwithdots, '\\.'); //returns 3 - incorrect count(loc, '\\.'); //returns 1 - incorrect just use .match , you're done: function count(s1, letter) { return ( s1.match( regexp(letter,'g') ) || [] ).length; } count('yes. want. to. place a. lot of. dots.','\\.'); //=> 6 [ edit ] in cas

add transitions to a hide/show javascript dom -

i have function (and 3 more it) function property (){ document.getelementbyid("property").style.display = "block"; document.getelementbyid("hotel").style.display = "none"; document.getelementbyid("other").style.display = "none"; document.getelementbyid("main").style.display = "none"; } how can add transition change of divs. function called on links. now shows div clicked, , hides others. old div fade out , new fade in.. thanks a popular way use jquery: $('#property').fadein(); and that's it. page http://api.jquery.com/fadein/ has demo.

c# - ASP.NET Custom membership issue with get custom membership user -No parameterless constructor defined for this object -

error throws when custom membership user object create. details error message below. error: system.configuration.configurationerrorsexception caught message=no parameterless constructor defined object. (d:\projects\sample\samplemembership\web.config line 23) source=system.web baremessage=no parameterless constructor defined object. filename=d:\projects\sample\samplemembership\web.config line=23 stacktrace: @ system.web.configuration.providershelper.instantiateprovider(providersettings providersettings, type providertype) @ system.web.configuration.providershelper.instantiateproviders(providersettingscollection configproviders, providercollection providers, type providertype) @ system.web.security.membership.initializesettings(boolean initializegeneralsettings, runtimeconfig appconfig, membershipsection settings) @ system.web.security.membership.initialize() @ system.web.security.membershipadapter.get_providers() @ system.we

java - How can I trim whitespace from request parameters in Spring MVC -

i'm struggling believe need trim leading , trailing whitespace request parameters not common requirement, , yet can't seem find has answer solving it. surely there simple way configure, say, spring webdatabinder trim whitespace parameter values before mapping them target object? i'd keen know how other people have tackled this. you can try registering custom propertyeditor in webdatabinder registercustomeditor(string.class, propertyeditor) either create 1 or use stringtrimmereditor , , instantiate set of whitespaces.

php - update memcache content -

is possible update memcached content.(i using php memcached) this current work flow: first retrieved content through db second time, same request, cache whenever action happens(i.e favourite links), flush cache , results db is possible updated content cache (if 1 record deleted, remove record cache , display cache content) never attempt flush memcache instead have single version value or such read before page fetched memcached version concatenated name of page way can both prefill cache putting new version before changing version read deliverers version can placed in memcache value fetched database if isn't present this rough summary of the secret memcached

objective c - iphone sdk 4.2: UIBarButtonItem' s are misplaced over UIToolbar -

i have installed 4.2 iphone sdk today , ran project (which written in 4.0) 4.2. noticed toolbar items misplaced on toolbar, both in ipad, iphone simulators. there else other me has encountered this? here code: @define toolbar_height 34 @define toolbar_item_width 90 // extends uiview @implementation mapviewcontrollercontainer - (void) setframe:(cgrect)frame { [super setframe:frame]; if (self.subviews.count == 2) { ((uiview *)[self.subviews objectatindex:0]).frame = cgrectmake(0, 0, frame.size.width, toolbar_height); ((uiview *)[self.subviews objectatindex:1]).frame = cgrectmake(0, toolbar_height, frame.size.width, frame.size.height - toolbar_height); } } @end // extends uiviewcontroller @implementation mapviewcontroller - (void) loadview { self.view = [[mapviewcontrollercontainer alloc] init]; [self.view release]; uitoolbar * toolbar = [[uitoolbar alloc] init];

iphone - Shrink UITableView to accommodate another small UIView -

i have uitableview inside of uiviewcontroller. want shrink length of table view dynamically in code when click on row, view slide down below , covers small part of view form bottom. using core animation able slide uiview below on top of table view want resize table view new uiview slides below not obscure of rows in table view. i tried changing height of frame of table view not working. any ideas missing here or common ways it? thanks simply setting correct frame on table view should work :-)

Sorted List in Java -

i need sort list in java below: list contains collection of objects this, list list1 = {obj1, obj2,obj3,.....}; i need final list has "lowest value" , "repetition of name should avoid". ex: list list1 = {[nellai,10],[gujarath,10],[delhi,30],[nellai,5],[gujarath,15],[delhi,20]} after sorting , need list : list list1 = {[nellai,5],[gujarath,10],[delhi,20]}; i have 2 delhi (30,20) in list. need 1 delhi has lowest fare (20). how in java? gnaniyar zubair almost same @visage answer, order different: public class namefare { private string name; private int fare; public string getname() { return name; } public int getfare() { return fare; } @override public void equals(object o) { if (o == this) { return true; } else if (o != null) { if (getname() != null) { return getname().equals(o.getname()); } else { return o.

java - @Async prevent a thread to continue until other thread have finished -

i have application number of times needs calculated. calculation function has annotation @async (from spring framework), makes possible run these calculations on 4 threads. problem need 40000 of these calculations , want know time between start , end of calculations, see time before , after for-loop calls calculation functions. calculations put in queue, loop finishes , time 1 second, while takes couple of hours calculations complete. i've tried setting max queue size 100 (also reduce memory usage) no solution since i'll miss last 100 calculations in total time takes. there way pause executing code after loop until threads have finished doing work, still being able use @async annotation? this code illustrates same problem: executing class: public class foo { public void executeblaalotoftimes() { long before = system.currenttimemillis(); (int = 0; i<40000; i++) { executebla(); } long after = system.currenttimemillis(

Convert Linq ObjectQuery IQueryable to IEnumerable -

totally confused data types required here. i have linq statement: var feat = allcustomers .select(c => c.customerservices.selectmany(cs => cs.customerservicefeatures) .selectmany(csf => csf.configelements).where(ce => ce.name == "itemtype").select(ce => ce.value).distinct()); it returns required data, , vs tells me type being set as: system.data.objects.objectquery<system.collections.generic.ienumerable<string>> however want add data list of strings: list<string> itemtypes = new list<string>(); itemtypes.addrange(feat); but throws error: argument 1: cannot convert 'system.linq.iqueryable<system.collections.generic.ienumerable<string>>' 'system.collections.generic.ienumerable<string>' i can't find required syntax cast correct type. can help? cheers, matt compile-time error shows, feat "collection of co

Model name "Query" doesn't work with rails 3? -

i using rails 3.0.3 , have model named query. when call "all" or "find" on query application (i calling user model) says "nomethoderror (undefined method `all' activerecord::attributemethods::query:module):" as checked in rails there module query in activerecord::attributemethods::query` in: activerecord/lib/active_record/attribute_methods/query.rb: but if call console, works fine. any help, information? thanks , regards, pravin. query reserved word. isn't listed in official list of reserved words , rails finding conflicting file. change model name workaround.

iphone - Releasing subviews -

i'm new @ programming ios, , experiencing problem ipad app i'm developing. using splitview controller add subview splitview's detailview every time cell in splitview's rootview tapped. fine until stack gets high , run out of memory. how can release previous subview after new view added stack? or there better way of solving problem? thanks to remove view superview: [view removefromsuperview]; the superview release view @ point. if superview actor owning reference view deallocated. put way, this: [superview addsubview:view]; causes superview retain view. see blocks of code like: view = [[viewclass alloc] initwithframe:frame]; // own view [superview addsubview:view]; // superview , both own view [view release]; // superview owns view; // it'll deallocated if // superview ever relinquishes

regex - Regular expression for matching \n and space -

i trying use regular expression within perl script parse file match: space , "\n" (newline) in alternating manner - i.e first match space "\n", space (which on new line in file... , on) thanks, -ad try this: (^ \n)+

objective c - printing a doc file using cocoa -

i'm looking simple code print contents of ms word file (.doc, .docx) using cocoa. i'm newbie cocoa. please help. mac os? doc format supported nsattributedstring, means can opened in nstextview. print doc file same print other text/rich text files. can off-screen text view if don't want force user view before printing. there example code printing off-screen nstextview on cocoadev wiki.

.net 3.5 - Assign a list of values to a struct in C#? -

i have struct (.net 3.5): struct columnheadings { public string name ; public int width ; } ; and when try assign list of values struct 'cannot implicitly convert type string/int ...': private void dosomething() { columnheadings[,] ch = new columnheadings[,]{{"column1",100}, {"column2",100},{"column3",100}}; } can struct values assigned in same way multi-dimensional array? or need assign values using?: ch.name = "column 1"; update: thanks marc's excellent feedback correct solution is: struct: struct columnheadings { private readonly string name; private readonly int width; public string name { { return name; } } public int width { { return width; } } public columnheadings(string name, int width) { this.name = name; this.width = width;

ios4 - Unable to play m4a file iPhone Device(Using iTunes affiliate search api) -

i trying play m4a(http://a1.phobos.apple.com/us/r1000/020/music/ad/41/da/mzm.fkekhvue.aac.p.m4a) file itunes affiliates using avaudioplayer can not able play it. think there issue link because have downloaded audio rename , hosted on server able play it. i have tried web-view able play it. want play using avaudioplayer. when tried data link not able correct data. also not able play using uiwebview or movieplayer(it working on simulator not in iphone device). , interesting not able play in safari app also. i using itunes affiliate search api(e.g. http://ax.itunes.apple.com/webobjects/mzstoreservices.woa/wa/wssearch?term=jack+johnson .) any idea? thanks, dipen patel i've had success using nsdata: nsdata *musicdata = [nsdata datawithcontentsofurl:previewurl]; nserror *err; avaudioplayer *player = [[avaudioplayer alloc] initwithdata:musicdata error:&err];

How to do unit testing without the use of a library? -

i've never written single unit test. since every article read, talking unit testing. figured should started it. but how? can point me simple unit tested hello world example? without use of junit or likes. if don't want use other libraries have lot of work yourself. example, suppose have class 1 function want test: class foo { public int bar(int input); } you can write test class: class testfoo { public void testbarpositive() { foo foo = new foo(); system.out.println(foo.bar(5) == 7); } public void testbarnegative() { foo foo = new foo(); system.out.println(foo.bar(-5) == -7); } public static void main(string[] args) { testfoo t = new testfoo(); t.testbarpositive(); t.testbarnegative(); } } this basic example shows how write own unit tests. that said, strongly recommend using library junit. gives lot free , removes huge amount of boiler-plate code have write yourself

html - PHP within <a> tag -

can see wrong line of code? <li><a href='<?php base_url()."company/view" ?>'view companies</a></li> just @ output: there echo , closing > missing: <li><a href='<?php echo base_url()."company/view" ?>'>view companies</a></li>

c# 3.0 - Design By Contract in C#3.0 -

i know c# 4.0 has code contract feature can used implement post-condition , pre-condition. wanting implement using c# 3.0 only. experimenting use feature in work. possible use attributes implement post-conditions , pre-conditions? any advise? thanks. you can use code contracts c# 3 , .net 3.5. main difference core classes (not tools) built .net 4 already.

javascript - Why does my object not have a constructor? -

i writing few helper classes scripting adobe illustrator. my problem starts in eyelet object. when instantiate it fails @ first new group() because apparently group doesn't have constructor. here stripped down version of code: /****************** collection class **********************/ function collection() { this.parent = app.activedocument; this.typename = "collection"; } collection.prototype.setname = function(name) { this.instance.name = name; }; /****************** group (extends collection) *****************/ function group(name, parent) { this.parent = parent || this.parent; this.instance = this.parent.groupitems.add(); if(name) { this.setname(name); } else { this.setname("group"); } } group.prototype = new collection(); /****************** shape class **********************/ function shape() { this.parent = app.activedocument; this.typename = "shape"; } sha

apache - Is there a way to not download body during Java HttpClient call when the resource is large? -

i'm trying prevent org.apache.http.client.httpclient ( link text ) downloading body when resource let's on 10 mb. what have done after searching here, , others head call, check content-length header, , if it's < 10mb, call, response body. would there better solution this? want avoid call. thanks. you can regular call , check length, , if length > 10mb break , cancel download. problem socket still download as possible before cancel. think doing head call best method.

SQL Running Total using CROSS JOIN -

need running total of table based on date , column. have following table called sales: day client 1 smith, j 3 johnson, b 6 fuller, 7 smith, j 8 johnson, b 9 lee, m i run following query: select a.day, a.client, sum(1) runningtotal sales cross join sales b (b.day <= a.day) group a.day, a.client order a.day this gives me following: day client runningtotal 1 smith, j 1 3 johnson, b 2 6 fuller, 3 7 smith, j 4 8 johnson, b 5 9 lee, m 6 but half correct. want running total based on day , client. table want looks this: day client runningtotal 1 smith, j 1 3 johnson, b 1 6 fuller, 1 7 smith, j 2 8 johnson, b 2 9 lee, m 1 don't need add client join? select a.day, a.client, sum(1) runningtotal sales join sales b on b.day <= a.day , a.client = b.client group a.day, a.client order a.day btw: approach calculating running totals

html - Problem with Div horizontal scrolling -

i have html page i'm working on. have div called "featuredcontent" i'm going add n number of elements class "item" to. want featuredcontent box scroll horizontally when exceed space in layout. sort of itunes songs. problem when try , define boxes width don't expand properly. here's rough draft of code. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <style type="text/css"> <!-- * { padding:0px; margin:0px; font-family:arial, helvetica, sans-serif; } #container { width:990px; margin-left:auto; margin-right:auto; } #header { margin-top:20px; text-align:left; overflow: auto; } #featured {

asp.net - How do I replace VS2010 javascript files -

how update visiual studio 2010 javascript files( jquery-1.4.1.*.js) current jquery.1.4.4 essentially want pull in new version of js (1.4.4) when create new asp.net web application etc. thanks it's easy deleting old jquery project , dropping in new jquery files. head on jquery.com , download version want. in addition, brian pointed out, there documentation updates included well, can things intellisense jquery in .net environment. another alternative is, if not need ship jquery project, link google cdn . way, you'll automatically receive updates , won't have worry keeping up-to-date yourself. there many advantages cdn, in environments not possible use (such on intranet application). you'll have decide yourself.

Possible to select individual values using SHOW STATUS in MySQL? -

is possible write query return value of variable returned mysql's show status? ideally want like: select `value` (show status 'com_delete') or similar. is possible? if using mysql 5.1 or above, should able data information_schema global status: select variable_value information_schema.global_status variable_name = 'com_delete'; or if want session status instead: select variable_value information_schema.session_status variable_name = 'com_delete'; the default show status session status, latter query work replacement that.

.net - Create a formatted SpreadSheet with DocumentFormat.OpenXML? -

i want create spreadsheet documentformat.openxml. i've been having hard time getting work, thought i'd ask here. i programmatically create spreadsheet @ runtime downloaded asp.net web site. (1) want spreadsheet contain rows of data sql database. want row headers consist of black text on yellow background. have string data, incidently, may contain strings of digits. want treated string @ times (ie, don't want 31415926535 presented 3.1415926e10) (2) have 300px x 300px png image appear below last row of data. image saved on server hello.png. what code need write make (1) , (2) happen? i've done similar. believe best way accomplish need first create template excel spreadsheet. then, using open xml productivity tool , reflect code needed create it. reading through limited documentation left me spinning wheels until started using productivity tool . generate extraneous code gets meat , helpful.

debugging - Serious instability with pygtk 2.22 and python 2.6 -

has come across this? i've taken gtk helloworld sample . runs fine. however, if import win32ui , not shutdown (as explained in this question ). there other problems. in process of narrowing down application see caused not shutdown, came upon point deconstructing logger class had written had no problems with. in constructor had line: self.logger = logger i had commented out rest of class self.logger not used. if left line as-is, error upon clicking "hello world" button: c:\python26\lib\site-packages\twisted\internet\gtk2reactor.py:350: gtkwarning: gtk_widget_destroy: assertion `gtk_is_widget (widget)' failed gtk.main() if change line to: self.logger = 0 then error not show up. happened various other lines of code in logger class well. suspect happen other random bits of code, too. in case - setting variable isn't used should not cause kind of problem. note @ point still using twisted pygtk. haven't reproduced yet gtk. this makes me s

Facebook Like button - Yahoo Implementation -

could tell me how done? http://l.yimg.com/p/social_buttons/facebook-share-iframe.php?u=http://www.lifehacker.com this facebook share button used yahoo in 1 of blogs. reason interested in because 1. fast. 2. has few requests facebook servers, unlink facebook iframe button. i use facebook iframe button , makes lot of requests fbcdn servers. it looks me you're asking manually tacking count on end of plain graphic: http://l.yimg.com/p/social_buttons/facebook-share-iframe.php if so, you're talking generating graphic (ie: png, can jog, well() , maybe using fb api @ current count, if you're not tracking yourself. using api isn't trivial set or use, after pieces in place, intuitive use. if you're talking doing different button, i'd advise against it. that's how facebook feature works. it's great because out of box, though have requests fb servers work.

tsql - How to calculate average date occurrence frequency in SQL -

i'm trying produce query on following table (relevant portion only): create table [order] ( orderid int not null identity(1,1), creationdate datetime not null, customerid int not null ) i see list of customerids each customer's average number of days between orders. i'm curious if can done pure set based solution or if cursor/temp table solution necessary. ;with base ( select customerid, row_number() on (partition customerid order creationdate, orderid) rn [order] ) select b1.customerid, avg(datediff(day,b1.creationdate, b2.creationdate) ) base b1 join base b2 on b1.customerid=b2.customerid , b2.rn =b1.rn+1 group b1.customerid

http - Is it faster to load files on the Web simultaneously than sequentially? -

i wanted load images site in order, found slow down total download time of site. is faster load files simultaneously, on web, rather sequentially? why? i found helpful, didn't answer question completely: http://code.google.com/speed/page-speed/docs/rules_intro.html i've found sweet spot around 4 sequential downloads. more , don't see improvement in speed. need define 4 different sub-domains grab files. browsers don't download multiple files same server.

php - unable to decode JSON -

i 'm passing json encoded url php generated through flash program here when trace myobject=%5b%7b%22fullname%22%3a%22jon%20jay%20junior%22%2c%22role%22%3a%22admin%22%2c%22username%22%3a%22jjj%22%7d%5d at php end $jsonstring = urldecode($_post['myobject']); $jsonstring = str_replace("\\", "", $jsonstring); $data = json_decode($jsonstring); print_r($data); but nothing doing wrong here? code in flash var people:array = new array(); var person:object = new object(); var url:string = "http://localhost/ping.php"; var request:urlrequest = new urlrequest(url); var requestvars:urlvariables = new urlvariables(); var loader:urlloader = new urlloader(); person.fullname = "jon jay junior"; person.username = "jjj"; person.role = "admin"; people.push(person); request.method = urlrequestmethod.post; requestvars.myobject = json.encode(people); request.data = requestvars; loader.load(request); trace(request.data);

jquery - JavaScript- find text within a page and jump to location in page -

i have webpage large list of records (say 250+ rows of data in table) , want able visit page, start typing, , have jump me first row matches text have typed. ideally, if continued type more characters first match doesn't match anymore, continue respond input , jump me new match. i've tried window.find() haven't had success... can reccomend working solution? i'm looking equivalent hitting 'ctrl-f' on keyboard... except without need hit ctrl-f make happen. i think tricky part of accepting of user input intelligently. therefore, i'd best thing pass off searching autocomplete-type plugin. once page ready, pass focus input text box, , let plugin magic search... for example, use quicksearch plugin. then given table of data , input this: <input id="searcher" type="text" name="searcher"> you have ready function looks this: $('#searcher').quicksearch('table tbody tr', { 'dela

Can I make auto complete to android's default Searchbar? -

i'm trying autocomplete android's default search dialog doesn't seem work. impossible do? after research found yes can done , here's how it's done: http://developer.android.com/guide/topics/search/adding-custom-suggestions.html

iphone - Core Plot generating a flat line, X or Y range incorrect? -

Image
i using core plot plot 2000 data points. load fine, see smooth line: i not sure why flat line rather showing graph of of values in large range. have done wrong setting plot space? cpxyplotspace *plotspace = (cpxyplotspace *)graph.defaultplotspace; plotspace.allowsuserinteraction = no; plotspace.xrange = [cpplotrange plotrangewithlocation:cpdecimalfromfloat(0.0) length:cpdecimalfromfloat(num_points)]; plotspace.yrange = [cpplotrange plotrangewithlocation:cpdecimalfromfloat(0.0) length:cpdecimalfromfloat(num_points)]; here numberforplot method well: -(nsnumber *)numberforplot:(cpplot *)plot field:(nsuinteger)fieldenum recordindex:(nsuinteger)index { nsnumber *num = [sortedarray objectatindex:index]; return num; } any ideas doing wrong here? there couple of different issues here: the plot space ranges given in data coordinates. can either calculate ranges or use plot space method -scaletofitplots: calculate them automatically. see answer your relate

MS MapCruncher - Silverlight Bing Maps -

is there version of mapcruncher works silverlight bing maps? not ajax version. i want overlay pdfs (floor plans) onto map. the standard version of mapcruncher , bing maps silverlight it. quick google gets lots of hits, example, here's 1 of more useful (also follow link chris pietschmann's article): http://social.msdn.microsoft.com/forums/en/vemapcontroldev/thread/8f1d38e6-12a4-4f3e-88e9-074206806cc0 the output mapcruncher useful - i've been able use google maps v3.

javascript - jQuery.ajax not working in IE7/8 -

something in script breaking ie. i'm looking on collection of links class, , hijacking url's. clicking link animate height , reveal message. ajax request mark message read. however, in ie goes url instead of staying on page , processing http request. $('.message .subject .subject_link').click(function(e) { toggle_message(e) return false; }); function toggle_message(m) { var link = m.target; var parent = $(link).parent().parent(); console.log(link.href); $.ajaxsetup({ url: link.href, datatype: 'json', timeout: 63000, type: 'get', cache: false }); if($(parent).hasclass('unread')) { $(parent).addclass('read').removeclass('unread'); $.ajax({ complete: function(r, textstatus) { console.log(r.responsetext) } }); } if($(parent).find('.body_wrapper').hasclass('collapsed')) { $(parent).find('.body_wrapper').addclass('

OpenGL ES 2.0: attribute not bound on vertex shader -

i'm developing android application. i have following vertex shader. "attribute vec4 vertexposition; attribute vec4 vertexnormal; attribute vec2 vertextexcoord; varying vec2 texcoord; varying vec4 normal; uniform mat4 modelviewprojectionmatrix; void main() { gl_position = modelviewprojectionmatrix * vertexposition; normal = vertexnormal; texcoord = vertextexcoord; } "; and fragment shader: precision mediump float; varying vec2 texcoord; varying vec4 normal; uniform sampler2d texsampler2d; void main() { gl_fragcolor = texture2d(texsampler2d, texcoord); } "; is there problem if left vertextexcoord unbound? think must use different vertex , fragment shader if model doesn't have texture, isn't? thanks. yes should have shader models without texture. otherwise, think experience implementation dependant behavior. related that, opengl documentation says: active attributes not explicitly bound bound

jquery - Jcarousel ajax - how to (ajax) load image before the slide? -

i love jcarousel, method allow nice image slide preload images, , want save bandwidth , page loading time. my goal: - first step should load , display single image. no second image should loaded - when click on next or prev occurs, want image added via ajax, have slide effect. in other words, able display regular single image on page, until user click of prev or next button. way if there no click no useless image loaded. anybody have tried before ? i have implemented jcaraousel, i load 4 images per page , when user click next 4 images.do following 1) no of images want 2) when user clicks next , swap existing image src next one. if want give loading effect , give default loading gif image background image those.we implemented same @ ...www.allposters.com , please check if want working demo.

Why is TUI used in stores? -

in many big stores/rental/service companys system using managing customers , looking products based on text user interface (tui). there reason why choose tui on gui or old systems? from experience, it's old systems. if old system still works, many companies don't see why should spend lot of money tui replaced gui.

database design - Designing For Lookup Values -

i wondering protocol in development shop or project dealing lookup values, such countries of world or states in united states of america. i have seen done in 2 different ways: @ 1 place worked our lookups stored in database table prefix "l_" , had following columns: id, code, desc, ordersequence. so, example, countries of world have table like: create table l_countries( countryid int identity(1,1) primary key, countrycode varchar(10) not null, countrydesc varchar(50) not null, ordersequence int null ) more have seen example lookups baked enumerations, example: enum countries { croatia = 1, slovenia = 2, serbia = 3, // , on } in event these originating database table, there utility generate c# code enumeration. otherwise takes time hardcode entries using assumption values not change . numeric values in enumeration, hardcoded based on id column in corresponding lookup table in database if exists, or hardcoded based on entry s

wxpython wx.EVT_LEFT_DOWN -

hey general wxpython mouseevent question.. if in wx.evt_left_down handler , suppose other mouse event in wx if dont call event.skip() window goes buggy , clicks dont register other widgets. event.skip() must every mouse event in wx? thanks no, event.skip() isn't required. point of allow parents receive event. if want parents receive event, use event.skip(), if don't, don't use it; depends on application. see this link . one thing keep in mind (for generalization of question) event propagation different wx.event , wx.commandevent. see this link more.

Silverlight Update Feature, this feels oh so wrong. Where is ReportProgress or a separation between CheckForUpdate() and Update() -

i've created line of business out of browser application. i need more control on update process. i initiate updating screen, on start-up when download of update has started, , deactivate app. far know, have no way tell if worker in progress. nice if reportprogress available or similar. maybe there , i'm totally missing it. great if progress bar based on bytes downloaded. right way can remotely this, waiting couple seconds, , if checkanddownloadupdatecompleted event hasn't fired, know downloading??? show intermittent progress bar, , wait complete. luckily 1 of business requirements start-up splash screen. i'm betting work... man feel ooooh wrong, there has better way. suggestions? nope you're not missing checkanddownloadupdateasync , completed event sum total passes upgrading api in silverlight. sounds have reasonable plan. you might interested in silverlight toolkit busyindicator control. in addition delivering progress bar requir

c# - Refactoring an eConnect method that uses a single stored procedure -

i'm writing program modify invoices in gp10 using econnect. of invoices require distributions reset because totals not add correctly due various other (not important question) processes; accomplished through program. additionally, of invoices moved different batch (think buckets if you're not familiar gp), using program. both of these tasks accomplished processing same type of file through econnect. method processes file: public bool persistallchangesindynamics() { //instantiate proper econnect object updating invoice. econnecttype econnect = new econnecttype(); soptransactiontype transtype = new soptransactiontype(); transtype.tasophdrivcinsert = this.converttosophdrivcinsertxml(); //adjust fields reset distributions. transtype.tasophdrivcinsert.updateexisting = 1; transtype.tasophdrivcinsert.createdist = 1; soptransactiontype[] updateinvtypearray = { transtype }; econnect.soptransactiontype =

jquery - getting rel attr of link and using as text recurring -

i'm trying rel attr set of links in slider, use text control. i've got working except lists first rel multiple times, instead of multiple rels once. my jquery is jquery("#slider li a").each(function() { var yearvalue = $(this).attr('rel'); jquery('#controls li a').text(yearvalue); }); and output html is <div id="slider"> <ul> <li><a rel="foo" href="#"><img src="image1.jpg" alt="alt" /></a></li> <li><a rel="bar" href="#"><img src="image2.jpg" alt="alt" /></a></li> </ul> </div> <ol id="controls"> <li id="controls1" class="first"><a href="javascript:void(0);" rel="0">foo</a></li> <li id="controls2" class="current"><a href="javascript:voi

algorithm - How to choose randomly in a certain ratio -

i want choose randomly* between 2 alternatives unequal probability. for instance, when user presses button, 25% of time make sound , 75% of time, sound b. can manually easy ratios 1:4 , 2:4 i'm having trouble ratios 3:5. what generic way think this? *i mean unpredictable when looked @ one-by-one. notice question word random in gets mensa of pedants . for 3:5 can add them 8, , pick random integer less 8. if it's 0, 1, or 2 (three chances) choose a, , if it's 3, 4, 5, 6, or 7 (five chances) choose b. code-wise you'd check whether random number less 3. for 3:5:4, you'd pick random number less 12 (3+5+4) , if it's less 3 choose a, otherwise if it's less 8 (3+5) choose b, otherwise choose c. this can generalize number of alternatives, it's inefficient lots of alternatives since have check random number against each threshold, o(n). this question seems provide more efficient (but more complex) algorithms weighted random sele

html - Errors on my page when I try to use CSS -

line 8, column 23: document type not allow element "style" here if try take line out format isnt correct, if leave in http://validator.w3.org/check gives me error. can explain or maybe give me correct way of doing this. <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title>randy's first html web page !</title> </head> <style type="text/css"> body h1 { background-color:#6495aa; margin-right:1350px; } h2 { background-color:#b0c4de; margin-right:1350px; } p { background-color:#649fff; margin-right:1350px; } div { background-color:#efffff; } </style> <h1> hello professor</h1> <h2> by: randy white</h2> <p> haven't done before.</p> <p>seems ok</p> <table border="1"> <tr> <th>month</th> <th>day</th> <th>

.net - FTPS (FTP over SSL) in C# -

i need guidance. need develop customizable ftp in c# should configured using app.config file. also, ftp should push data server client again depends on config file. i appreciate if can guide, if there api or other useful suggestion, or move me in right direction. you can use ftpwebrequest ; however, low level. there higher-level class webclient , requires less code many scenarios; however, doesn't support ftp/ssl default. fortunately, can make webclient work ftp/ssl registering own prefix: private void registerftps() { webrequest.registerprefix("ftps", new ftpswebrequestcreator()); } private sealed class ftpswebrequestcreator : iwebrequestcreate { public webrequest create(uri uri) { ftpwebrequest webrequest = (ftpwebrequest)webrequest.create(uri.absoluteuri.remove(3, 1)); // removes "s" in "ftps://". webrequest.enablessl = true; return webrequest; } } once this, can use webclient normal, exc

mouseevent - Android mouse simulator -

i have android running on dev board. how can simulate mouse pointer in that? i have application sends (x,y) coordinates running deamon. should able simulate tap @ corresponding point on touch screen. can suggest ideas , feasibility of ? you can emulate such events using monkey tool it supports running in daemon mode accepting commands, see details , samples in android repository

sed - Swapping two lines -

how can make use of sed h , h , x , g , g etc. commands swap 2 lines? for example in file start dog cat else end say want swap "this dog" "this else". this have far: /this dog/{ h # put hold space } /this else/{ # stuck on do. } if know pattern on each of 2 lines want swap, not full contents of lines, can this: sed -n ' # turn off default printing /dog/{ # if line matches "dog" h # put in hold space :a # label "a" - top of loop n # fetch next line /something/{ # if matches "something" p # print x # swap hold , pattern space bb # branch out of loop label "b" } # done "something" # if we're here, line doesn't

c++ - Where is the Makefile generated by the Eclipse CDT? -

i've built hello world c++ project eclipse(helios) cdt. compiled fine. take @ makefile cdt generated. can't find in project folder/debug/release folders or in src folders. can find makefile? if use default setttings current builder = cdt internal builder , there no make file. if select current builder = gnu make , see makefile in debug folder.

joining images of different dimensions in matlab -

if have 2 images of different dimensions....than can have window size equal sum of sizes of 2 images, means window( size)=size of image1+size of image 2 , paste these mages on window show them jointly .....is possible?if yes how from description sounds want construct block-diagonal matrix 2 images, since size of result sum of sizes (along each dimension). way use blkdiag function: img1 = randn(70,100); img2 = randn(50,110); img = blkdiag(img1,img2); imshow(img) of course off-diagonal blocks padded zeros. edit: answering refined question, have pad shorter image zeros becomes @ same height longer image. can concatenate them side side. assuming img1 longer , like: h1 = size(img1, 1); [h2, w2] = size(img2); img2a = [img2; zeros(h1-h2, w2)]; img = [img1, img2a];

c# - Hooking Direct X Endscene in Direct X 11 game -

i have memory reading in game , injection. however, avoid race conditions, need inject asm code endscene. previously have used code: uint d3d9_device; d3d9_device = memory.read<uint>(memory.baseaddress + direct3d9__device); d3d9_device = memory.read<uint>(d3d9_device + direct3d9__device__offseta); d3d9_device = memory.read<uint>(d3d9_device); d3d9_device = memory.read<uint>(d3d9_device + direct3d9__device__offsetb); to access dx9 device, , find endscene using reversed offsets. however, in windows 7, directx 11 forced, means read fails , gives null object. any idea how might perform hook endscene of game when directx 11 in use? you should iat hooking getprocaddress , calls d3dcreate, capturing device pointer , hooking vftable there. dunno how 'reversed the com vftable offsets(these predefined how com dlls build, need count virtual methods defined in dx sdk headers, start @ 0, multiply by sizeof(int_ptr)` offset), way reading them looks