Posts

Showing posts from August, 2012

ruby - How do I test DelayedJob with Cucumber? -

we use delayedjob run of our long running processes , test cucumber/webrat. currently, calling delayed::job.work_off in ruby thread work done in background, looking more robust solution what best approach this? thanks. the main problem see delayed:job.work_off approach making explicit in cucumber scenarios belongs internals of system. mixing both concerns against spirit of functional testing: when click link # operation launched in background , jobs dispatched # delayed:job.work_off invoked here should see results... another problem populate cucumber scenarios repetitive steps dispatching jobs when needed. the approach using launching delayed_job in background while cucumber scenarios being executed . can check cucumber hooks using in link.

ruby on rails - update_attributes not working for many-to-many nested attributes -

i have nested attributes in models such: class employee < activerecord::base has_one :user, :as => :user_role, :dependent => :destroy accepts_nested_attributes_for :user, :allow_destroy => true end class user < activerecord::base has_one :person, :as => :person_role, :dependent => :destroy belongs_to :user_role, :polymorphic => true accepts_nested_attributes_for :person, :allow_destroy => true end class person < activerecord::base has_many :address_person_links, :dependent => :destroy has_many :addresses, :through => :address_person_links, :uniq => true, :dependent => :destroy belongs_to :person_role, :polymorphic => true accepts_nested_attributes_for :addresses, :allow_destroy => true end class addresspersonlink < activerecord::base belongs_to :address belongs_to :person end class address < activerecord::base has_many :address_person_links, :dependent => :destroy has_many :people, :through =...

C# Homework. I am looking for an explanation of what is going on -

