Posts

Showing posts from September, 2011

c# - How to fix "CA1810: Initialize reference type static fields inline" with an abstract base...? -

here's simplified parts of code have: abstract class datamanager<tvalue> { protected static dictionary<string, tvalue> values; } and have: class textmanager : datamanager<string> { static textmanager() { values = ... // fill data } } and, i'm getting ca1810. see few solutions, making values public , setting them elsewhere, don't that, or making static method in textmanager same thing, invoked when program starts, don't either. i think it's obvious example, values should filled once per tvalue . so, think best solution here? i turn off rule. thing is, have rule (afaik) designed warn potential performance hit of using static constructor. initialization of static property can done either via static constructor or inline (as suggested msdn ). in case can't inline because: you have actual values in subclass there's no such thing abstract static method, can't delegate actual inline initia

Working in svnx with svn+ssh -

i work mac program subversion "svnx", , works rather http repositories. today tried checkout svn+ssh repo program not work correctly. solved problem? thanks i've found 3 things have helped me use svnx svn+ssh repositories. these might problem: do initial checkout command line; allows accept site's host key older versions of subversion not pass -q option ssh default; if case you, add line [tunnels] section of ~/.subversion/config: ssh = $svn_ssh ssh -q if use controlmaster option ssh, should disable svn; add line [tunnels] section of ~/.subversion/config (you may need combine last item): ssh = $svn_ssh ssh -o controlmaster=no hope helps!

.net - Why isn't my item in an array getting updated? -

i have array of objects, find item index, assign value looking @ array item doesn't show updated value. public structure cheque public id string public status byte public amount string public warrantno string end structure public class chequecollection private chequecoll() cheque 'this populated ok public sub updatechequeamount(byval id string, byval amount string) synclock lockobject dim idx integer = get_idx(id) 'finds ok if idx <> -1 dim cheque cheque = chequecoll(idx) cheque.amount = amount 'updates value ok if in chequecoll value isn't there end if end synclock end sub end class because value types copied everywhere they're used - you're updating copy of value type that's in cheque variable, opposed copy within array. you'd need update copy in array: dim cheque cheque = chequecoll(idx) c

c# - MEF Generic Imports -

