Posts

Showing posts from April, 2010

c# - Calling static method on a generic class -

this question has answer here: how access static methods of generic types 3 answers i have generic class program static method below: class program { public static void main() { console.writeline("hi program"); console.readline(); } } when try access static main method inside generic class program1 below: class program1<t> : program t : program { public static void check() { t.main(); } } i error : 't' 'type parameter', not valid in given context however if use public static void check() { program.main(); } everything runs fine. can please explain mistake might committing? when program1 : program , telling program1 instances not of type program1, of type program, because inherits it. but when program1<t> , telling pr

c# - Some updates are discarded out of a method -

i have set of objects inherits 1 baseobject have global primitive properties (indexes etc). now, have 2 objects, 1 of them (the target one) have values base properties , other (the source, 1 of set of objects) have values other properties (retrieved 3rd party app), base one's. i'm trying copy source object's properties target one, keep target's base properties' values. in other words – i'm trying equal 2 object's properties' values without deleting anything… target = source; delete target's base indexes… so, made method gets arguments 2 objects (casted baseobject) , copy target's indexes's values source befor copy, this: public void copy(baseobject source, baseobject target) { //copy primitive indexes here... source.index = target.index; source.reference = target.reference; etc… //copy updated object target one... target = source; } it seems ok in debug mode inside method, – when code exits method surpri

oracle adf - How to print log in ADF mobile -

i have followed step in http://docs.oracle.com/cd/e35521_01/doc.111230/e24475/debugging.htm and emulator connected server. have try every code displaying error. log not printed. used following code displaying log. system.out.print("test new"); trace.log(utility.applicationlogger, level.severe, test.class, "activate", "!!!!!!!!!!feature 1 activate!!!!!!!!!!"); adf.mf.log.application.logp(adf.mf.log.level.warning,"myclass","mymethod","my message"); utility.applicationlogger.logp(level.warning, test.class.getname(), "ontestmessage", "embedded warning message 1"); logger.getlogger(utility.app_logname).logp(level.warning, this.getclass().getname(), "ontestmessage",

c# - Adding list in list -