forgive me asking might think stupid questions. trying read code below , make sense out of it. why novel.title used in main. understand title why novel.title used. other 1 holding title information entered user. same questions author, , level. using system; using system.collections.generic; using system.text; namespace assignment6 { public class book { protected string title; public string title { { return title; } set { title = value; } } protected string author; public string author { { return author; } set { author = value; } } public void showbook() { console.writeline("the book entered " + title + " " + author); } public book(string booktyp1, string booktyp2) { console.writeline("you enter data " + booktyp1 + " book indic...

.net - Azure Table Storage Performance from Massively Parallel Threaded Reading -

short version: can read dozens or hundreds of table partitions in multi-threaded manner increase performance orders of magnitude? long version: we're working on system storing millions of rows in azure table storage. partition data small partitions, each 1 containing 500 records, represents day worth of data unit. since azure doesn't have "sum" feature, pull year worth of data, either have use pre-caching, or sum data ourselves in azure web or worker role. assuming following: - reading partition doesn't affect performance of - reading partition has bottleneck based on network speed , server retrieval we can take guess if wanted sum lot of data on fly (1 year, 365 partitions), use massively parallel algorithm , scale number of threads. example, use .net parallel extensions 50+ threads , huge performance boost. we're working on setting experiments, wanted see if has been done before. since .net side idle waiting on high-latency operations, seems pe...

javascript - Is this a browser cache problem? -

can check if browser cache problem? i have scenario, have table displays data , below link sends url. 1 row can click @ time. <table> <thead> . . </thead> <tbody> <tr> <td><input type=""checkbox" value="1" name="_chk"/></td> <td>field1</td> <td>field2</td> </tr> </tbody> </table> <a href="/myapp/url.htm" id="mylink">change</a> on click of link, adding current click id href attribute using jquery $(document).ready(function(){ $("#mylink").click(function(){ var transid = $("input[name='_chk']:checked").val(); var currhref = $(this).attr("href"); $(this).attr("href", currhref + "?transid=" +transid); }); }); on first click, ok , transaction id get...

How do I use the .send method for a dynamic class to go to the specific path in Rails? -

i using following: send("#{done_event.class.name.tableize}_path", done_event.id) an example done_event specific instance of contactemail. i represent path contact_email_path(done_event.id) translate contact_emails/1 however, result contact_emails.1 not sure do...? i error when try pass in object: http://localhost:3000/contact_calls.%23%3ccontactcall:0x9fefb80%3e this seems trick: send("#{done_event.class.name.tableize.singularize}_path", done_event) although if polymorphic worked, use that.

javascript - How to write the php code in js file -

is program divide pages div in first div added code <?php $table="am_users"; $query="select distinct(`user_email`) $table"; $result=mysql_query($query); $num_rows = mysql_num_rows($result); while($data1=mysql_fetch_array($result)) { $data[]=$data1['user_email']; } sort($data); foreach($data $search_term) { $js_data[] ="\"" . $search_term . "\""; } <script type="text/javascript"> var collection = [<?php echo implode($js_data, ","); ?>]; </script> ?> below include css file division 1 working in division 2 css not applied . problem due div 1 had js variable value if remove var collection = []; statement css working fine . possible pass value php file js file on loading time save file .php instead of .js , add header("content-type: application/javascript"); . @ b...

c# - Entity Framework/SQL2008 - How to Automatically Update LastModified fields for Entities? -

if have following entity: public class pocowithdates { public string poconame { get; set; } public datetime createdon { get; set; } public datetime lastmodified { get; set; } } which corresponds sql server 2008 table same name/attributes... how can automatically : set createdon/lastmodified field record now (when doing insert) set lastmodified field record now (when doing update) when automatically , mean want able this: poco.name = "changing name"; repository.save(); not this: poco.name = "changing name"; poco.lastmodified = datetime.now; repository.save(); behind scenes, "something" should automatically update datetime fields. "something"? i'm using entity framework 4.0 - there way ef can automatically me? (a special setting in edmx maybe?) from sql server side, can use defaultvalue , work insert's (not update's). similarly, can set default value using constructor on poco's, again work...

php - Different Drupal front page from different country -

i have drupal site, , want redirecting visitors different page based on country. have code: require_once "net/geoip.php"; $geoip = net_geoip::getinstance("net/geoip.dat"); try { $geocode = $geoip->lookupcountrycode($_server['remote_addr']); } catch (exception $e) { $geocode = 'en'; } switch ($geocode) { case 'hu': header('location: http://www.example.com/hu'); break; case 'gb': header('location: http://www.example.com/en'); break; case 'at': header('location: http://www.example.com/at'); break; case 'cy': header('location: http://www.example.com/cy'); break; case 'de': header('location: http://www.example.com/de'); break; case 'nl': header('location: http://www.example.com/nl'); break; case 'ch': heade...

debugging - Need to get List of C++ Kernel Types? -

respectfully!! i need complete list of kernel types such "critical_section", "_large_integer" or "_security_attributes". extracting data members of class given class name type debugging sdk (right using dia sdk or dbghelp) . now if type(say class or struct) contains kernel level objects mentioned above, extract(details of type e.g data member , types ) types well. i need block extraction of kernel level objects , types. need types user defined , contains data members having native types of again user defined types (like int, float, double ,char,std::string or can someudt obj). is there other way out...? regards usman check latest docs windows kernel dev

java - Sum of the maximum downsequence number in an array -

given array int [] myarray = {5,-11,2,3,14,5,-14,2}; you find maximum sum of values in downsequence in unsorted array of integers. if array of length 0 maxseqvalue must return integer.min_value. you should print number, 19 because downsequence maximum sum 14,5. downsequence number series of non-increasing number. these codes used guess there cases still not accounted for. ideas, in advance. public class maxdownsequence{ public int maxseqvalue(int[] a){ int sum=integer.min_value; int maxsum=integer.min_value; (int i=1;i<a.length;i++){ if(a[i]<a[i-1]){ sum = a[i] + a[i-1]; if (sum>maxsum){ maxsum=sum; } } else { sum=a[i]; if (sum>maxsum){ maxsum=sum; } } } if (a.length==0){ return integer.min_value; } else{ return maxsum; } } public static void main(string args[]){ maxdownsequence mys...

c# - Is there such a control in ASP.NET that can render HTML during runtime? -

like preview box below take input textarea typing now. the requirement retrieve html saved in database , preview on screen. should use label or there better control around? i use literal control unless need "extra" html.

localization - Localized Splash screen in iPhone -

is possible have different image different language splash screen in iphone ? you can localize default.png file localize other. way, depending on device language appropriate default.png used. might add, splash screens highly dissuaded in hig, default.png should first screen give illusion app starts faster. haven't heard of apps being rejected due splash screen on other hand. edit you can not add kind of custom behavior decides default.png use. either localize file or use default.png no text in it.

javascript - 'var' is null or not an object -

the code works fine in firefox, not in ie8. i'm getting error: 'address' null or not object. have been googling days , couldn't clear answer on how fix/debug this. hope stackoverflow.com can help. var latlng = [ { address: new glatlng(-6.1364941,106.8000411), marker0: myicon0 }, { address: new glatlng(-6.1364941,106.8000411), marker0: myicon0 }, { address: new glatlng(1.3520831,103.8198361), marker0: myicon0 }, { address: new glatlng(14.06666671,121.33333331), marker0: myicon }, ]; var markers = []; ( var = 0; < latlng.length; i++ ) { var marker = new gmarker( latlng[ ].address, latlng[ ].marker0 ); map.addoverlay( marker ); markers[i] = marker; } $(markers).each(function(i,marker){ gevent.addlistener(marker,"click", function(){ // map.panto(marker.getlatlng()); map.setcenter(marker.getlatlng(), 10); marker.openinfowindowhtml($('.view-display-id-attach...

delphi - Suggestions for caching a dataset -

i'd perform following: 1) open dataset (using tmsquery, sdac devart component) 2) caching content disk (imagine list of cutsomers) 3) next time need open dataset first populate cached data, refresh calling tmsquery.refreshquick method. in way plan obtain substantial improvement in speed, because don't need retrieve records retrieved in previous application runs. how can obtain caching? have many datamodules tmsquery, somehow have global routine checks everytime try open tmsquery, if query somehow tagged try restore cache, call refreshquick, in case fails call open. can please suggest? (i use delphi 2009 , sdac 4.80) you can use tclientdataset , tdatasetprovider components this, connecting components in way. tmsquery->tdatasetprovider->tclientdataset the tclientdataset alternative persist , retrieve data disk. see these links more info clientdataset using midas clientdataset replacement cached updates a guide using tclientdataset in...

c# - Windows Application in future to be controlled over browser -

i writing windows application using c#. planning on later allow controlled on intranet using browser also. in future should able control both using local interface or on intranet browser. is there pre-defined architecture allow me this? methods of achieving this? new c#/.net. edit: the windows application needs access communication ports extensively, , needs pretty stable , run days together. thanks... i can't tell if specific package exists ease development. but, if attempt it, after googling , not finding available , meeting needs, make application wcf host. create service entry points accept control messages remotely. need well-know location register application remote system find it. should sure provide user way of disabling application remote control feature. your host interface need run on own thread remain performant. since new c#, , presumably windows forms application development, need read on how talk gui controls non-gui thread. alternativel...

resize textarea to fit in a fluid width layout with javascript -

i have fluid layout , need textarea expand/reduce depending of size of parent container. in css this: textarea{ width: 100%; } but doesn´t work textareas. how can javascript? can parent element width , them calculate number of cols fit width how know size of 1 col (in px)? chk out : http://css-tricks.com/box-sizing/ textarea { -webkit-box-sizing: border-box; /* safari/chrome, other webkit */ -moz-box-sizing: border-box; /* firefox, other gecko */ box-sizing: border-box; /* opera/ie 8+ */ }

c# - Faulting application <app_name>, version <version number>,faulting module kernel32.dll -

i have 1 windows application built using c# , .net framework 2.0 , installed on windows server 2003. i have tested application on machine , works on machine. difference between 2 machines that, machine has windows vista os , machine on error occured has windows server 2003 os. when start application, works correctly time gives 1 error faulting application , version ,faulting module kernel32.dll,version 5.2.3790.4480, stamp , debug? 0. fault address 0x000bef7. source : .net runtime 2.0 error category : none event id : 1000 does knows why error coming? googled error of solutions either explorer.exe or internet explorer. use windbg or adplus attach process , process crash dump. identify offending part of code symbols loaded. in cases, shows last exception , hence gives view of have gone wrong.

css - Wordpress: adding active class to wp_nav_menu items -

in wordpress (3.0.1), if use gui update main menu include item called news: ** url: /news/ navigation label: news title attribute: news ** the news item shows in menu. great. when click on , navigate /news/ page, wordpress not add current_menu_item class <li> . nor give <li> menu item id or name of "news" - instead it's called unhelpful "menu-item-899". why doesn't wordpress add current_menu_item class? surely has information needs this? </grumble> and given above, how can style <li> item show current item? don't want have use jquery @ page name , match arbitrarily-named ids... option? you use css style : /*.current-menu-item controls active state on nav menu */ #primary-menu ul li.current-menu-item a, ul li ul li.current-menu-item { color:#663; }

html - Need help with iFrames -

i have iframe : <iframe width="985px" frameborder="0" marginheight="0" marginwidth="0" height="2100px" src="http://www.myblog.com/search?q=<?php echo $plus ?>searhed"></iframe> now in iframe want add button ( or that,can image),that navigate previous page person browsing. its want add "back" , "forward" functions in browser iframe. thanking you. take @ javascript function history.back()

svn - Finding List Of All Checkin's By User Using TortoiseSVN -

i ve used tortoise svn , cant seem able find list of checking username - know if possible? you can filter author in log window, showing commits made author. there search box in log window, can choose search, choose author , write name.

c# - Please tell what approach should be used for desktop application -

i planing develop desktop application have multiple logins , according login type options/from view displayed. i have done database login part turn of view how can establish have in mind that drag , drop required controls , make them visible = false , check type of login , display accordingly create separate forms , display 1 one required for me depends on numbers. if u have many diffrent user roles , share few controls easier make diffrent form / panel each user type. approach quite dangerous since when want change common control u forced in forms / panels. thats why recommend group application logic custom controls , build gui them. for example: if have 2 user types ( let's boss , employee ) can build form shared controls / logic , 2 user controls (bosscontrol, employeecontrol) functions boss , employee. after login check add matching user control gui.

oop - Using Android's TabActivity in an Object-oriented manner -

i'm new object-oriented programming, , i'm interested in learning correctly. problem this: i trying create tabactivity plots user's data on time in each tab's content. thing tabs going control timespan of graph. (i.e. 1 tab 'past year', 1 'past month', 1 'all time', etc). can see, layout used each tab identical. code used each tab differ couple lines... (the starting , ending date of x-axis). i'm not sure how can pull off in well-designed, object-o fashion. ideas? ok...as far know can give try : make on super class extends acitivity.. particular class have acitivity life cycle methods. now make child class a1 extending class (since activity, a1 acitivity) can start activity in tab 1. make child class a2 extending class (since activity, a2 acitivity) can start activity in tab 2. make child class a3 extending class (since activity, a3 acitivity) can start activity in tab 3. don't forget declare activities a1, a...

asp.net - Is this IIS configuration possible, and if not, what would you suggest? -

is possible configure iis website provide domain credentials asp.net application if user logged particular domain, , use anonomous if coming in internet? will need seperate virtual directories, 1 domain , 1 anon only? i have application follows different code paths depending on wether or not user autenticated against intranet domain, need allow login attempts outsite intranet, site hosted outside of intranet. looks if anon access on use that, , need setup 2 virtual directories.

jquery - how to avoid repetition of data for a repeated dropdownlist input? -

i have webpage should relatively lightweight, problem i've got table editable user data on each line , data includes dropdownlist hundreds of options. i've argued against use of values guess wasn't able come satisfying solution; ginormous dropdownlist stuck (we're talking 35kbytes of options per drop down list, here) it doesn't mean data has got there each drop down list, though, , i've been looking ways manage without hassle. i've been considering: filling selected drop down list data on click creating empty drop down lists , 1 full drop down list swap selected 1 when applicable forcing line editable after click on edit command. i'd avoid 1 since think should minimize number of clicks user creating fillable field smaller drop down list attached. user either type word , select nearest match or directly select shorter list i'm trying keep lists empty possible because table should wrapped eventual jquery plugin render sortable, , sw...

dependency injection - Asp.net MVC 3 inject UserControl for TemplateHint -

is possible somehow leverage dependency injection in asp.net mvc 3 (using forms viewengine) inject usercontrols library? using mef load other stuff mvcapplication. i need because want build system expandable type system. want type vendor able inject custom controls provided type. have custom metadataprovider knows how handle provided types (it sets modelmetadata.templatehint property). the question can plug in mef, templatehint gets handled, , custom control dispalyed upon caling html.editorformodel i can't think of way using current service locator infrastructure in mvc 3 beta. can think of 2 alternative appraoches though: have editor template instead of rendering html delegates custom controls , returns output. write own viewengine can perform lookups partial views (the paths of form "editortemplates/yourtypename" etc.) , return view knows how talk custom controls.

MVC, WCF ASP.NET 4.0 & JQUERY -

i've spent past few days getting frustrated wcf, i've decided post on here because.. well.. don't have clue start!.. appreciated! firstly: when creating wcf service in .net 4.0, template should use if want able create service accept data ajax post using jquery? (i'd able have global.asax if possible). secondly: service works fine in wcf test client, when manage accept requests, test client stops showing service methods. post methods seem refuse work outright. i'd develop wcf service run on iis server can hook 1 of applications via jquery ajax call. if has tutorial point's me in right direction, appreciated havn't been able find on wcf using .net 4, works. cheers the first thing should consider same origin policy restriction. if not able comply , web service not hosted on same domain consuming ajax script may stop reading answer here , rethink architecture. if still reading start defining service contract , implementation usual: [s...

Extending Struts ActionServlet and RequestProcessor -

can tell me scenario in should extend actionservlet class , requestprocessor ? have read in struts documentation can done, don't understand in situation. regards, aashutosh the actionservlet , requestdispatcher main players in struts framework. actionservlet treats requests made struts application , delegates "heavy lifting stuff" of handling request requestprocessor object. in struts application have operations performed creating action classes, each action taking care of own different stuff. though wish perform common operations actions logging or security , don't want them performed inside each action class you? mean lot of code duplication, have place common behavior somewhere above individual actions. the actionservlet , requestprocessors make candidates sort of stuff. sure, write filter actionservlet , requestprocessors contain code related framework there not point in starting scratch when can reuse exists , extend it. the subject of ext...

nhibernate - Dependencies in Acceptance Testing -

me , co-worker having debate. on craptastic legacy project , adding acceptance tests. believes should doing work in gui/watin using low level library query database directly 'end end' test puts it. we using nhibernate , advocate using gui/watin nhibernate objects assertions in acceptance testing. dislikes dependency of nhibernate in test. assertion have/should have integration tests against nhibernate objects make sure working db way intend @ point there no downside in using them in acceptance test assert proper operation. think low level sql dependence make tests fragile , duplicate business logic in alot of cases. integration testing in our shop means single component dependency e.g. filerepository/filesystem domain-nhibernateobject/database. acceptance testing means coming in through gui. unit means dependencies have/can mocked/stubbed out , you've got pure test in memory method under test doing real work. let me know if defs off. anyway articles/docs/parchment...

c++ - modf returns 1 as the fractional: -

i have static method, receives double , "cuts" fractional tail leaving 2 digits after dot. works almost time. have noticed when receives 2.3 turns 2.29. not happen 0.3, 1.3, 3.3, 4.3 , 102.3. code multiplies number 100 uses modf divides integer value 100 , returns it. here code catches 1 specific number , prints out: static double dround(double number) { bool c = false; if (number == 2.3) c = true; int factor = pow(10, 2); number *= factor; if (c) { cout << " number *= factor : " << number << endl; //number = 230;// when not marked comment code works well. } double returnval; if (c){ cout << " fractional : " << modf(number, &returnval) << endl; cout << " integer : " <<returnval << endl; } modf(number, &returnval); return returnval / factor; } it prints out: number *= factor : 230 f...

php - Should I name my actual controller files the same as my view files in Codeigniter? -

i'm writing first codeigniter site using mvc pattern. i'm building controllers load views (haven't gotten models yet) i'm noticing view , controller files have same filename (like products.php). in respective folders of course. example have controller, loads view, both of named about.php. have products controller loads products view both named products.php. practice? from reading , studying seems names models differently, products_model.php, makes easy distinguish, can't recall seeing doing different controllers , views. am setting myself headache down road when site develops more? thank you! what when writing codeigniter sites creating folder same controller name in views and if have method called index(), it'll view: /views/controller_name/index.php. in controller can this: $this->load->view('controller_name/index'); can load file inside folder.

Declaring a type synonym in C# -

i hope missed in docs. there way declare type synonym in c#? you can use using statement create alias type. for example, following create alias system.int32 called myint using myint = system.int32; alternatively, can use inheritance in cases. example create type people list<person> public class people: list<person> { } not quite alias, simplify things, more complex types this public class somestructure : list<dictionary<string, list<person>>> { } and can use type somestructure rather fun generic declaration. for example have in comments, tuple following. public class mytuple : tuple<int, string> { public mytuple(int i, string s) : base(i, s) { } }

stream - How to show feedback while streaming large files with WCF -

i'm sending large files on wcf , i'm using transfermode="streamed" in order working, , working fine. the thing files big, , want give client sort of feedback progress. does have godd solution/idea on how acomplish this? edit: don't command read of file in either side (client or server) if did give feedback on read function of stream. edit2: part of code others understand problem here's contract [operationcontract] filetransfer update(filetransfer request); and here's definition of filetransfer [system.servicemodel.messagecontractattribute(wrappername = "filetransfer", wrappernamespace = "http://tempuri.org/", iswrapped = true)] public class filetransfer : idisposable { [system.servicemodel.messagebodymemberattribute(namespace = "dummy", order = 0)] public stream filebytestream; public void dispose() { if (filebytestream != null) { filebytestream.close(); ...

inheritance - Multiple superclasses in Objective-C? -

can inherit multiple classes in objective-c? (if yes, how so?) as others have said, objective-c single-inheritance. however, protocols provide handy ways around type of situation might have wanted multiple inheritance , allow avoid pitfalls multiple inheritance creates such the diamond problem . edit: changes interface protocol. sorry, getting java , obj-c mixed up.

jquery - markitup settings issue -

Image
here settings in set.js. don't want h1 - h3 tags, images etc. deleted lines markitup text area appears not settings , shows following. using textile set basic simple skin. also, there sprited version of images? mysettings = { previewparserpath: '', // path textile parser onshiftenter: {keepdefault:false, replacewith:'\n\n'}, markupset: [ {name:'heading 4', key:'4', openwith:'h4(!(([![class]!]))!). ', placeholder:'your title here...' }, {name:'heading 5', key:'5', openwith:'h5(!(([![class]!]))!). ', placeholder:'your title here...' }, {name:'heading 6', key:'6', openwith:'h6(!(([![class]!]))!). ', placeholder:'your title here...' }, {name:'paragraph', key:'p', openwith:'p(!(([![class]!]))!). '}, {separator:'---------------' }, {name:'bold', key:'b', ...

ruby - Nokogiri and XML Formatting When Inserting Tags -

i'd use nokogiri insert nodes xml document. nokogiri uses nokogiri::xml::builder class insert or create new xml. if create xml using new method, i'm able create nice, formatted xml: builder = nokogiri::xml::builder.new |xml| xml.product { xml.test "hi" } end puts builder outputs following: <?xml version="1.0"?> <product> <test>hi</test> </product> that's great, but want add above xml existing document, not create new document. according nokogiri documentation, can done using builder's with method, so: builder = nokogiri::xml::builder.with(document.at('products')) |xml| xml.product { xml.test "hi" } end puts builder when this, however, xml gets put single line no indentation. looks this: <products><product><test>hi</test></product></products> am missing format correctly? found answer in nokogiri mailing list...

c# - Implementation of Interface Invalid -

i've been trying make module, command-line-like application. each module can hold multiple commands. example, "module a" can have commands "exit" , "echo". i'm using following code load , initialize modules... foreach (string filename in directory.getfiles(path.combine(appdomain.currentdomain.basedirectory, @"modules"), "*.dll")) { assembly asm = assembly.loadfrom(filename); foreach (type asmtype in asm.gettypes()) { if (asmtype.getinterface("icommandmodule") != null) { object commandobject = activator.createinstance(asmtype); icommandmodule commandmodule; if (commandobject icommandmodule) { commandmodule = (icommandmodule)commandobject; } else { throw new exception("commandobject not valid icommandmodule."); } ... i know fact module lo...

loops - Walking a tree backwards in SQL -

i have table simple schema: create table q( orig integer not null, dest integer not null, cost float, primary key (orig, dest) ); i need walk table backwards in cost minimizing way. let me explain. i need tour of 15 points, point can orig or dest . algorithm backtracking last dest initial orig . here how spell out: given final dest , find orig link said dest minimum cost . corresponding orig becomes new dest ; loop on 15 times. let's assume know last dest number 10 . sql statement allows me find orig leading dest in cost- minimizing way is: select orig q cost = (select min(cost) q dest = 10); now use orig returned above function find previous point (assume returned, say, point 5 ): select orig q cost = (select min(cost) q dest = 5); i can go on until have 15 points. how make efficient query in sql? table has 50 million rows. here's query assumes you're using sql server 2005+. uses common table expressions (cte). example...

c++ - How do I test for user input for equations? -

i have equation 4 variables, prompting user enter each 1 of these variables, , program decides based on variables entered, variables needs solve for. instance, given variable , b, need solve b , c. trying come way program decide variables have been entered, , ones have not been. have been thinking far: int a,b,c,d; char unknown; cout<<"****this program decides variables solve for****\n; cout<<"please enter known variables below, if variable unknown, please enter a'?'\n" cout<< "please enter variable a\n"; cin>>a; cout<< "please enter variable b\n"; cin>>b; etc.... if (a =='?'){ check b,c,d} if (b =='?'){ check c,d} and running variables through if statements determine variables present , aren't. there has easier way though, these if else if statements have potential ridiculous. if of have advice appreciated. thanks! the pseudo-code you've posted won't work, bec...

Applying Class to Customer Zend Decorator -

i found code change standard dt , dd tags table tags zend_form_element. here code used: $element->setdecorators(array( 'viewhelper', 'errors', array(array('data' => 'htmltag'), array('tag' => 'td', 'class' => 'element')), array('label', array('tag' => 'td', 'class' => 'rightalign')), array(array('row' => 'htmltag'), array('tag' => 'tr')) )); puts class name 'rightalign' on label tag instead of td. can't seem wrap head around these custom decorators can tell me how class name 'rightalign' on td surrounding label? just add 1 more decorator $element->setdecorators(array( 'viewhelper', 'errors', array(array('data' => 'htmltag'), array('tag' => 'td', 'class' => 'element')), 'labe...

once you select an item on a multiselect html listbox, is there anyway to deselect all -

my users can't seem deselect on select in html. have basic multiselect listbox in html: <select class="longdropdown" id="selectedcalendars" multiple="multiple" name="selectedcalendars"> <option value="13">er</option> <option selected="selected" value="26">billy 123</option> <option selected="selected" value="28">new cal</option> </select> if few items start out selected, can change clicking on others remove selection, there doesn't seem way user deselect them all. have write jquery / javascript code programatically. flaw in html ui spec? on macos, user can ⌘ + click on last selected item deselect it. on other platforms, user use ctrl + click instead.

msbuild - MSBUILDEMITSOLUTION not working with .NET 4? -

in prior versions of msbuild, set environment variable named msbuildemitsolution 1 xml version of solution (.sln) file parsed. according msbuild team blog , that's still in version ships visual studio 2010, not seem working. has managed working msbuild 4.0? if so, required? (we use find , run convention-based unit tests nant script.) set msbuildemitsolution=1 , build command line. should see mysolution.sln.metaproj file near mysolution.sln. notes: if open command prompt window set env var via sysetm settings have open new command prompt. you'd think use msbuild /p:msbuildemitsolution=1 , can't.

objective c - IPhone App Crashes on Device -

i have simple app (this first one) loads image resources folder, change image (with image name changing): myuiimageview.image = [uiimage imagenamed:@"nextimage.jpg"]; it runs on app can change image infinite number of times. when run on ipod touch, crashes after image changes 4 times. need release image when change it? seems memory issue, i should mention each image 200kb. the console reads when crashes: program received signal: “0”. data formatters temporarily unavailable, re-try after 'continue'. (unknown error loading shared library "/developer/usr/lib/libxcodedebuggersupport.dylib") any advice help, thanks! when runs well, mean runs on simulator? i've found not check memory problems on simulator: tends way powerful compared actual device. crash may not on image swapping code @ all. i recommend go on code , check leaks. monitor using instruments->leaks while running on device, not on simulator.

python: how to convert currency to decimal? -

i have dollars in string variable dollars = '$5.99' how convert decimal instead of string can operations adding dollars it? there's easy approach: dollar_dec = float(dollars[1:])

how do python capture 302 redirect url -

i try fetch data web,but page use 302 redirect how can use python fetch real url? have @ chapter 11.7. handling redirects dive python series. explains entire issue in quite bit of detail, example code , all.

c# - HttpWebResponse LastModified -

is httpwebresponse.lastmodified accurate? present? project create sort of focused web crawler , stucked if use hash value of resource or httpwebresponse.lastmodified property check resource's "freshness". using hash value means streaming resource every time it's checked. has big impact on overall performance. if check httpwebresponse.lastmodified, accurate? httpwebresponse.lastmodified returns value of http last-modified response header. http response headers set http server sending response. it's server if sets last-modified response header, , whether sets accurate value or not. the last-modified response header part of validation model caching in http. used in conjunction if-modified-since request header. might want read http/1.1, part 6: caching details.

sql - Adding minutes to datetime on insert - mysql -

i've tried this insert products (product_id, product_type, created_dt, end_dt) values ('11', '1', '2010-10-08 00:11:10', date_sub(2010-10-08 00:11:10, interval 59 minute)) but doesn't work. other ways within mysql? thanks! use: insert products (product_id, product_type, created_dt, end_dt) values (11, '1', '2010-10-08 00:11:10', date_add(str_to_date('2010-10-08 00:11:10', '%y-%m-%d %h:%i:%s'), interval 59 minute) ) on mysql 5.1.49, wouldn't add/subtract because wasn't implicitly converting string datetime data type. had use str_to_date explicitly convert string datetime . otherwise, mysql workbench returns blob ...

Accessing session variable in Django template with Google App Engine (Webapp) - Python -

i have django template front-end. @ back-end, used sessions provided gaeutilities store variable (email). front-end: {% if session.email %} <div id="entersite">welcome <em>{{session.email}}</em></div> {% else %} <div id= "entersite"><a href="/login/" id= "entersite">enter site</a></div> {% endif %} back-end: self.session = session() self.session['email'] = email temp = os.path.join(os.path.dirname(__file__),'templates/index.htm') outstr = template.render(temp, {}) self.response.out.write(outstr) problem: how access stored session on server side , use on django template (front-end)? anybody can give update on qns? you need set session object in django template context, no? template.render(temp, {'session':self.session})

Oracle XML Parsing Vs Java XML Parsing -

i have situation choose between parsing xml documents in oracle pl/sql , parsing them in java. system receives xml documents on message queue , xml documents not on file system, unless write them filesystem after reading queue. and, intent of parsing insert/update records in bunch of database tables. which 1 better option performance stand-point? it's competition between pl/sql , many possible java parsers. it's of java parsers beat pl/sql on performance. some other reasons go java parser: license costs less. you're not chained particular database. your solution has more deployment options. however if need extract information xml and insert oracle database, advantage might go pl/sql. in case might worthwhile prototype both approaches , see. consider development time needed each: if number of bytes of xml coming system relatively small, pick solution that's fastest implement.

javascript - How to use onclick on a iframe tag -

how use onclick in iframe tag call javascript. i want redirect other page when user clicks on iframe.i have added facebook button site iframe code. once has clicked on button want him redirected thank page edit: don't want redirect iframe want redirect main page on interactivity iframe. on solution on focus or or on click on iframe should able redirect. can @ least it. you can't that. facebook's xfbml elements (like 'like' button) on different domain own (and function way); using javascript modify frame isn't possible due security restrictions.

javascript - Simultaneous Clock Ticks -

i'm using jquery clock demonstrate time in application. in application,there two different browser windows 1 of these triggers other pop window. in these 2 windows,i'm using jclock instances,but somehow these clocks don't both tick one. http://plugins.jquery.com/files/jquery.jclock-1.2.0.js.txt $(document).ready(function () { $('#clock').jclock({ format: '%d %b %a %y %h:%m:%s' }); }); <div id="clock"></div> why these clock not simultaneous ? how can achieve ? thank you it's because jclock uses timeout interval of 1000 ms update clock view, without aligning updates 0th millisecond. i can think of 2 workarounds: don't directly initialize jclock inside popup let parent window initialize both own , popup's jclock instances. maybe way, clocks run sync. in both main window , popup: read current milliseconds , set timeout expire after current milliseconds % 1000 ms. when timeout expires, initiali...

mysql - SQL: get the place in results query -

i have table called 'points' has field 'total' contains total points record. calculate rank of specific record. so like: select (...) rank points id=63 is possible in sql? count rows points higher + 1 , total rows.

Dotnetnuke - How to move my project to root directly? -

i have installed dotnetnuke in sub directory, , completed project. how can move project root directory? there many hard coded links in project. how can change directory without issues? please me!!!! the engage f3 module free , allows search , replace in html modules replace hard links.

msysgit - How to sign off a patch using git -

i'm working on project people sent me git patches , i've verify patches , sign off commits. we creating patches using git format-patch master --stdout > file.patch and file mailed us, we've verify patch. creates new branch , applies patch using git apply file.patch then verifies contents of commit, if correct need add sign off each commit patch. i've seen git -am command can add signoff @ time of applying patch. is possible add commit after applying patch? thank you is possible add commit after applying patch? well, yes, make changes , create new commit.

cocoa - Custom dash style in NSBezierPath -

is possible create custom dash style nsbezierpath? i.e. want line of say, arrows pointing in direction of stroke. for example, this... ->--->--->--->---> any ideas appreciated.. mt not way depicted - "dash style" given in "line visible/line not visible" segments. won't "custom brush" type of effect nsbezierpath is.

ruby - Given a String and an array of Strings, how do I efficiently calculate the occurrences of the array in String? -

let's assume text string , contains text. tags array of strings. text = <<-eos lorem ipsum dolor sit amet, consectetur adipisicing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. eos tags = [ "some", "in", "dolor", "laborum", "missing" ] the algorithm should return tags contained @ least once in text . in example above [ "in", "dolor", "laborum" ] the resulting array not required sorted. also, don't need know number of occurrences of each tag in text . i came few solutions, none of them convinced me. suggestion? text.gsub!(...

iphone - Can We Change the UITableViewCell TextColor when we are selecting the Cell? -

i having default tableviewcell not customizing it. want change textcolor when selecting tableviewcell can it. in uitableviewcell can uilabel .textlabel , set highlightedtextcolor property. mycell.textlabel.highlightedtextcolor = [uicolor blackcolor];

python - quick question: clear an attribute of a model in django -

i think pretty easy question you. want clear attribute of django-model. if have this: class book(models.model): name = models.textfield() pages = models.integerfield() img = models.imagefield() in abstract function want clear attribute, @ time don't know type field has. examples name="" , pages=0 or img=none .. there way in generic way? search set_to_empty(book,"pages") do know function that? many in advance! i don't think there clean way of doing it. however, assuming you've set default value (which don't have) can this: book.img = book._meta.get_field('img').default do note current model won't allow none value. allow have set null=true , blank=true . pages need default=0 .

cakephp - Fatal error: Call to undefined method CookieComponent::del() -

hi have strange error in code. want make cookie system cakephp, , in app_controller.php include var $components = array('auth', 'cookie'); var $helpers = array('html', 'form', 'session'); but everytime click on logout link error appears. function function logout() { $cookie = $this->cookie->read('user'); if($cookie) $this->cookie->del('user'); $this->session->setflash('logout'); $this->redirect($this->auth->logout()); } where can solution? thank dude the method name delete , not del , hence error. see http://api.cakephp.org/class/cookie-component#method-cookiecomponentdelete

javascript - document.getElementById('grand_total_display').innerHTML = "Total is : $"+variable; is displaying error in IE6 and IE7 -

Image
document.getelementbyid('grand_total_display).innerhtml = "total : $"+variable; displaying error in ie6 , ie7 i have <li> with id grand_total_display text displayed in it. <li class="bannerprice" id="grand_total_display">total price : $0</li> i executing jjavascript function insert other value it.. displayed error given below: please me rectify issue apparently there's no element in dom 'totaldisplay' id, or, galambalazs suggests, might have multiple elements same id. with ie7 can use "internet explorer developer toolbar" , "web development helper" plugin, find problem.

java - Packaging Javascript files in a war? -

i developing servlet based java project packaged war using maven. there way can include javascript (js) files along project (they should available @ url when project loads on tomcat server). i have looked around have not found working solutions. maybe better solution stick maven convention, specifies root directory of web application src/main/webapp . so if put javascript files in src/main/webapp/javascript (or src/main/webapp/js ), integrated in final war package. in maven war plugin, give descriptions (see here example) content of directories. example: |-- pom.xml `-- src `-- main |-- java | `-- com | `-- example | `-- projects | `-- sampleaction.java |-- resources | `-- images | `-- sampleimage.jpg `-- webapp |-- web-inf | `-- web.xml |-- index.jsp `-- jsp `-- webs...

dependencies - Maven dependency -

hi have quite simple question maven dependency. have 2 modules of 1 project. first module dependent on second. second module has dependencies on libs. second module can installed standalone app. when build project first war contain packaged second module libs second module depends on. i need when package first module second module should included without it's dependencies. how possible manage? thx i need when package first module second module should included without it's dependencies. how possible manage? somehow, hint dependencies of 2nd module provided when gets packaged inside war. iow, declaring dependencies of 2nd module provided scope it, wouldn't pulled transitively. depending on how create standalone distribution of 2nd module, might need combine dependencies scope profiles, or not. can't since didn't :) references dependency scope

winforms - When I add a new Form in the Ide, it gets default properties, but I always use a different font and a different background color -

adding new form in project creates default form default properties. have change them manually, in project have same properties (font, background color, etc.). is there way can change default ide template forms? not using inheritance adrian recommended mistake. right way because can in 1 fell swoop change every form in app editing base form properties. but want change template. that's easy well. start new scratch project 1 form , change properties want have customized. click file + export template. select item template, next. tick form, next. next. give name , description , click finish. can select template whenever create new form.

linux - Linking to wrong library version in a C++ application -

i'm troubleshooting c++ binary on rhel/centos 5, has problems openssl shared libraries. don't c/c++ programming, , i'm having trouble finding root issue. what seems going wrong application linking specific versions of libcrypto , libssl (0.9.8), instead of symlinked paths of /lib/libcrypto.so.6 , /lib/libssl.so.6 . since openssl libs have been updated since compiled, it's broken. ldd shows following 2 problems binary: libcrypto.so.0.9.8 => not found libssl.so.0.9.8 => not found [edit] obtained source, , built correctly. i'm going have go simplest possible explanation, build machine misconfigured non-standard libraries, , makefiles fine. a couple suggestions (i'm assuming have no way of getting new binary links new versions of ssl libs): get old versions of libs previous version of package , keep them around binary (you put them somewhere out of /usr/lib , load them program ld_library_path). force loading new versions of libs ld_p...

email - Broken PHP contact form script -

i'm trying make contactform. , somehow won't work. tried send email mail()-function , works. i'm doing wrong , don't know what. when click on submit button, refer mailer.php file. both file in same folder. <?php if(isset($_post['sendbutton'])) { $to = "contact@domain.com"; $subject = "contactformulier portfolio"; $name_field = $_post['yourname']; $email_field = $_post['youremail']; $message = $_post['yourmessage']; $body = "from: $name_field\n e-mail: $email_field\n message:\n $message"; echo "data has been submitted $to!"; mail($to, $subject, $body); } else { echo "there has been error, try again please!"; } ?> without seeing code, guess condition mailing never met because there no value set submit button. try making condition emailing this: if($_post) { mail here } else { error case }

c# - DataGridView first column,first row, is selected on Load, I don't want this -

so first column in first row selected, can't figure out way have gridview has no selected cells. help? i had same issue , nothing working. solution worked me setting 'tabstop' property false , calling clearselection() method after data bind.

c# - Need a numeric only windows control TextBox -

this question has answer here: how make textbox accepts numbers? 29 answers i creating old-school dialog in c# using system.windows.controls.textbox . there easy way of limiting text input in box numeric only? thanks! just implement onkeyup event handler , if key pressed not character.isdigit clear it. http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.onkeyup(vs.95).aspx

The best solution to keep files in database (Rails) -

i know best way save binary files 'in database'. of course on disk files, need 'link' them in db. great solutions? use paperclip attach file model. say have mortgage has document class mortgage < activerecord::base has_attached_file :document end later: mortgage = mortgage.find(params[:id]) document = mortgage.document paperclip used images, works types of files. can store on s3 well.

android - Logging inside Framework? -

i trying develop small application reset logging on phone. can 1 throw lights on how achieve logging in andriodruntimeinit whenever there exception? want write file whenever there runtime exception. it recommended use android's built in logging via log . can access log via adb logcat , don't have worry else.

c# - Transferring data from XML to SQL -

i have created 1 xml file..... node : <patient>kanna</patient> <id>12</id> and transferred values sql db. using c#.net now added 1 more value in same xml file <patient>kanna</patient> <id>12</id> <patient>raja</patient> <id>13</id> question : how append new value sql db.... can u suggest me idea ? thanks in advance:-) question : how append new value sql db.... answer is: how did first value... im not sure question clear btw.

Software alternatives to Google Search Appliance (GSA) -

i interested in software alternatives google search appliance (gsa) use in (large) university context. has experiences of migrating gsa alternative solution? if so, reasons doing (technical, financial, staff effort, etc) , have experiences been positive? i recommend looking apache solr , imho best scalable, feature-rich search server out there. f/oss out-of-the-box solution apache software foundation , used organizations such netflix, aol, cnet etc. had used gsa in our company year before moving solr. move relatively painless compared benefits accrued. since integrates restful interface can integrated platform of choice without language/platform tie-ins. give whirl!

What is the optimal LDAP Query or Queries for searching for users by name? -

given input free-form search field, need query ldap system , return user records. our ldap schema includes "preferredname". possible valid inputs include: "lastname", "givenname", "preferredname lastname", "lastname, preferredname", "givenname lastname", etc., including such variations multiple-word last names (with or without hyphens). our current less-than-optimal process splits out individual words, makes assumptions order (based on presence or absence of comma) , makes several simple ldap queries (e.g.: "john smith" submit following queries: (&(objectclass=person)(sn=*smith*)(preferredname=*john*)) (&(objectclass=person)(givenname=*john*)(sn=*smith*)) we amalgamate , de-dupe results of multiple queries. single-query solution preferable, if query complex. basic understanding of ldap query syntax, string every possible permutation of name words 1 gigantic query, i'm hoping there's more ele...

python - Getting implicit property names on a db.Model in Google App Engine? -

how can access implicit property names of db.model in google app engine? in particular, assume have following: class foo(db.model): specific = db.integerproperty() class bar(db.model): foo = db.referenceproperty(foo, collection_name = "bars") if attempt property names on foo, so: my_foo = foo(specific = 42) key, prop in my_foo.properties().iteritems() print "here bars won't show up" then my_foo.bars property doesn't show up. or totally mistaken? any appreciated edited model python, not ruby (that model definition looks strange hybrid of python , ruby.) i'm not clear on you're trying achieve here, can list of model property members using introspection: [x x in dir(foo) if isinstance(getattr(foo,x), db.property)] if you're trying add instances of bar foo, should create new bar instances foo fields pointing @ foo instance: foo = foo(specific=42) foo.put() bar(foo=foo).put() bar(foo=foo).put() logging.info(...

subprocess - Debugging a Windows Service and trying to see what it sees -

we have automated system runs service processing satellite images. service maintains configuration file, in configuration file apply scripts(python) covnert input satellite imagery more usable format. scripts call required applications, conversion proces. scripts invoked service via system("command") (its written in c/c++). (the service uses same account user). we trying add support satelitte imagery format, converter commerical .exe erdas imagine(importavhrr), (we several of our own steps after in script change projection). the script works fine, until hits this: argslist = ['importavhrr.exe', '-in', '%s' % infn, '-out', '%s' % tmpimg1, '-gui', 'false', '-correct', '-flyingheight', '833', '-rect', 'gcp', gcpfn] print "".join(argslist) p = subprocess.popen(argslist, shell=true, stderr=subprocess.pipe, stdout=subprocess.pipe) print str(p.communicate()) what en...

flex datagrid columns drag -

i have data grid users can drag columns , reposition them. there strange requirement columns should not draged left of other column. eg, assume columns : name, price , start date, end date, the end date should not dragged , placed before start date. i.e. user can have start date, price , name , end date. name, start date, price , end date. but @ no point can end date appear before start date. is there way flex? there way know user trying drop column , show error message ? the solution involves work around. first use advanced data grid instead of data grid. then create column group , add start date , end date columns it. then set childrendragenabled="false" in column group. thats work around. sample code below. solution (notice childrendragenabled="false" ): <mx:advanceddatagridcolumngroup childrendragenabled="false"> <mx:advanceddatagridcolumn datafield="startdate" /> <mx:advanceddatag...