i have following example code using mef: public interface ifoo<t> {} public class foo<t> : ifoo<t> {} [export(typeof(ifoo<string>))] public class foo : foo<string> {} public class bar<t> { [import] private readonly ifoo<t> foo; } static void main() { var catalog = new aggregatecatalog(); catalog.catalogs.add(new assemblycatalog(assembly.getexecutingassembly())); var container = new compositioncontainer(catalog); container.composeparts(); var bar = new bar<string>(); //bar.foo null } this doesn't seem work - foo field null . because type isn't seen mef ifoo<string> ? foo null because creating instance yourself. need have container create instance. additionally, want check out genericcatalog if plan on working importing/exporting generics.

hibernate - Standard way to handle Repository in JPA -

consider following scenario. there table in db content form repository. table updated (updation of existing extities, addtion of new entities or removal of entities) rarely. approach using create singleton xxxrepository pojo read rows (entities) xxx table , store them in map. if updating xxx table after update part of code executed, post runnable run clear repository (map) , hence next time entity being located map, loadrepository invoked (as map null). this way handle repository caching can use throught application life cycle. is there standard way provided/supported in jpa/hibernate achieve/implement requirement. i went through caching mechanism (both 1st , 2nd level cache). seems entities or queries or data , different purpose/approach expected happening or achieved repository. if able achieve somehow using 2nd level cache, there 1 more issue cache updates in case of jpa operations , jpql queries. in case of jdbc or native queries fail updated , have stale data (correc

c# - Show Progress bar with smtpClient.send -

i using function send mails via gmail. private bool uploadtogmail(string username, string password , string file , string backupnumber) { mailmessage mail = new mailmessage(); smtpclient smtpserver = new smtpclient("smtp.gmail.com"); mail.from = new mailaddress("jain@gmail.com"); mail.to.add("jain@gmail.com"); mail.subject = "backup mail- dated- " + datetime.now + " part - " + backupnumber; mail.body = "hi self. mail contains \n backup number- " + backupnumber + " \n dated- " + datetime.now ; system.net.mail.attachment attachment; attachment = new system.net.mail.attachment(file); mail.attachments.add(attachment); smtpserver.port = 587; smtpserver.credentials = new system.net.networkcredential("jain@gmail.com", "password"); smtpserver.enablessl = true; smtpserver.timeout = 999999999; smtpserver.send(ma

asp.net - error making dll -

i created asp.net pages using c# code when compile (.csproj file) code using compile.bat file shows me compilation error error code cs1303 [ "label01" not found, "textbox01" not found" on... forms unable make dll... i wanna compile code make dll file cannot compile it.... please me.... i found designer file missing in context. try adding it.

closures - reuse Criteria in Grails Controller -

typically have following last line in grails generated controller list method: [userinstancelist: user.list(params), userinstancetotal: user.count()] if want restrict users specific criteria looks like [userinstancelist: user.list(params) { ilike('login', '%test%') }, userinstancetotal: user.count() { ilike('login', '%test%') }] but violates dry principle - best way reuse criteria closure? paged results criteria builder (the result class pagedresultlist ) have property, totalcount , can use calling count() on same criteria: def userinstancelist = user.createcriteria().list(params) { ilike 'login', '%test%' } [userinstancelist: userinstancelist, userinstancetotal: userinstancelist.totalcount]

Any way to change the sampling frequency of a WAV (or MP3) in Android or just Java? -

i'm trying files played through mono (sco) bt headset in android. files have have 8000 hz frequency, ones have 44100 hz. files mp3s, i've created code convert them wavs, since know android doesn't handle mp3s natively. this has done on device @ execution time,so can offer suggestions? i should mention don't care format files end in, long can played using mediaplayer. 44100/8000=5.5125 can try take 5.5125 samples , calculate average value , reduce sample rate i think should work although im sure result noisy ist worth trying you can take every 5.5125 sample maybe can http://en.wikipedia.org/wiki/downsampling

ruby on rails 3 - How to load views on an added Devise module for a custom registration controller -

my rails 3.0.3 app uses devise gem (1.1.5) authentication , before wasn't using :registerable module. have since added enable users sign up. implemented own registration controller extends devise::registrationscontroller. when visit url /users/sign_up. " missing template error " because rails doesn't find registration views under app/views . had generated devise views using rails generate devise_views means registration views under app/views/devise/. when copy views app/views/ folder works. doesn't seem dry. there way of telling rails use views in app/views/devise? thanks, kibet. the easiest way add line in \config\application.rb config.paths['app/views'] << "app/views/devise"

jQuery UI widget : How can I get the widget's container? -

i'm developping jquery ui widget uising widget factory, , need selector containing widget. to clear things : i use jquery ui tabs (official) my widget created in each tab (1 instance each tab, meaning different displays) when perform action in tab, needs update widget located in same tab the problem : when perform said action, update not occur in right tab, in first one i tried several modifications of listeners on actions, believe problem comes widget itself. defined classes (because it's meant appears multiple times), except tab defined id. tried make happen in widget element child of said div#id , doesn't work. what need know how container of widget within widget's code, make modifications in right tab thank you help. edit : here's jsfiddle showing (very) basic structure of app. when fire action, on nearest widget instance, meaning 1 in same tab. actual effect in first tab. because (i think) of plugin locates own elements using classe

iphone - MKMapView Cannot Zoom Map -

i created basic app shows mkmapview , userlocation. i'm having problems drawing base map (it shows pieces of map), , whenever pinch zoom map, fails redraw, , shows blank gray tiles. console shows whenever needs new map tile: /sourcecache/googlemobilemaps/googlemobilemaps-263.5/googlenav/mac/loader.mm:231 server returned error: 502 this looks gateway error, doesn't make sense, since i'm using open wifi testing. haven't implemented region zooming code, want display , zoom basic map first. i'm using ios 4.2.1 (8c148), i'm wondering if problem newer ios versions? ideas? edit: works fine now, must problem google's servers. just started getting same error. i've searched online , can't see else having issue (yet). thought did, suspect @ google's end.

actionscript 3 - Flex/AS3 Using Multiple Item Renderers In a List -

i'm trying have multiple item renderers in list, have several different types of objects want display. tried creating new class extends listbase, , adding override public function createitemrenderer code within function. instantiate new class , give array of data dataprovider, createitemrenderer never called within new class, can me please? thank you i managed solve extending list instead of listbase, shakakai making me think :) incase else has similar problem here code looks like: public class multiplerendererslist extends list { override public function createitemrenderer(data:object):ilistitemrenderer { if (data type1) { return new type1component; } else if (data type2) { return new type2component; } return null; }

flex - Google Maps Polyline CLICK Event -

i'm implementing map application. uses google maps api flash. there 1 callback function triggered when map clicked. additionally, there plenty of polylines generated dynamically. polylines have click event listener assigned them. problem when click polyline, map click event triggered @ first , polyline's click event fired. i can't resolve issue. it's anoying. here code assigns callback map's click event: map = new map(); map.key = google_map_key; map.addeventlistener(mapmouseevent.click, onmapclicked, true); and here code assigns callback function polyline's click event: var polyline:polyline = new polyline(path); polyline.addeventlistener(mapmouseevent.click, cuttoend); i need supress "onmapclicked" function's invocation when click on polyline. "cuttoend" method should invoked. thanks map.addeventlistener(mapmouseevent.click, onmapclicked, true); you use bubblingphase here (third "true" parameter). me

javascript - How do I access a local variable dynamically (via a String form of its name) from a closure scope? -

this question has answer here: how can access local scope dynamically in javascript? 3 answers in javascript, i'm used being able access variables within known namespace "dynamically" (correct me if i'm using wrong word here) using [] operator. instance (from global namespace): var = 1; window['a']; # => 1 or object-type namespace: var = { b: 1 }; a['b']; # => 1 and i'm familiar basics of how this determined: var = function(){ return this['c']; }; var b = { c: 1 }; a.apply(b); # => 1; but within function itself, how access local variables i've instantiated (or redefined) using var ? namely, want following function call return 1 without calling a : function(){ var = 1; return a; } you can't use window['a'] because a defined locally, , can't use this['a'] bec

sql - Basic question: how to properly redesign this schema -

i hopping on project sits on top of sql server 2008 db seems inefficient schema me. however, i'm not expert @ sql, seeking guidance. in general, schema has tables this: id | | b id unique identifier a contains text, such animal names. there's little variety; maybe 3-4 different values in thousands of rows. vary time, still small set. b 1 of 2 options, stored text. set finite. my questions follows: should create table names contained in a, id , value, , set id primary key? or should put index on column in table? right now, list of a's, "select distinct(a) table" seems inefficient me. the table has multitude of columns properties of a. like: color, age, weight, etc. think better suited in separate table with: id, animalid, property, value. each property unique animal, i'm not sure how schema enforce (the current schema implies it's column, can have 1 value each property). right db readable human, size growing fast , feel design ineffic

asp.net mvc - How do you add jquery animation to mvc 2 rendered controls? -

have editor template can rendered 0 n times on given page: <%@ control language="c#" inherits="system.web.mvc.viewusercontrol<newemployee.models.requestedaccessviewmodel>" %> <fieldset style="display: inline;"> <legend> <%: model.description %></legend> <div class="editor-label"> <%: html.labelfor(model => model.requested) %> <%: html.checkboxfor(model => model.requested)%> </div> <div class="editor-field"> <%: html.textareafor(model => model.comments) %> </div> <%: html.hiddenfor(model => model.description) %> <%: html.hiddenfor(model => model.id) %> </fieldset> what i'd 'comments' text area hidden initially, , slide down view when check box hit, , slide out if checkbox turned off again. i know how traditinal asp.net, @ loss mvc2. use jq

Reading a file in Python without an extension -

i want read (basically text file) file without extension in python 2.6. have tried following codes following errors.. for infile in glob.glob(os.path.join(path + "bookmarks",'*')): review_file = open(infile,'r').read() print review_file -> global name glob not defined f = open(path, "r") text = f.readlines() print text -> prints "x00\x00\x00\x00\x00\" etc, , not inside of file. edit: -> conents of file, directly, want, example if file had "023492034blackriver0brydonmccluskey" in it, (as of now) extract bunch of binary values, whereas want exacy contents. how so? if want use glob module, have import first: import glob infile in glob.glob(os.path.join(path, '*')): review_file = open(infile,'r').read() print review_file are sure file not contain binary data getting?

javascript - Using images / links to switch form select (dropdown) -

i'm building form client , they've requested map of city let visitors visually pick location, , have link city: dropdown/select area of form. here's clients old, archaic & disgusting website showcasing want done, though, it's terrible. http://www3.telus.net/russellsrubbish/order_form.htm i looking @ hidden form value change , i'm unsure if pushing in right direction? if failed explain myself apologize, i'm pretty novice when comes jquery. to make work make background sprite map , use image maps . use jquery react on clicking 1 of hotspots , change selected index in select box. ---------------------------------------- edit - working example ------------------------------ heres working example made you: example can click 2 regions in netherlands on map, "noord-brabant" , "gelderland". html: <div class="mymap"> <img alt="" src="map_overlay.png" usemap="#holland"&

sql server - SELECT ... FOR XML into a file -

i have query returning large xml, size can reach 1gb in extreme cases, takes hundreds of megabytes. the obvious approach when client program receives data @ once , keeps in memory doesn't work in case. is there way make sql server output result file? or maybe deliver resulting data piece piece? in latter case trivial direct ouput file without loading memory. according statement of problem resulting xml transformed xslt produce smaller result. ideally server should instructed output xml data pipe connected xslt engine being run separate process. don't see way this. are there ideas? thank you. client program written in c# 3. sql server version 2005, if solution exists in 2008 only, restriction should not considered essential assuming using .net language , ado.net, here http://www.csharp-station.com/tutorials/adodotnet/lesson02.aspx you find example how feed result set of select sql console stream using sqldatareader. replace console file stream , do

xml - JAXB minOccurs and UnmarshalException -

i generated classes using xjc, , trying process following xml doc. getting error: javax.xml.bind.unmarshalexception: unexpected end of element {http://schemas.xmlsoap.org/soap/envelope/}:body i believe because xml not contain fault element (when add in fault element, process without errors. response either contain retrieval_id or fault, never both. thought having minoccurs=0 in schema fix this, no go (at least how did it). possible use jaxb situation, is, when either of these elements may exist, never both @ same time? xml response in question: <?xml version = '1.0' encoding = 'utf-8'?> <env:envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/xmlschema-instance" xmlns:xsd="http://www.w3.org/1999/xmlschema"> <env:header> <bmw:rule xmlns:bmw="http://adr.com/bmw"> <bmw:customer>44</bmw:customer> <bmw:schemaname>abc</bmw:s

Setting environment variables for application Maven -

my question have pom file calls bat file sets environment variables application. call ant script uses these environment variables compile , execute. these environment variables cant recognized ant script , fails. believe because both run in different context. can guys let me know how link together. org.codehaus.mojo exec-maven-plugin 1.1 pre_clean pre-clean exec env.bat maven-antrun-plugin compile compile run yes. when batch file ends environment changes go out of scope. so, need call ant within .bat file or set environment before starting maven or set them in pom.

javascript - jQuery autocomplete and back button behaviour? -

i'm using awesome jquery autocomplete plugin . i'm bit of newbie when comes understanding browser behaviour , ajax, have question. this sequence of events: user types 'fish' text box user chooses book title list of autocomplete options - fish farming, fish frying, etc html loads on page (as ajax) - 'click here fish farming' user clicks on link , loads fish farming page user decides fish farming isn't them, clicks on 'back' button - , returns empty page! how can change when user returns home page, see fish farming html - page looking at? this autocomplete code: // autocomplete listener. $("#q").catcomplete({ source: "/book_results", select: function(event,ui) { $('#book_results').html(load_img); if (ui.item.category=="books") { $.bbq.removestate(); var paramsobj = { 'b' : ui.item.id

android - error: Only the original thread that created a view hierarchy can touch its views -

hi , thank looking @ question. intermediate programmer in c android newbie. have been trying chat programming working. assuming else in code below works perfectly. 1 question ask when try settext() thread running, exception above. looked @ many many websites , here too. found many things, not understand. please explain me in simple way or offer me simple fix if possible. thank much!! public class chatter extends activity { private string name = "unknown user"; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final edittext msgtoserver = (edittext) findviewbyid(r.id.msgbox); final edittext chatfromserver = (edittext) findviewbyid(r.id.chatbox); final button msgtoserver = (button) findviewbyid(r.id.sendbutton); socket socket = null; string ipaddress = "192.168.1.103"; try { inetaddress servera

java - Create n amount of arrays -

i know how, if possible, create n amount of arrays of same size. appreciated. example: want create 10 arrays same amount of elements without having create them 1 one: int[] = new int[] . hope more clear now. one of questions in 1 of comments +- "how sort array row row / column column". figured out - maybe may find useful. int[] sortarr = new int[5]; //create array transfer data row new array (int i=0; i<n; i++){ (int j=0; j<5; j++){ sortarr[j] = hands[i][j]; //transfer data 2d array's row sortarr } arrays.sort(sortarr); //sort row's data (int x=0; x<5; x++){ hands[i][x] = sortarr[x]; //transfer data 2d array } } maybe it's pretty obvious, hope out there. you need create 2d array. int n; int size; int[][] arr = new int[size][n]; you can fill array nested for loop; for(int =0;i < arr.length; i++) { for(int j = 0; < arr[i].length; j++) { arr[i][j] = somevalue; } } or populate a

php - Two queries to get information -

i have 2 data tables. 1 contains of users identifiable informaiton (username, id, etc) , rest content generated them. doing comments page. when submit comment, user_id goes in comment. on comments page doing query show of comments have use user_id comments pull name user_database. using query below no success. how can tweak it? code: $query="select * comments post_id = '$postid'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo ""; $i=0; while ($i < $num) { $comment=mysql_result($result,$i,"comment"); $user_id=mysql_result($result,$i,"user_id"); $other=mysql_result($result,$i,"other"); echo "<br>$comment, $user_id, $other"; echo ""; $i++; } if(mysql_num_rows($result) < 1) { echo "<div id=noresultfound>no results $comment</div>"; } to information 2 t

java - JPanel: automatically paint at creation? -

this must rather trivial , straight forward, cannot figure out. this jpanel looks like, added jframe: private class radarpanel extends jpanel { public radarpanel() { super(); this.repaint(); } @override public void paintcomponent(graphics g) { super.paintcomponent(g); //painting logic here //repaint in 500 ms this.repaint(500); } } now, when resize jframe jpanel starts getting redrawn time. however, when not resize jframe jpanel's paintcomponent method not seem called, though call repaint in constructor. any advice? thanks. update: more complete code (everything except drawing logic): import java.awt.color; import java.awt.dimension; import java.awt.graphics; import java.awt.event.windowadapter; import java.awt.event.windowevent; import java.util.arraylist; import javax.swing.jframe; import javax.swing.jpanel; public class playerradar ext

Iphone development Certificate issue -

hi have created development certificate using key chain procedure explained on apple website. since have finished app when try create distribution certificate same key used development portal reason dist certificate not hooking key chain development cert. have added manually selecting file>import items. when submit app app store email saying invalid binary , saying certificates not valid. have tried numerous times no result. any appreciated! ok stupid of me being lazy , not reading apple website to. app status wauting review now. did deleted certificatesand started step step apple distribution certification creation , submission , dead seamlesss!.. thank god app on end took ages!!!!!!!!!!!!

web services - Create WCF endpoint configurations in the client app, in code? -

i trying consume wcf web service .net client application, , think need able programmatically create endpoints, don't know how. think need because, when try run application, getting following error: could not find default endpoint element references contract 'iemailservice' in servicemodel client configuration section. might because no configuration file found application, or because no endpoint element matching contract found in client element. while troubleshooting error, created simple windows forms application, in try consume same web service. test application can connect web service successfully, , valid response. but, can reproduce exact error cited above within in test app removing system.servicemodel node , of child nodes application's app.config file (i might not have remove of section, i'm not sure). so, first thought need add section app.config file real app, , should fine. unfortunately, ridiculous reasons won't here, not o

java - Adding list item to JList from another JList -

i have following code working made_list.setlistdata(original_list.getselectedvalues()); here made_list 1 jlist , original_list jlist. if run code selected value original_list replacing previous value in made_list. dont want that. want append instead.. how do ?? 1) model made_list 2) selected items orig_list 3) make new object[] size of 1) + 2) 4) populate 3) items 1) + 2) 5) set make_list model object[] 4) implementation: listmodel made_model = made_list.getmodel(); // 1 object[] orig_sel = orig_list.getselecteditems(); // 2 object[] new_made_model = new object[made_model.size() + orig_sel.length]; // 3 // block 4 int = 0; for(;i < made_model.size(); i++) new_made_model[i] = made_model.getelementat(i); for(; < new_made_model.length; i++) new_made_model[i] = orig_sel[i - made_model.size()); made_model.setlistdata(new_made_model); // 5