i have class sellstatement public class sellstatement { public long billno public datetime paymentdate; public list<string> productname; public list<double> quantity; public list<double> rateperquantity; } when trying access function getsaledetails public exception getsaledetails(list<sellstatement> lss1,string query) { try { (int = 0; < lss1.toarray().length; i++) { query = "select * [product details] [bill no]=@billno"; com = new sqlcecommand(query, con); con.open(); com.parameters.addwithvalue("@billno",lss1[i].billno); sdr = com.executereader(); while (sdr.read()) { lss1[i].productname.add(sdr.getstring(1));//exception line lss1[i].quantity.add(sdr.getdouble(2)); lss1[i].rateperquantity.add(sd

php - Can not get the id from the cart session -

i'm working on homework. have cart session , can on attribute in mysql database base on product id. <?php $total_price=0; if(isset($_session['cart']) ? $_session['cart'] : null) { echo "<tr> <th></th> <th>product</th> <th>price</th> <th>quantity</th> </tr>"; foreach ($_session['cart'] $key => $product) { $the_query = "select * products id=" . $product->id; $the_product = $db->query($the_query) or die('query failed: '.mysql_error()); $the_product->execute(); $the_product->setfetchmode(pdo::fetch_obj); while ($row = $the_product->fetch()){ $total_price = $total_price + $row->price*$product->quantity; echo "<tr><td>"; echo "<img src='".$row->image_url_small."' /></a></td>"; echo "<

trace - Using Tracepoints in GDB to track how often code is executed -

i want count how function or line of code executed during test run. idea set tracepoint using gdb @ line , count how tracepoint hit. can tell me if/how can achieved. functions can find tracepoints take snapshots of registers or save values of variables. think answer might related passcount value, don't know how implement want. if more info or detail needed, please let me know, thanks, dave below question/answer provides nice trick count. think solve problem without ambiguity. hth!

php - SELECT records WHERE rows have difference on a specific column -

i have database table campaign_data . need select customer_id in campaign there difference in tariff. how can mysql query. here sample data. sql fiddle schema | campaign_id | customer_id | campaign_name | tariff | --------------------------------------------------------- | 1 | 1 | richmond | 100 | | 2 | 1 | sutton coldfield | 75 | | 3 | 1 | putney | 100 | | 4 | 1 | kentish town | 100 | | 5 | 1 | woking | 100 | | 6 | 2 | chiswick | 90 | | 7 | 2 | ealing | 100 | | 8 | 2 | camden | 100 | | 9 | 3 | croydon | 75 | | 10 | 3 | croydon1 | 100 | | 11 | 3 | archway | 100 | | 12 | 4 | ealing0 | 100 | | 13 |

expression trees - Output of C program -

this question has answer here: why these constructs (using ++) undefined behavior? 12 answers int a[]={10,20,30,40}; int x=0; int v=a[++x]+ ++x + a[--x]; printf("%d",v); what output of program?? completely confused output. no way going done according operator precedence knowledge. according me, in expression array subscripting [] has highest precendence , should executed first. both [] should executed first left right. in case value of x increment first, decrement , come 0. expression become int v=a[0] + ++x + a[0] . pre increment having highest precedence , incremented 1. our expression become int v=a[0]+1+a[0] . final output 21. but not case. have checked on different compiler implementations , no 1 prints 21. i surprised because value printed 43, no understandable me. that's why want me understand , come result 43. the link others have s

iphone - How to acces data in a relation using parse.com -

i using parse.com, , have in data browser following tables: user (the default user table) , studyyears. in user table, have multiple users. have added user table column of relation type refers table called studyyears. studyyears table contains string column called year. how can make query user values year column of studyyears table? i hope can understand trying get. in advance! http://blog.parse.com/2012/05/17/new-many-to-many/ states: when fetch place object, objects in relations won’t fetched, huge win relationship large number of objects. without fetching objects in relation, can add objects relation using add:. if wanted fetch objects in relations, like: pfrelation *relation = [place relationforkey:@"likes"]; pfquery *query = [relation query]; [query findobjectsinbackgroundwithblock:^(nsarray *results, nserror *error) { // results contains people liked sid's bbq. }];

css - Dynamic image resize -

i saw nice homepage on templatemonster , im trying make homepage alike , problem main image. wont scale same way , have no idea should search . have searched dynamic picture cant find anything. the site image script: http://livedemo00.template-help.com/wt_43701/#!/pagesplash try resize window , see image shrink , parts of image move outside window. the site im working on is: http://dq.se/formbar/ main image has 1 tag , is width:100%; please me find way image has min-height: 500px; , if window gets smaller image cut on sides. / axel well if have min-height:500px; try overflow:hidden; hide rest of picture after shrinking 500px little fiddle : here

navigation - concrete5 loop child pages of parent -

i'm new concrete5 , need loop out child pages of parent (the parent not being current page needs parent slug passing argument). i'd expect simple i've found on relates autonav. can't use autonav due site navigation being in non-standard format. the solution doesn't need print markup - fine generate php array of slugs , titles can loop markup. i'll take either way :-) in advance! if want some markup, , want displayed on sort of page, check out page list block: http://www.concrete5.org/documentation/editors-guide/in-page-editing/block-areas/add-block/page-list/ if need pages programmatically, there's pagelist model can pass parent page , children array of page objects. https://github.com/concrete5/concrete5/blob/master/web/concrete/core/models/page_list.php

hibernate - Populate OneToMany relationship in Criteria -

i have entity auditlog holds one-to-many relationship auditparameter : @entity public class auditlog implements iauditlog, serializable { // ... @onetomany(targetentity = auditparameter.class, mappedby = "auditlog") private list<iauditparameter> parameters; } the auditparameter of cause has @manytoone(targetentity = auditlog.class) private iauditlog auditlog . i fetch auditlog records relationship list fetched. tried following: session session = ((entitymanagerimpl)em.getdelegate()).getsession(); criteria audits = session.createcriteria(auditlog.class) .setfetchmode("parameters", fetchmode.join); but generates left outer join . can explain why generates outer join , how accomplish eagerly load auditparameters parameters collection?

javascript - how to get clicked a href link on mouseover? -

how clicked href link on mouseover? i want clicked link on mouseover what have make link clicked on mouseover this code: <a href="www.example.com">link</a> try : <a onmouseover="this.click();" href="...">link</a>

asp.net - Paypal adaptive payment return url is calling twice -

i have implemented paypal adaptive payment method , using web flow. after making payment, when explicitly clicks on return button, return url calls twice if wait auto redirect calls once only. i not able understand why return url calling twice. please advice. i using below code. public static actionoutput maketransactionusingpaypal(paymentdetails payment, shopcart shop_cart) { receiverlist receiverlist = new receiverlist(); receiverlist.receiver = new list<receiver>(); string action_type = "pay_primary"; decimal amnt_to_admin = ((shop_cart.totalamounttobepaid * 10) / 100); /*total amount admin account */ receiver rec1 = new receiver(shop_cart.totalamounttobepaid); rec1.email = config.adminpaypalbusinessaccount; rec1.primary = true; /*amount after deducting admin commision seller */ receiver rec2 = new receiver(math.round((shop_cart.totalamounttobepaid - amnt_to_admin), 2, midpointrounding.toeven)); rec2.email = p

database - Is banks overdraft penalty linked to technology limitations? -

i have been reading article data consistency in banking operations . author highlights fact that, differently common thinking, banks adopt base (basically available, soft state, consistent) transactions assure high availability service. in nutshell, transactions written down in different partition allow quick response, , database consistency performed afterwards. instance, when withdraw money atm, aim money possible. so, transaction operation stored separately, money released , afterwards take care apply transaction database , make consistent. because of technical limitation in communication: wouldn't possible provide responsive service if acid (atomicity, consistency, isolation, durability) transactions used. of course means there may inconsistencies: money withdraw can more available ones, , have no way know in advance, before transaction made consistent. , here comes overdraft penalty , fee pay " over-withdrawing ". question is: did banks introduce " ov

codeigniter - Dialog box showing ajax success response disappears immediately -

i uploading both data , files in 1 form using ajax in codigniter , displaying ajax success response in dialog box, dialog box disappears immediately, not showing result few minutes.. here code.. $(function(){ $("#pushform").submit(function(){ var formdata = new formdata($(this)[0]); $.ajax({ url:'<?=base_url()?>addpush', type: 'post', data: formdata, async: false, success: function (response) { document.getelementbyid('ajaxresult').innerhtml=response; $('#result').dialog({ autoopen: true, height: 300, width:500, modal: true, duration: 5000 }); $('#dialogalert').hide(); $('#sample').load("<?=base_url()?>pushnotify"); }, cache: false, contenttype: false, processdata: false }); return false; }); please me solve problem did u check line: $('#dialogalert').hide();

c - Is this a portable way to make a stack buffer eight-byte aligned? -

struct { uint64_t a; char z[120]; } b; ... struct buffer_with_alignment_requirement* c = (struct buffer_w*)&b; c->start_using_it; without first member a , might crash when accessing fields in buffer. portable , correct add member force aligment whole struct strict enough? this not question pointer aliasing, whether address of b on stack eight-byte aligned. it depends on mean aligned. if want (uintptr_t)&b % 8 == 0 , there no portable way obtain this, conversion pointer integer implementation-defined , need not sane, natural mapping. if want buffer sufficiently aligned access type uint64_t , solution works well. why don't use (possibly array of) type struct buffer_with_alignment_requirement , rather ugly union hackery? in other words, give buffer right type intend access begin with. can pass pointer type read , fread , revc , etc. , other functions might using write buffer, , if you'll passing function expects buffer pointer of type char * or

How expensive is the "key" function of a Ruby hash? -

i'm using couple of hashes values of hashes key of others. i need use key couple of times key value can use access in hash. i wondering kind of performance impact possibly have. in situation, these hashes few in number , contents small, want know theoretically. should avoid using much? how perform compared getting value key? think of way: you're doing step value. that's happens time use conditional test , add couple steps computation. it's obvious there's little overhead associated it, worrying @ point premature optimization. can feel difference, using benchmark class test alternate way of getting hash key, vs. normal way. i suspect you'll have several million loops see appreciable difference. here how create reverse mapping mentioned @fontanus: hash = {a:1, b:2} hash.merge!(hash[hash.values.zip(hash.keys)]) which results in: { :a => 1, :b => 2, 1 => :a, 2 => :b } it can done coercing hash array,

latex - emacs AUCTeX macros fontification -

i started using excellent package xargs provides \newcommandx . shares syntax similar default \newcommand . font-lock reflect this. did (custom-set-variables '(font-latex-user-keyword-classes (quote (("cx" ("newcommandx" "*|{\\[[{") (:family "font-lock-type-face") command))))) but fontifies command name itself, not body ( \newcommand fontifies body 'font-lock-function-name-face , in case bold). want \newcommandx fontify body 'font-lock-function-name-face . to summarize question: how make fontification \newcommandx same \newcommand (i.e. bold body in case)? here example can modify suit needs. see lines 280 436 of font-latex.el within auctex-11.86 complete list of predefined keywords. following examples used add additional keywords, and/or define own coloration contents of wavy / square brackets. ;; \effect{[font-lock-function-name-face]} (setq font-latex-match-function-keywords '(

string - Python: How to not print comma in last element in a for loop? -

my code iterates on set , print actor's names: for actor in actorsbymovies(): print actor+",", the result looks like: brad pitt, george clooney, but want detect last element won't print last comma. result should instead: brad pitt, george clooney how can that? print ', '.join(actorsbymovies())

asp.net - XML Property 'InnerText' is WriteOnly when trying to read attribute value -

i'm getting "property 'innertext' writeonly" error when trying read attribute value here's xml: <?xml version="1.0" encoding="utf-8"?> <products> <product id="11837"> <price currency="eur">75.29</price> <properties> <property name="brand"> <value></value> </property> </properties> <variations/> </product> </products> to extract price do: node.selectsinglenode("price").innertext which returns "75.29" but when do: node.attributes("id").innertext i error: property 'innertext' writeonly i don't see reason why it's write-only , don't know how can change can read value. it's fact of implementation of xmlattribute supports writing innertext property. don't "change it" can

php - Is htmlspecialchars() used for all applications when suspect content is put on a page? -

i understand should use htmlspecialchars() when displaying user provided content html on page. apply other content such javascript, css, value of <input> , etc? believe have heard use json_encode() instead of htmlspecialchars() encode js. <?php $dangerous=$_get['dangerous']; session_start(); $_session['mysession']=$dangerous; ?> <!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> <title><?php echo($dangerous);?></title> <style type="text/css"> div.<?php echo($dangerous);?> {size:12px;} </style> <script type="text/javascript"> var myvar=<?php echo($dangerous);?>; </script> </head> <body> echo(<?php echo($dangerous

Update Pass in Passbook with PHP -

is possible update pass in passbook using php? has example code or tutorial? searched google, can't find anything. to answer question, yes. can use php (for server side component) update passes. start reading passbook programming guide apple. then, check out this tutorial (which good, gives obj-c code code samples , explains server side code well) integrating , updating passes in app.

What is the benefit of using IQueryable and LINQ queries? -

i have project realized own configuration classes: iconsizesconfigsection: configurationsection iconsizescollection: configurationelementcollection iconsize: configurationelement in config class exists property: public iqueryable<iconsize> iconsizes { { iconsizesconfigsection configinfo = (iconsizesconfigsection)configurationmanager.getsection("iconconfig"); return configinfo.iconsizes.oftype<iconsize>().asqueryable<iconsize>(); } } iconsizes property returns iconsizescollection derives configurationelementcollection . in turn configurationelementcollection derives icollection , ienumerable . in class have such code: var previewiconsize = config.iconsizes.firstordefault(c => c.name == "avatarsize"); why in such case uses deffered execution? why uses asqueryable<iconsize>() collection , uses linq , deffered execution? is there benefits compared using simple

c# - How to implement a sealed, public nested class that can only be created by its enclosing class? -

goal my goal implement sealed, public nested class can created enclosing class - without using reflection. that means nested class cannot have public or internal constructors or public or internal static factory methods. previous work this post couple of years ago seems answer . (that entire thread has lot of information i'm trying achieve.) how works quite straightforward: leverages fact nested class can access static fields of enclosing class, along static constructor nested class. the enclosing class declares static func<nestedclasstype, nestedclassctorargtype> delegate returns instance of nested class, enclosing class can use delegate factory method. the nested class has static constructor initialises enclosing class's static factory delegate delegate create instance of nested class. the problem unfortunately, can't work written in answer. reason static constructor nested class not called before enclosing class uses factory method, , there

jquery - CKEditor - attach to AJAX loaded content -

i have page has contenteditable area has ckeditor attached. what i'm looking do, load page replace current one, loads in contenteditable div via ajax this works fine, loaded content, doesn't have ckeditor wysiwyg attached. <div contenteditable="true" class="content"></div> $.ajax({ type: "post", url: 'load.php', data: "id="+id, success: function(data) { // i've tried using ckeditor config, doesn't load } }); load.php <div contenteditable="true" class="content"></div> for dynamically added elements need call ckeditor.inline . method accepts element (or id) on editor should initialized , config object. see docs . [added] your dynamically created div or text area <div contenteditable="true" id="content">...</div> end js code a

Magento error "Failed opening" -

when disabling purchased module in magento , load magento admin. shows me error: rr (3): warning: include() [function.include]: failed opening 'mage/sarp/helper/data.php' inclusion (include_path='app/code/local:app/code/community:app/code/core:lib:.') in lib/varien/autoload.php on line 93" i have googled , got link: http://kb.magenting.com/content/22/29/en/solution-failed-to-open-stream-no-such-file-or-directory-in-includes-src-varien_autoloadphp-on-line-93.html . i have follow steps. no results. don't have ssh access. magento not have module named sarp. me looks still having code mage::helper('sarp') somewhere (maybe in phtml) module don't exist.

c++ - What's the value of characters in execution character set? -

quote c++03 2.2 character sets: "the basic execution character set , basic execution wide-character set shall each contain members of basic source character set..the values of members of execution character sets implementation-defined, , additional members locale-specific." according this, 'a' , belongs execution character set, value implementation-defined. it's not 65(ascii code of 'a' in decimal), what?! // not 65? printf ("%d", 'a'); or i've misunderstanding value of character in execution character set? of course can ascii's 65, if execution character set ascii or superset (such utf-8). it doesn't "it can't ascii", says called "the execution character set".

php - Select from 3 tables with calculating -

i try make query in mysql gets data 3 tables, , calculate in 2 tables. don't know how this. i have in php code calculate "avage cost per click": get campaigns. select * campaigns; get how many clicks campaign has: select sum(id) ialt2 aktivitet annonce_id = '@@campaign_id' group ip"); get total revenure rows select sum(price) ialt money ad = '@@campaign_id' group id now can calculate "avage cost per click" "ialt / ialt2" = cpc then should say: select * campaign order cpc desc limit 0,1 select * campaigns c order ( (select sum(price) money ad = c.campaign_id) / (select sum(id) aktivitet annonce_id = c.campaign_id) )desc limit 0,1 just guessing, think want this

html - Validating phone number with JavaScript -

i have form 3 elements. want validate phone number when user enters it. if user moves next element , phone number contains , characters not numbers want display alertbox. i have written code stumped. problem having function is, if enter numbers phone number element still alert box displayed. code looks this: <script type="text/javascript"> function validateform() { checknr= isnan(document.forms[0].elements[1]) if(checknr == true) { window.alert("you can enter numbers. please try again") } } </script> <form> <strong>fullname: </strong><input type="text" / id="name"><br /> <strong>phone nr: </strong><input type="text" id="phone" onblur="validateform()" /> <strong>nationality</strong><input type="text" id="nat" /><br /> <input type="button" id="subbutton" onclick="calc()&

Sharing session between a rails server and a php server -

currently have 2 servers set up, each handling there own thing, want have unified login between them. right 1 portal's login form sending username/pass through api rails portal, , sends auth token, store in our session , use future authentication , api calls. so problem becomes user visiting our site has login once in each portal, since ruby api doesn't communicate ours, , ruby side doesn't session when api pinged send , auth token. my initial idea have rails side create session when send credentials api, apparently won't work won't able set session id in users browser, or @ least that's told. if ruby side moved on using database session storage, alleviate issue? basically, want keep of changes on ruby side this. i have implemented session sharing using memcache concept between ruby on rails , php. got success in this. if familier memcache concept useful you. , if need same can share you.

exception - Graph OAuthException 1500 : The url you supplied is invalid -

as of today, of app's calls share links on user's feeds failing following error: { "message": "(#1500) url supplied invalid", "type": "oauthexception", "code": 1500 } uisng php curl, i'm posting https://graph.facebook.com/{user_id}/feed , submitting link parameter pointing valid, working url (plus message params) etc. strangely, can issue command line curl request , request seems work correctly (at least haven't had error yet). i don't want file bug report yet incase i've missed in breaking migration. ideas may causing this? http://developers.facebook.com/bugs/476666205677592 i have problem too. happened randomly. i'm sure url supplied valid , can not reproduce it. reported bug here..

django - Reverse for 'media' with arguments '()' and keyword arguments '{}' not found -

urls.py is (r'^when/$', 'when'), (r'^media/$', 'media'), (r'^followup/$', 'followup'), models.py class report(models.model): user = models.foreignkey(user, null=false) incident_number = models.charfield('incident number', max_length=100) device_id = models.charfield('device id', max_length=100) app_uuid = models.charfield('unique app id', max_length=100) created_date_time = models.datetimefield('created') manual_date_time = models.datetimefield('another time', null=true, blank=true) sent_date_time = models.datetimefield('sent') views.py is def when(request): if request.method == 'post': reportform = reportform(data=request.post) if reportform.is_valid(): log.debug("test:%s",reportform) report = reportform.save(commit=false) report.user = request.user red

c# - Remove item from dictionary where value is empty list -

what best way remove item dictionary value empty list? idictionary<int,ilist<t>> var foo = dictionary .where(f => f.value.count > 0) .todictionary(x => x.key, x => x.value); this create new dictionary. if want remove in-place, jon's answer trick.

jar - Android Library Project - Resources$NotFoundException -

Image
i'm trying create library project use unity3d plugin. correct when i'm trying show custom progressdialog example i'm doing this, getting resources$notfoundexception layoutinflater inflater = (layoutinflater)getsystemservice(context.layout_inflater_service); view layout = inflater.inflate(com.myapp.test.r.layout.loading, null); layout.setminimumwidth((int)(displayrectangle.width() * 0.9f)); layout.setminimumheight((int)(displayrectangle.height() * 0.9f)); progress.setview(layout); i'm doing wrong? library project ( jar file ) seems not contains layouts or resources... have put in preferences of eclipse library true. you cannot package resources jar file. suggest make library project , refer same in android project. for more information check link below http://developer.android.com/tools/projects/index.html right click on project, goto properties, choose android, choose library (tick). to refe

rspec - Timecop and Ruby 2.0.0 -

can suggest why spec fails using timecop 0.6.1 , ruby 2.0.0? (it passes using timecop 0.4.5 , ruby 1.9.3) require 'timecop' require 'spec_helper' describe class "freezes time" timecop.freeze date.new(2012,7,1) expect(date.today).to eq(date.new 2012,7,1) end end end which results in: $ rspec spec/models/time_cop_spec.rb failures: 1) class freezes time failure/error: expect(date.today).to eq(date.new 2012,7,1) expected: sun, 01 jul 2012 got: thu, 02 may 2013 (compared using ==) diff: @@ -1,2 +1,2 @@ -sun, 01 jul 2012 +thu, 02 may 2013 there clear , consise answer (and pull request fix it) on timecop's github repo . short answer : change in bundler version, not change in ruby or timecop version , caused issue. short solution : add require 'date' top (before require 'timecop' ). thanks @micahchalmer :)

iOS: Draw on top of AV video, then save the drawing in the video file -

i'm working on ipad app records , plays videos using avfoundation classes. have of code basic record/playback in place , add feature allows user draw , make annotations on video—something believe not difficult. harder part, , have not been able find examples of, combine drawing , annotations video file itself. suspect part accomplished avcomposition have no idea how. appreciated. mark i not think can save drawing video file in ios. consider using separate view save drawing , synchronize overlay onto video using transparent view. in other words, user circled @ time 3 mins 42 secs in video. when video played overlay saved drawing onto video @ 3:42 mark. it's not want think close can right now. edit: there might way after all. take @ tutorial. have not read whole thing seems incorporate overlay function need. http://www.raywenderlich.com/30200/avfoundation-tutorial-adding-overlays-and-animations-to-videos

java - String concatenation in jdo query -

i trying query like search on concatenated results. in sql this: where firstname + ' ' + lastname '%namesearch%' when trying in jdo this: query q = pm.newquery(user.class); map<string, object> args = new hashmap<string, object>(); args.put("search", search); q.setfilter("(user.firstname + ' ' + user.lastname).indexof(:search) >= 0"); q.executewithmap(args); however doing results in parsing exception. portion of expression not parsed: (:search) >= 0 is possible concatenated expression searches in jdo this? the problem see forgot call q.declareparameters("string search")

rendertargetbitmap - RenderToBitmap trouble in WPF -

actually, have print view viewport3d , obviously, use rendertargetbitmap . problem if resolution of rendered image got high, triangles of scene don't appear on final image. for example, viewport can 1024*768 , resolution use rendertargetbitmap 3 times viewport 's resolution. http://imgur.com/ps2f9d9 i solved problem in way... in fact, triangles don't appear when use big scale. if lower size of rendertargetbitmap , contain everything. actually, have more or less 1024*768 @ 96dpi . if want impress @ 300dpi , need huge image avoid last solution. some code : public static rendertargetbitmap captureecran(viewport3d p_viewport, int p_scale) { rendertargetbitmap l_bmp; p_scale = p_scale > 5 ? 5 : p_scale; l_bmp = new rendertargetbitmap(p_scale * convert.toint32(p_viewport.actualwidth), p_scale * convert.toint32(p_viewport.actualheight), p_scale * 96.0, p_scale * 96.0, pixelformats.pbgra32); drawingvisual vis = new drawing

ios - UIBarButtonItem: Change title font colour during animation -

i've initialized uibarbuttonitem custom uibutton , set rightbarbuttonitem within navigation controller. uibarbuttonitem *rightbarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:rightnavigationbutton];//rightnavigationbutton custom uibutton set before self.navigationitem.rightbarbuttonitem = rightbarbuttonitem; via appearance proxy of uibutton set colours uicontrolstates (normal/disabled/highlighted). uibarbuttonitem behaving expected. when "save-button" pressed, want highlight uibarbuttonitem give visual feedback has been saved. i'm trying simulate highlighting of uibarbuttonitem through changing color of title during saving animation since doesn't seem can trigger highlighting animation (or set selected property) programmatically ( also mentioned in post ) so did set iboutlet property, hooked uibarbuttonitem in interfacebuilder , assigned rightbarbuttonitem it. when "save-button" pressed i'm trying this: [uiview animatew

What are "solution configurations" in visual c++ 2005/2008? -

msvc++ docs: this example builds project csharpconsoleapp, using debug project build configuration within debug solution configuration of mysolution. devenv "c:\documents , settings\someuser\my documents\visual studio\projects\mysolution\mysolution.sln" /build debug /project "csharpwinapp\csharpwinapp.csproj" /projectconfig debug i confused solution configuration , how differs/relates project configuration. in 1 of our build scripts have lines like: devenv ..\projectx.vcproj /build releaseunicode /project projectx /projectconfig "releaseunicode|win32" /out ..\buildlogs\build_projectx.log but doesn't match msdn's example , still seems kind of redundant, can me understand more clearly? a solution configuration substantially set of project configurations settings, i.e. quick way build project particular configuration setting each project. for example, may have solution containing gui applicatio

sql server - SSAS 2012 - Dimension Modeling -

Image
i working structure results lot of single attribute dimensions require no hierarchy. examples: status(status name) type(type name) i following warning when compiling project: "avoid having multiple dimensions containing single attribute. consider unifying them if possible." a large number of single attribute dimensions workable our users, causes lot of clutter in excel pivot table. dimensions listed along single attribute redundant. i unify them warning suggests have single dimension called 'attributes' contains status/type/etc, unsure best way so. doesn't make conceptual sense me parent/child dimension. any suggestions? i agree worthwhile change. construct view brings required attributes. available on fact/measure group table/view, can use same source object (in dsv) construct dimension. the tricky part may dimension key. flexible key fact surrogate key eg unique value per fact row - in future can add other fact-based attribu

java - Difference between singleton and eagersingleton for Gin or Guice? -

i wondering different between singleton , eagersingleton gin or guice? from guice's wiki eager singletons reveal initialization problems sooner, , ensure end-users consistent, snappy experience. lazy singletons enable faster edit-compile-run development cycle. use stage enum specify strategy should used. eager: "create instance of class when module being run" lazy: "create instance of class when it's first requested dependency injection"

algorithm - Improved First Fit -

Image
i working on different heuristic solutions bin packing problem , have implemented different algorithms such ff, ffd, bf, bfd , on. question is, there better algorithm these or there (even small) improvements on these algorithms. have read lot , searched not find interesting. i use construction heuristics (such ff, ffd, bf, bfd) followed metaheuristics (such tabu search, simulated annealing, late acceptance) in optaplanner (java, open source) better results ffd:

How to use storeAttribute in Selenium RC -

i need use waitforattribute() - having issues getting attribute need, looking example usage of storeattribute() using php. sample dom <div class="sidebar"> <a class="add"></a> </div> i want class of <a> // $foo null $foo = $this->storeattribute('css=div.sidebar@class'); // error: element css=div.sidebar["class" not found $foo = $this->storeattribute('css=div.sidebar["class"]'); i'm using css selectors, don't mind using xpath. i changed strategy - else running issues moved in order waitforattribute() work: $this->waitforcondition("selenium.browserbot.getcurrentwindow().$('div.sidebar a').hasclass('remove')");

sql - Relational Database emergency person + contact number? -

i'm trying design normalized relational database patient has * contact person * (person contacted in case of emergency). have table called contact_num takes patient_id foreign key. how can implement having emergency contact person (who has phone number) may/may not patient? should implement emergency_contact_num table? or kind of unary relationship? egs helpful i think have contacts book, stored in database so patient, entry database be: 'id' => '1' 'first_name' => 'john' 'last_name' => 'doe' 'emergency_contact' => '2' of course, should include important information person in table (ex. phone number). emergency contact, database be: 'id' => '2' 'first_name' => 'lisa' 'last_name' => 'joe' 'emergency_contact' => 'none'

c# - insert multiple rows to database looping -

what wrong code achieve insert rows database clear textbox value , enter record.. problem @ first loop data added successfully...but on next iteration loops add empty strings rows of database want accept input textbox , continue iterating...please try read code , me ...it been 2 weeks since trying solve .. again want -user enter number of group members - group members have column ,first name,last name gender,city.etc group members (eg:6 group membrs) add 6 rows of of different column added code add first rows , rest 5 row's empty data sorry bad english..somebody please try think thinking {{ private void btnaddloan_click(object sender, routedeventargs e) if (txtname.text != "" && txtlname.text != "") { int c=0; int input=int.parse(txttotalnumberofgroupmembers.text); { string connstr = "data source=ger-pc\\

php - Open specific jquery ui tab based on which the previous page is -

i have created jquery ui tab , when page containing jquery ui tab loads, specific tab open depends on previous page. far, have down following: php: obtain previous page using $_server['http_referer']; determine tab open using "if" statement (assigning tab_index variable); assign "tab_index" hidden input value. javascript: pick hidden input value , assign js variable; ?? then not sure how make work in $('#tabs').tabs({.... statement. idea of how resolve appreciated. many thanks. php: $string = $_server['http_referer']; $string = substr($string, -(strlen($string)-strrpos($string, '/')-1), strlen($string)-strrpos($string, '/')); if ($string == "specific_page.php") { $tab_index = 2; } else { $tab_index = 0; } html: ... <input id="hidden_input" type="hidden" value="<?php echo $tab_index; ?>" /> js: $(document).ready(function() { var tab_index = $(&

jetty - Facing java.lang.NoSuchMethodError: HttpServletRequest.getParts()Ljava/util/Collection -

i've seen many issues related exception here in , of them being solved adding "commons-file-upload" jar apache. tried use solution , i've added same version of jar projects, not seem fix problem, i'm still facing problem. know question has been asked, wonder if give me hand specific problem. stacktrace: java.lang.nosuchmethoderror: javax.servlet.http.httpservletrequest.getparts()ljava/util/collection; @ fr.synomia.v4.ws.remotelayer.ws.rest.restserver.getparameters(restserver.java:378) @ fr.synomia.v4.ws.remotelayer.ws.rest.restserver.parseurlrequest(restserver.java:367) @ fr.synomia.v4.ws.remotelayer.ws.rest.restserver.access$0(restserver.java:354) @ fr.synomia.v4.ws.remotelayer.ws.rest.restserver$1.handle(restserver.java:67) @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:110) @ org.eclipse.jetty.server.server.handle(server.java:346) @ org.eclipse.jetty.server.httpconnection.handlerequest(httpconnect

performance of large number calculations in python (python 2.7.3 and .net 4.0) -

there lot of general questions python performance in comparison other languages. i've got more specific example: there 2 simple functions wrote in python c#, both checking if int number prime. python: import time def is_prime(n): num =n/2 while num >1: if n % num ==0: return 0 num-=1 return 1 start = time.clock() probably_prime = is_prime(2147483629) elapsed = (time.clock() - start) print 'time : '+str(elapsed) and c#: using system.diagnostics; public static bool isprime(int n) { int num = n/2; while(num >1) { if(n%num ==0) { return false; } num-=1; } return true; } stopwatch sw = new stopwatch(); sw.start(); bool result = functions.isprime(2147483629); sw.stop(); console.writeline("time: {0}", sw.elapsed); and times ( surprise me beggine

javascript - Filtering out duplicate objects before pushing to an array? -

i attempting filter out duplicate objects before pushing each object array. function collaborators() { var api = '/docs/' + doc_id + '/json'; $.getjson(api, {format: "json"} ).done(function(data) { var collaborators = []; (var = 0; < data.notes.length; i++) { if ( data.notes[i].author === data.notes[i+1].author) { console.log('dup found') console.log(data.notes[i].author) } else { collaborators.push(data.notes[i].author); } } }); } the console showing "uncaught typeerror: cannot read property 'author' of undefined". seeing duplicate entry in console.log(data.notes[i].author) , array empty. needs corrected? in last iteration of loop, there no i+1 : data.notes[i+1] since undefined, calling .author on blow up. error indicates, data.notes[i+1] undefined, therefore there no property author of undefined .

Passing a string from view to controller in ASP.NET MVC Razor -

i've got asp.net mvc razor application. in application have multiselect control (which dropdown can select multiple items from). have subscribed "close" event of control when closed, passes string of comma separated integers controller. however, although method in controller being called, value being passed null. have tested event , know string being generated correctly. here code in event handler: `function close() { var alerttypeids = $("#alertmultiselect").val().tostring(); //alert("this alerttypeid: " + alerttypeids); $.post('@url.action("subscribetoalerts")', { value: alerttypeids }, function (result) { alert("the value sent server"); }); };` here controller code: `public void subscribetoalerts(string alerttypeids) { bool issubscribedtonewitem = false; bool issubscribedtonewcustomer = false; bool issubscribedtonewsupplier = false;

c# - Dynamically Creating Image - Does not Exist in Current Context -

i trying create whackamole game in wpf in c#. bit of noob. in loop trying add number of "i" "image". following error: "error name 'image1' not exist in current context" same thing 'image2' , on. trying integrate images stackpanel. thanks :) public partial class mainwindow : window { image[] imagearray = new image[50]; public mainwindow() { moleini = molescore[1]; initializecomponent(); //string imagename = "image"; (int = 0; <= 8; i++) { image image = new image(); imagearray[i] = image; image.name = "image" + i.tostring(); } ////create images //for (int = 0; <= 8; i++) //{ // stackpanel1.children.add(createimage(i)); //} //dispacher mole appear system.windows.thr

google maps - Geocoding Web service api returns OVER_QUERY_LIMIT after 8 queries -

i have been doing geocoding prefetch groups of addresses. since last week, have been getting over_query_limit result returned after handling 8 addresses. so, still within 2500 requests per day , give 2 second pause between each request. has there been change in procedure ? i have checked api documentation verify hasn't changed since last year. code same before, wondering has changed. likely sharing server user counting in quota, since quota ip address. code operate it's own ip address or sharing server other users?

javascript - jQuery datepicker altFormat not displayed -

i have jquery datepicker localized based on language preferences of seller. each datepicker customization has different date format want input when form submitted in specific format parsing. trying use altformat on date picker set 'mm/dd/yy' not want date in format shown user. there way this. i.e. there way have different date formats datepicker evaluate same date when creating javascript date objects? why not want use altformat altfield ? in simple example here can store , access date in desired format mm/dd/yy while showing user in "his" desired format. see jsfiddle on button click shown format changes format in altfield doesn't. <input type="text" id="datepicker"> <input type="button" id="changeformat" value="change!"> <!-- hidden input --> <input type="text" id="altformat"> $(document).ready(function () { $('#datepicker').datepick