sql - Truncating timestamps -

let's suppose have timestamp variable: select timestamp '2011-02-24 08:30:42 +06:00' dual; is there way "truncate" like '2011-02-24 08:00:00 +06:00' (i've cut minutes , seconds, left timezone) the target oracle version 11g r2 sql> select to_timestamp_tz(to_char(timestamp '2011-02-24 08:30:42 +06:00', 'yyyy-mm-dd hh24 tzh:tzm'), 'yyyy-mm-dd hh24 tzh:tzm') dual; to_timestamp_tz(to_char(timestamp'2011-02-2408:30:42+06:00','yyyy-mm-ddtzh: --------------------------------------------------------------------------- 24.02.2011 8:00:00,000000000 +06:00

jquery - Multiple malsup cycle slideshows controlled by 1 pager, startingSlide staying in sync -

ok guys, i'm complicated question. have big slideshow composed of 3 separate malsup cycle slideshows. current slide in front , other 2 behind it, left 1 starting slide -1 of current 1 , right 1 starting slide +1. works. when click #next triggers three, great. problem need implement pager , pager controls central slideshow , not other 2. i need pager able trigger 3 slideshows 3 being devoted initial startingslide relation. here's js code: function featuresslideshow(){ $('ul#main-features-leftbehind').cycle({ startingslide: 0, fx: 'scrollleft', timeout: 0, speed: 1000, easing: 'easeinoutquart', pager: '#main-features-nav', next: 'ul#main-features-upfront' }); $('ul#main-features-rightbehind').cycle({ startingslide: 2, timeout: 0, fx: 'scrollleft', speed: 1000, pager: '#main-features-nav', easing: 'easeinoutquart', next: 'ul#main-features-upfront' }); $('ul#main-features-upfront&

authentication - Persistant Login with connect-auth -

i'm building node.js , using connect-auth user/pass authentication, , i'd allow users logged in long periods of time. playing around , looking through source seems connect-auth depends on connect sessions maintain authenticated state, once session cookie expires (default 4 hrs) user gets logged out. one option fork connect-auth , refactor not dependent on req.session, that's non-trivial. option change default age on session cookie high, want session object able die session. anyone have suggestions? overlooking existing solution? thanks! i wouldn't use/fork connect-auth. plugin of connect breaks onion ring idea/architecture of connect , makes (imho) code unreadable/brings unnecessary complexity. authentification simple library. (if talking simple user login) i'm using self written auth. can find simplified version below. depends on session-cookies can replaced persistant cookies. a simple authentication connect (it's complete. execute t

Convert PHP datetime to MySQL RFC-822 valid Date-Time for RSS Feed -

i want add date/time, created in php, mysql valid in rss feed. i'm using in php $d = date( 'y-m-d h:i:s t', time() ); $mysqldate = gmdate(date_rss, strtotime($d)); inserting datetime field in database but saves in format wed, 02 oct 2002 08:00:00 and need in format rfc-822 valid wed, 02 oct 2002 08:00:00 est use date_rfc822 instead of date_rss

c# - How to pass values of the javascript-created-textboxes to asp.net mvc3 controller? -

i want let user add many tag wants article, have these simple classes: public class tag { public string name { get; set; } } public class article { public list<tag> tags { get; set; } public article() { tags = new list<tag>(); } } and controller looks this: public class homecontroller : controller { public actionresult index() { return view(new article()); } [httppost] public actionresult edit(list<tag> tags) { //tags null here return view(); } } in view have simple textbox link named "add", , submit button. when "add" clicked, calls javascript function take value entered , create new disabled textbox value, disabled textbox placed in specified div. when submit, posts home/edit. "add" part works fine, user can add many tags necessary on fly. the problem is, when submitting, none of newly created disabled textboxes passed in paramet

c++ - CUDA: NVCC gives controlling expression is constant warning on assert -

i warning controlling expression constant on assert statement this: assert(... && "error message"); why warning on assert? how can suppress warning? nvcc nvidia cuda compiler, think based on llvm. why give warning, when same compiles fine gcc or visual c++ compilers? a portable alternative (possibly wrapped in macro) like: { const bool error_message = true; assert([...] && error_message); } to clear meant: #define myassert(msg, exp) { const bool msg(true); assert(msg && (exp)); } // usage: myassert(ouch, && b); ... gives e.g.: assertion "ouch && (a && b)" failed [...]

Unmarshalling to a subclass with JAXB -

i've json this: objects:[{ id:"p452365", type:"photo", link:"http://xxx.zz" }, { id:"v7833", type:"video", link:"http://xxx.yy", length:"4.12" } ] in superclass entity , there're 2 instance variables: id , type. in extended xmladapter class tried cast entity instances subtype ex. photo public hashmap<string, list<column>> unmarshal(feeds f) throws exception { for(feed feed : f.getfeeds()){ system.out.println("entity id feed : " + feed.getid()); for(entity e:feed.getobjects()){ if (e instanceof photo){ // of course it's not } } } return (hashmap<string, list<column>>)fm.map(f.getfeeds()); } of course e isn't instanceof photo, took shot there.:) wanna interfere jaxb process sometime , unmarshall according type value in jso

cocoa touch - WebKit error domain and codes in iOS headers? -

i want trap specific error uiwebview, webkiterrorframeloadinterruptedbypolicychange (102) in webview:didfailloadwitherror: the trouble since webkit framework proper isn't accessible in ios can't find constants anywhere. is solution hard code @"webkiterrordomain" , 102? i hope not :) men.. have same problem. it's lazy, work #define webkiterrorframeloadinterruptedbypolicychange 102 you can use enum if need more constant.

Inserting into 2 tables select result of a table SQL Server -

how insert 2 tables result select statement. i have table several data: val1 val2 val3 .... valn ------------------------- 12 21 54 78 .. .. .. .. i have like: select t1.val1, t1.val2, t2.val3, t2.val4 table1 t1 , table2 t2 tablename. so want val1, val2, being inserted new table 2 fields like: tabble1: id fieldvalue 1 val1 2 val2 the same goes val3 , val4. how can acomplished tabble2: id fieldvalue 1 val3 2 val4 is possible? granted, difficult understand trying accomplish. if in fact trying insert rows 2 different tables, marc_s stated, must use 2 insert statements. however, judging sample, may not case trying insert 2 tables rather use 2 tables insert third table transpose data. if case, can in single statement: insert mysterytable( id, fieldvalue ) select 1, val1 table1 union select 2, val2 table1 union select 3, val3 table2 --assuming these come table2. isn't clear in op union select 4, val4 table2 --assuming the

webview - Android application closed unexpectedly -

i used following code download file. runs fine, when click download button, following error comes: "application mibooks has stopped unexpectedly." how can solve problem in code? package mds.mibooks; import android.app.activity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.webkit.downloadlistener; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.button; public class mibooks extends activity { webview mwebview; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final button button = (button) findviewbyid(r.id.button1); button.setonclicklistener(new onclicklistener() { public void onclick(view v) {

objective c - display popover when user click into text field? -

hi have been following book how display popover when user clicks on toolbar button item. works fine want display popover when user clicks textfield. seems minor adjustment. changing ibaction "showpopover" method bit. code looks method: - (ibaction)showpopover:(id)sender{ if(popovercontroller == nil){ //make sure popover isn't displayed more once in view popovercontroller = [[uipopovercontroller alloc]initwithcontentviewcontroller:popoverdetailcontent]; [popovercontroller presentpopoverfrombarbuttonitem:sender permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; popovercontroller.delegate = self; } } there instance method other "presentpopoverfrombaritem" called "presentpopoverfromrect".would use instead? tried write code i'm not sure how relate textfield or how draw rectangle needed.can me this?thanks. you have use textfields delegate method textviewshouldbeginediting: something this:

ImageMagick php imagick loading a file from memory -

i m trying integrate imagick framework. framework has file in memory. the imagick code works great /* read page 1 */ $im = new imagick( 'test.pdf[0]' ); /* convert png */ $im->setimageformat( "png" ); /* send out */ header( "content-type: image/png" ); echo $im; now problem imagick constructor takes path name. how can load pdf memory. like $im = newimagick($file); $im = new imagick(); $im->readimageblob($file_contents); http://www.php.net/manual/en/function.imagick-readimageblob.php

Rails routes for article/234 and article/index -

i need setup following urls: /article (article#index) /articles/1234 ( article#show id 1234) /articles/new (article#new) can define using: resources :article ??? end if closely @ question, appears want index @ /article instead of default rails rest convention, /articles it doesn't make apparent sense model routes way, if surely want do, add 1 more route line in addition call resources resources :articles match '/article', :to => 'articles#index'

mysql - How to query this situation? -

i wrote question few hours ago many many queries. mellamokb suggested: how list categories, , how many posts in each category, sorted category posts category least. how make query string? can't think start. so... sort of thing looking for? select category.name , count(*) [count] post inner join postcategory on post.id = postcategory.post_id inner join category on postcategory.category_id = category.id order count group category.name

jquery - Prototype fade black and white to color on mouseover -

i want have image black , white, when hover on it, fade color image. i found how jquery, i'm not prototype , can't figure out how convert code work prototype library. can me out please? here jquery function: <script type='text/javascript'> $(document).ready(function(){ $("img.a").hover( function() { $(this).stop().animate({"opacity": "0"}, "slow"); }, function() { $(this).stop().animate({"opacity": "1"}, "slow"); }); }); </script> here css: <style> div.fadehover { position: relative; } img.a { position: absolute; left: 0; top: 0; z-index: 10; } img.b { position: absolute; left: 0; top: 0; } </style> and here body code: <div class="fadehover"> <img src="cbavota-bw.jpg" alt="" class="a" /> <img src="cbavota.jpg" alt="" class="b" /> </div> thank taking time fella out!

c++ - member binary operator and nonmember binary operator in operator overloading -

while trying learning operator overloading, read following statements c++ primer. frankly speaking, not quite understand message these statements want deliver. examples include defining both member binary operator , nonmember binary operator. there difference when using them? ordinarily define arithmetic , relational operators nonmember functions , define assignment operators members: sales_item& sales_item:: operator (const sales_item&) sales_item operator_(const sales_item&, const sales_item&); both addition , compound assignment binary operators, yet these functions define different number of parameters. reason discrepancy pointer. yes, there difference in actual use. in particular, when overload operator non-member function, conversions can applied either operand (or both operands). when overload binary operator member function, conversions can applied right operand. this can lead oddities. example, consider writing "bignum"

Sharepoint 2010 grid view -

how add link column sharepoint grid view? you can use spmenufield. serves 2 purposes - configures hyperlink follow if click on item directly and, optionally, links dropdown menu this great primer on msdn blogs spgridview http://blogs.msdn.com/b/powlo/archive/2007/02/25/displaying-custom-data-through-sharepoint-lists-using-spgridview-and-spmenufield.aspx

java - Resources don't contain package for resource number -

i'm trying write simple app widget has config , uses alarmmanager update @ faster pace (it's clock needs current). followed google's examples on how their documentation. now here's what's going on, clock uses various images display time , when file installed on emulator following error: resources don't contain package resource number 0x7f0700e5 it says 15 different things varying between drawables, drawables-hdpi , strings. @ first thought this solution might fix issue i'm following google's code @ point. here's how config file setup: @override protected void oncreate(bundle savedinstancestate) { log.d(tag, "oncreate"); super.oncreate(savedinstancestate); setresult(result_canceled); setcontentview(r.layout.config); configokbutton = (button)findviewbyid(r.id.btnconfok); configokbutton.setonclicklistener(btnconfokonclicklistener); intent intent = getintent(); bundle extras = intent.getex

image - Python code for Earth mover's Distance -

i looking earth mover's distance(or fast emd) implementation in python. clues on find it, have looked enough on web. want use in image retrieval project doing. thanks. edit: found nice solution using pulp libararies . page has instruction required set up. there excellent implementation in opencv python. name of function calcemd2 , simple code compare histograms of 2 images this: #import opencv library cv2 import * ### histogram function ######################################################### def calchistogram(src): # convert hsv hsv = cv.createimage(cv.getsize(src), 8, 3) cv.cvtcolor(src, hsv, cv.cv_bgr2hsv) # extract h , s planes size = cv.getsize(src) h_plane = cv.createmat(size[1], size[0], cv.cv_8uc1) s_plane = cv.createmat(size[1], size[0], cv.cv_8uc1) cv.split(hsv, h_plane, s_plane, none, none) planes = [h_plane, s_plane] #define numer of bins h_bins = 30 s_bins = 32 #define histogram size hist_s

jquery - Can't work with DOM elements after AJAX call -

i have large ajax response inserts amount of html. after can't work of newly created ids or classes if present when form loaded. i have looked .live() solves 1 of problems not other. i want show div either id or class inserted via ajax .html() when link clicked. example: code: html_out = "<div class='span-1'><a href='#' onclick='show_sub_row(\"#sub_row" + id + "\"); return false;'>[ + ]</a></div>"; html_out += '<div class="hidden_sub_row prepend-2" style="display: none;" id="#sub_row' + id + '">'; html_out += 'content'; html_out += '</div>'; $('#search_results').html(html_out); then after html created try: function show_sub_row(sub_row) { $(sub_row).show('fast'); } i know referencing correct id since can alert(sub_row) , shows correct id matches id shown using firebug inspect hidden div.

java - store the values in a list from database -

in database there table called account .in table 2 fields user , account number . single user has multiple account number. want display account number of particular user in jsp page since question general , not specific suggest @ jdbc tutorial here: http://www.roseindia.net/jdbc/jdbc.shtml (topic 8): retrieving rows database basics : http://www.roseindia.net/jdbc/jdbc-mysql/getallrows.shtml hope helps. if not, please specific in question.

.net - Why is the CLR Object type serializable? -

i surprised find object class decorated serializable attribute. although object instances can useful (for thread synchronization, instance), have no state can meaningfully stored or re-hydrated. problems have encountered if clr object class had not been marked serializeable? if not serializable, no other type in .net serializable given types derive system.object .

cocoa touch - 360 degree view in a iphone -

i want create 360 degree view of object in cocoa , ios. possible ways can that? inputs should provide that. i'm new cocoa please me this. maybe this project help. frankly speaking, don't understand expecting for.

android - Display synced contacts in HTC Sense -

i'm working on syncadapter add contacts webservice. working fine on emulator contacts doesn't show on htc desire running htc sense. i've read sense needs "real" contacts "link" new 1 i'm pretty sure facebook sync application adds new contacts. so know how can done? thanks. ok, got working, have declare account in groups. here i've done : contentproviderclient client = mcontext.getcontentresolver().acquirecontentproviderclient(contactscontract.authority_uri); contentvalues cv = new contentvalues(); cv.put(groups.account_name, account.name); cv.put(groups.account_type, account.type); cv.put(settings.ungrouped_visible, true); client.insert(settings.content_uri.buildupon() .appendqueryparameter(contactscontract.caller_is_syncadapter, "true") .build(), cv);

Want to show sunrise/sunset time on website -

on website want display sunrise , sunset time of place person opening webpage. google web search give sunrise , sunset time if search : http://www.google.com/search?q=sunrise:<city_name> . how can use provide functionality on website? i looking similar service , found http://www.earthtools.org/webservices.htm#sun here's example new york 4th december: http://www.earthtools.org/sun/40.71417/-74.00639/4/12/-5/0

silverlight 4.0 - Playing .SWF file in Silverlinght -

Image
i tring play .swf in silverlight page.i using telerik control below this working fine in internet explorer in mozilla gives option of downloading file rather playing swf could please elaborate more on scenario. i've tried following: <usercontrol x:class="htmlplaceholderandswf.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"> <grid x:name="layoutroot" background="white"> <telerik:radhtmlplaceholder sourceurl="http://www.bassfiles.net/parachute.swf" /> </grid> </usercontrol> ...and works expected, both in ie , ff. internet explorer firefox probably there should setting in firefox preventing playing swf within browser.

Installing java SDK in ubuntu 10.10 -

possible duplicate: how install sun jdk on ubuntu 10.10 “maverick meerkat”? can 1 suggest me how install java sdk in ubuntu 10.10? for openjdk, use aptitude install openjdk-6-jdk for sun distribution, see: how install sun jdk on ubuntu 10.10 “maverick meerkat”?

overloading - C++ [] operator overload problem -

i'm still new c++ daily run new problems. today came [] operator's turn: i'm making myself new generic list class because don't std's one. i'm trying give warm , fuzzy of c#'s collections.generic list, want able access elements index. cut chase: extract template: t& operator[](int offset) { int translateval = offset - cursorpos; movecursor(translateval); return cursor->value; } const t& operator[](int offset) const { int translateval = offset - cursorpos; movecursor(translateval); return cursor->value; } that's code operators. template uses "template", far saw on tutorials, that's correct way operator overloading. nevertheless, when i'm trying access index, e.g.: collections::list<int> *mylist; mylist = new collections::list<int>(); mylist->setcapacity(11); mylist->add(4); mylist->add(10); int = mylist[0]; i th

android - binding adapter to list view -

if(cur.movetofirst()) { do{ int nameidx=cur.getcolumnindexorthrow(contactscontract.contacts.display_name); int ididx=cur.getcolumnindexorthrow(contactscontract.contacts.has_phone_number); string strname=cur.getstring(nameidx); string strid=cur.getstring(ididx); if(strid.equals("0")) continue; toast.maketext(this,"contact name: "+strname, toast.length_long).show(); names.add(strname); //result[cur.getposition()]=strname+"("+strid+")"; }while(cur.movetonext()); adapter=new arrayadapter<string>(this, r.layout.list_view_item, names); setlistadapter(adapter); this code , getting error @ setlistadapter(adapter) setlistadapter undefined. please me in resolving error. you need have object of listview listview lv = (listview) findviewbyid(r.id.lv); then set adapter listview object lv.setadapter(