Posts

Showing posts from April, 2013

vb.net - Sort Datagridview columns when datasource binded to List(Of T) -

i have datagridview datasource binded list(of t). sort on of columns. my code: 'database access : items = list(blogpost) dgblogposts.datasource = items 'my blogpost class public class blogpost public property id integer public property title string public property content string public property creationdate datetime public property rating decimal = 5.0 end class take @ this example recommends using bindinglist instead , bit of code enable sorting. there this on codeproject.

c# - How do I post a single file to an asp.net webform from windows forms? -

how post single file asp.net webform c# windows forms? you can using system.net.webclient. see sample on msdn page: webclient.uploaddata method (system.net)

Custom error messages for standard errors in Cognos 8 -

our cognos 8 application has error affecting many users: http://img543.imageshack.us/img543/6849/aoeu.png cm-req-4158 search path ... invalid. we know how fix problem (it's browser configuration issue) error message not helpful. also, users issue if upgrade ie. so is possible modify error message more useful? i believe way you'll able hone in on messages use language development kit (ldk).. i'm sure can edit them hand, don't think it's worth it.

rest - With Spring 3.0, can I make an optional path variable? -

with spring 3.0, can have optional path variable? for example @requestmapping(value = "/json/{type}", method = requestmethod.get) public @responsebody testbean testajax( httpservletrequest req, @pathvariable string type, @requestparam("track") string track) { return new testbean(); } here /json/abc or /json call same method. 1 obvious workaround declare type request parameter: @requestmapping(value = "/json", method = requestmethod.get) public @responsebody testbean testajax( httpservletrequest req, @requestparam(value = "type", required = false) string type, @requestparam("track") string track) { return new testbean(); } and /json?type=abc&track=aa or /json?track=rr work you can't have optional path variables, can have 2 controller methods call same service code: @requestmapping(value = "/json/{type}", method = requestmethod.get) pu...

println in grails gsp file -

i know simple thing, not aware. i used println in gsp file , expected print output in console. showing on page. <% for(int =0; < threads.size();i++) { println } %> thanks. you can use <% system.out.println %> but why use sniplets in gsp page? if want console debug output gsp suggest using plugin: https://grails.org/plugin/debug

wcf - Service Contract Implements another Interface -

please tell me if possible. have client win form app , wcf app in c#. model. common project public interface iservicea { string doworka(); } i not using servicecontract or operationcontract attributes here in common project. now, clientproject references common project. serviceproject references common project. in serviceproject, using service contract shown below: [servicecontract] public interface igetdata : iservicea { // implements iservicea method [operationcontract] string doworka(); } public class myservice : igetdata { string doworka() { } } in client side public class myclass : iservicea { // implements iservicea method string doworka() { // inside call myservice using duplexchannel proxy } } [please assume callback contract implemented in model] why asked question that, in application, have lot of modules, each needs data service own method. planning use facade pattern. please tell me if correct ...

generics - Code explanation in Java -

this morning came across code, , have absolutely no idea means. can explain me these <t> represent? example: public class myclass<t> ... bits of code private something<t> so; private otherthing<t> to; private class<t> c; thank you you have bumped "generics". explained nicely in guide . in short, allow specify type storage-class, such list or set contains. if write set<string> , have stated set must contain string s, , compilation error if try put else in there: set<string> stringset = new hashset<string>(); stringset.add("hello"); //ok. stringset.add(3); ^^^^^^^^^^^ //does not compile furthermore, useful example of generics can allow more closely specify abstract class: public abstract class abstclass<t extends variable> { in way, extending classes not have extend variable , need extend class extends variable . accordingly, method handles abstclass can defined this: p...

python - What does "str indices must be integers" mean? -

i'm working dicts in jython created importing/parsing json. working sections see following message: typeerror: str indices must integers this occurs when like: if jsondata['foo']['bar'].lower() == 'baz': ... where jsondata looks like: {'foo': {'bar':'baz'} } what mean, , how fix it? you need check type dict , existance of 'z' in dict before getting data dict. >>> jsondata = {'a': '', 'b': {'z': true} } >>> key in jsondata: ... if type(jsondata[key]) dict , 'z' in jsondata[key].keys() , jsondata[key]['z'] true: ... print 'yes' ... yes >>> or shorter 1 dict.get >>> jsondata = {'a': '', 'b': {'z': true}, 'c' :{'zz':true}} >>> key in jsondata: ... if type(jsondata[key]) dict , jsondata[key].get('z',false): ... print ...

uiviewcontroller - iPhone - how to find a parent View -

i need find view inside hierarchy. here how build view stack. inside first uitableviewcontroller push uiviewcontroller contains uitabbarcontroller: [[self navigationcontroller] pushviewcontroller:itemvc animated:yes]; inside uitabbarcontroller add uitableviewcontroller: isstableviewcontroller *graphics = (isstableviewcontroller *)[tabbarcontroller.viewcontrollers objectatindex:3]; inside didselectrowatindexpath present modal view controller using uinavigationcontroller: graficoviewcontroller *graph = [[graficoviewcontroller alloc] initwithnibname:@"graficoviewcontroller" bundle:nil]; uinavigationcontroller *navigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:graph]; [self presentmodalviewcontroller:navigationcontroller animated:yes]; [navigationcontroller release]; now (big) question is: have hide nagivationbar of first uitableviewcontroller inside last view. tried this: [[[[[self parentviewcontroller] parentvie...

html - Resize TD in a table -

i re-building table display page, wanted know if it's possible resize td without inline styles, add class width , height? example: <td class="td_class">blah</td> .td_class { height:30px; width:80px; } probably can, wanted make sure when make table. yes, can. wouldn't call resizing however. setting width , height of table cell. resizing synonymous manipulating dom javascript.

Creating jQuery helper plug-in -

how write jquery helper plug-in can invoke $.myplugin() , opposed $.fn.myplugin() ? with plug-in created in following way, can call $("selector").myplugin() or $.fn.myplugin() . (function( $ ){ $.fn.myplugin = function() { }; })( jquery ); , myplugin() helper function doesn't need this reference. idea? @andres has provided 1 of possibilities of defining jquery plugin, though it's more usual define plugin using $.extend functionality. (function($) { // plugin closure var defaults = { ... }; $.extend({ myplugin: function(options) { // when options needed options = $.extend({}, defaults, options); // functionality afterwards } }); })(jquery);

svn - Subversion - put version number in a file -

i want single file, called "revision", contains repository revision number @ given time when export repository, application able see revision was. how can this? the problem using normal keyword substitution $rev$ shows last revision in file changed. haven't tried myself, there tool called svnversion comes svn believe can use revision number of working copy. it's case of configuring build process use tool , insert result revision file. there guide on how use svnversion (especially if you're using ant) here: http://cameronstokes.com/2009/12/12/using-svnversion-from-ant

ASP.NET MVC3 Razor - lost intellisense when placing view in alternate location? -

vs2010 ultimate, asp.net mvc 3 w/razor. i've created custom view engine in mvc3 app allows nested areas, so ~/areas/admin /marketing /views index /controllers marketingcontroller /email /views index ... /controllers emailcontroller /templates /views index edit ... /controllers templatescontroler etc. this works great, except seem have lost intellisense in views aren't in standard ~/areas/area_name/views/myview.cshtml location. any suggestions? update just on lark, added @inherits statement @inherits system.web.mvc.webviewpage<namespace.models.class> and intellisense started working. deleted statement, , continues work. is there setting in project file or tells visual studio sort of intellisense apply open ...

iphone - Why doesen't it work to write this NSMutableArray to a plist? -

edited. hey, trying write nsmutablearray plist. compiler not show errors, not write plist anyway. have tried on real device too, not simulator. basically, code does, when click accessoryview of uitableviewcell , gets indexpath pressed, edits nsmutablearray , tries write nsmutablearray plist. reloads arrays mentioned (from multiple plists) , reloads data in uitableview arrays. code: nsindexpath *indexpath = [table indexpathforrowatpoint:[[[event touchesforview:sender] anyobject] locationinview:table]]; [arrayfav removeobjectatindex:[arrayfav indexofobject:[nsnumber numberwithint:[[arraysub objectatindex:indexpath.row] intvalue]]]]; nsstring *rootpath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring *plistpath = [rootpath stringbyappendingpathcomponent:@"arrayfav.plist"]; nslog(@"%@ - %@", rootpath, plistpath); [arrayfav writetofile:plistpath atomically:yes]; // reloads data arrays...

ruby - Rails iteration with some smarts -

i'm putting little game people voting see 2 other people match based on interests they've entered , i'm having trouble getting code want. have data "friends" , i'd following: select 1 of "friends" find match of friend if can't find friends' matches voted on, random match i'd steps 1 , 2 random don't see friend each time. recording votes now, have list of votes already. have far, can't figure out how put 2 together. found_new_match = false #try connected users first # connected_users = current_user.get_connected_users connected_users = [] unless connected_users.blank? user = connected_users.shuffle.first @match = user.matches.first end # here i'd detect whether got through our connections' matches while found_new_match == false found_new_match = true if @match = current_user.get_random_new_match end assuming supporting logic of code (getting connected users) works correctly , question how co...

Can anyone recommend a method to perform the following string operation using C# -

suppose have string: "my event happened in new york on broadway in 1976" i have many such strings, locations , dates vary. example: "my event happened in boston on 2nd street in 1998" "my event happened in ann arbor on washtenaw in 1968" so general form is: "my event happened in x on y in z" i parse string extract x, y , z i use split , use sentinel words "in", "on" delimit token want seems clunky. using full parser/lexer grammatica seems heavyweight. recommendations gratefully accepted. is there "simple" parser lexer c#? try using regex pattern matching. here's msdn link should pretty helpful: http://support.microsoft.com/kb/308252 an example might help. note regex solution gives scope accept more variants , when see them. reject idea regex overkill, way. i'm no expert it's easy stuff wonder why it's not used more frequently. var regex = new regex( "(?...

c# - RegisterStartupScript not working after upgrading to framework 3.5 -

i'm trying upgrade asp.net c# web project framework 2.0 3.5. when this, client side script gets written using registerstartupscript isn't rendered on client page. this works when compile 2.0, , 3.0, not when compile 3.5. here code isn't getting rendered: page mypage = (page)httpcontext.current.handler; scriptmanager.registerstartupscript(mypage, mypage.gettype(), "alertscript", "alert('test');", true); this called class project, , not web project itself, why i'm using httpcontext.current.handler. there no errors getting generated compiler, clr, , there no client side javascript errors. if search "alertscript" in rendered page, above code isn't there. anyone have ideas going on? -edit- this seems issue when i'm trying register script external project. if use exact same code in class file in web project (not code behind), works. however, if make call method in class project, not work. does scriptman...

objective c - How to wrap the data in a label of a cell in iphone? -

im passing huge data label of cell.so need wrap line.i tried below methods ------- cell.textlabel.linebreakmode = uilinebreakmodewordwrap; cell.textlabel.linebreakmode =uilinebreakmodetailtruncation;by truncating label no use.in way problem didnt solved.i want data displayed in same font size also.if label of cell containg less data,the font size different , if label of cell containing more data,the font size small.please me out.....thanks in advance you can find uilabels expected size programetically , appply word wrap..please refer this. uilabel size according text

ubuntu - hg serve simply hangs in terminal -

i've started using mercurial personal projects , i'm going through joel's tutorial here: http://hginit.com/02.html the problem when type in hg serve in terminal, hangs. other commands hg init works perfectly. know what's going on? i installed mercurial doing this: sudo apt-get install mercurial meld you want use -d option run in background: hg serve -d otherwise run foreground process, logging stdout , stderr. run hg serve see more options.

jquery - Combine multiple JSON values as one variable -

currently i'm working on assignment wanted me value 2 json results. here stuck: 1) have 2 json urls both return different values: function aa(){ $.getjson("url1.js", function(valuea){ valuea.json; }); } function bb(){ $.getjson("url2.js", function (valueb){ valueb.json; }); } 2) then, need combine both results , math in jquery: function math() { result = valueb.json / valuea.json; alert(result); } i can parse both json results failed combine in math function. should in order make work? thanks :| the ajax calls, name state, asynchronous. first need "synchronize" them perform math, ie have wait both of them have loaded before math. to so, put in callback function call checker function check if 2 ajax calls ended, , if perform math. here's how it: var valuea, valueb; function checkifeverythinisfine() { if ( (valuea || valuea === 0) && (valueb |...

C# Bind DataTable to Existing DataGridView Column Definitions -

i've been struggling nullreferenceexception , hope here able point me in right direction. i'm trying create , populate datatable , show results in datagridview control. basic code follows, , execution stops nullreferenceexception @ point invoke new updateresults_delegate. oddly enough, can trace entries.rows.count before return queryevententries, can @ least show 1) entries not null reference, , 2) datatable contains rows of data. know have doing wrong, don't know what. private void updateresults(datatable entries) { datagridview.datasource = entries; } private void button_click(object sender, eventargs e) { performquery(); } private void performquery() { datetime start = new datetime(datetimepicker1.value.year, datetimepicker1.value.month, datetimepicker1.value.day, 0, 0, 0); datetime stop = new datetime(datetimepicker2.value.year, ...

events - Add server control to my custom webcontrol that fires javascript function and a server side function -

in asp.net, trying create webcontrol. in control, have rendercontrol method overridden html controls. protected override void rendercontents(htmltextwriter output) { output.write(@"<table><tr><td>"); output.write(@"<input type=""submit"" name=""btnexecute"" value=""execute"" id=""btnexecute"" />"); output.write(@"</td></tr></table>"); } how can make button call click event server side method btnexecute_click() can called? also, button calls javascript function before server side even. please suggest how make work. check out example on how implement compositecontrol (which derivative of webcontrol). http://msdn.microsoft.com/en-us/library/3257x3ea.aspx#y114 your button there exist private member of composite. you'll initialize , wire server-side method in createchildcontrols. you'll call button...

orm - SQL-wrappers (activerecord) to recommened for python? -

is there activerecord (any similar sql-wrapper) python? for: used in server-side python script light-weight supports mysql what need do: insert (filename, file size, file md5, file itself) (string, int, string, blob) columns if same file (checksum + filename) not exist in db thx you might consider sqlalchemy along elixir : elixir declarative layer on top of sqlalchemy library. thin wrapper, provides ability create simple python classes map directly relational database tables (this pattern referred active record design pattern), providing many of benefits of traditional databases without losing convenience of python objects.

css - Centering a div to the middle of the web page? -

i want make div positioned in middle-center part of web page. i'm attempting make pre-loader div should in middle-center part of web page , after page loads, div hidden. how can achieve such? the div should centered horizontally , vertically. to center div both hor , ver way: markup <div class="centered"></div> css .centered{ position:absolute; width:100px; height:100px; left:50%; top:50%; margin-left:-50px; margin-top:-50px; } fiddle: http://jsfiddle.net/steweb/qsvaq/1/

PHP recursion: How to create a recursion in php -

i have little problem recursion in php. have read many articles solution doesn't come. i have array: [59] => array ( [id] => rel000000 [name] => religione / generale [description] => [idparent] => ) [799] => array ( [id] => rel102000 [name] => religione / teologia [description] => [idparent] => rel000000 ) [800] => array ( [id] => rel068000 [name] => religione / teosofia [description] => [idparent] => rel000000 ) [801] => array ( [id] => rel103000 [name] => religione / universalismo unitario [description] => [idparent] => rel000000 ) [802] => array ( [id] => rel034000 [name] => religione / festività / generale [description] => [idparent] => rel000000 ) i create hierarchical tree idparent fie...

apache2 - Require ruby gems in rails controller -

require 'rubygems' require 'mechanize' agent = mechanize.new page = agent.get("http://google.com/") this simple script works ok. but if i'am trying add require 'rubygems' , require 'mechanize' rails controller, server gives: loaderror in newscontroller#find no such file load -- mechanize i use rvm on ubuntu 10.04 server machnine. ruby version: 1.9.2, rails version: 3.0.3. server: passanger under apache2. p.s. if run rails server , go mysite.com:3000 works without error, there problem passanger! please, me! you shouldn't require gems in controller. thats why bundler added rails 3. add mechanize gemfile this gem "mechanize" and run bundle install on command line. gem mentioned here required on application startup.

asp.net - How to resize animated gif file using imagemagick without destroying animation using C#? -

Image
i using imagemagick dll (refer: http://www.imagemagick.org ) resize image, when re-sized animated gif image going screw. i using below code re-size image ( image type png, gif, jpg, bmp, tif ...) imagemagickobject.magickimage imglarge = new imagemagickobject.magickimage(); object[] o = new object[] { strorig, "-resize", size, "-gravity", "center", "-colorspace", "rgb", "-extent", "1024x768", strdestnw }; imglarge.convert(ref o); how can fixed it. see result image i think have extract every single frame gif first, resize every single frame , put together. edit: this? not tested nor builded... int maxframes=32; imagemagickobject.magickimage imglarge = new imagemagickobject.magickimage(); // first extract frames gif single png files for(int frame=0; frame<maxframes;frame++) { object[] o = new object[] { string.format(strorig+"[{0}]", frame) , string.format("tmp{0...

c# - Moving delegate-related function to a different thread -

we developing library in c# communicates serial port. have function given delegate. problem want run in different thread. we tried creating new thread (called datafrombot) keep using follows (first line): comport.datareceived += new serialdatareceivedeventhandler(comport_datareceived); datafrombot = new thread(comport_datareceived); datafrombot.start(); comport_datareceived defined as: thread datafrombot; public void comport_datareceived(object sender, serialdatareceivedeventargs e) { ... } the following errors occur: error 3 best overloaded method match 'system.threading.thread.thread(system.threading.threadstart)' has invalid arguments c:...\ir52clow\communicationmanager.cs 180 27 ir52clow error 4 argument '1': cannot convert 'method group' 'system.threading.threadstart' c:...\ir52clow\communicationmanager.cs 180 38 ir52clow any ideas of how should convert compile? please note comp...

how to us .dll in java based web application -

i have web based j2ee application. there way use .dll file in it. yes, can use jni / system#loadlibrary() same way in normal java application. need realize runs @ server side, not @ client side. if intent run @ client side, need serve in flavor of applet or webstart application .

CSS: can I hide the borders of the searchbox? -

can hide borders of searchbox ? white, text should visible. , need solution browsers. see picture: http://dl.dropbox.com/u/72686/searchbox.png you can add this <input name="textfield" type="text" class="hide_border" id="textfield" /> css .hide_border{ border:none; *border:solid 1px #fff; }

Android camera intent -

i need push intent default camera application make take photo, save , return uri. there way this? private static final int take_picture = 1; private uri imageuri; public void takephoto(view view) { intent intent = new intent(mediastore.action_image_capture); file photo = new file(environment.getexternalstoragedirectory(), "pic.jpg"); intent.putextra(mediastore.extra_output, uri.fromfile(photo)); imageuri = uri.fromfile(photo); startactivityforresult(intent, take_picture); } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); switch (requestcode) { case take_picture: if (resultcode == activity.result_ok) { uri selectedimage = imageuri; getcontentresolver().notifychange(selectedimage, null); imageview imageview = (imageview) findviewbyid(r.id.imageview); contentresolver c...

javascript - Mapstraction: Changing an Icon's image URL after it has been added? -

i trying use marker.seticon() change markers image. appears although changes marker.iconurl attribute icon using marker.proprietary_marker.$.icon.image display markers image - markers icon remains unchanged. there way dynamically change marker.proprietary_marker.$.icon.image ? add marker. check icon's image url , proprietary icon's image - they're same. change icon. again check urls. icon url has changed marker still shows old image in proprietary marker object. <head> <title>map test</title> <script src="http://maps.google.com/maps?file=api&v=2&key=your-google-api-key" type="text/javascript"></script> <script src="mapstraction.js"></script> <script type="text/javascript"> var map; var marker; function getmap(){ map = new mxn.mapstraction('mymap','google'); map.setcenterandzoom(new mxn.latlonpoint(45.559242,-122.636467), 15); } ...

android - Galaxy S screen DPI -

i developing , testing android application on galaxy s device, should (according android dev site) normal size screen (4 inch) hdpi (233dpi). for reason, drawables put in drawable-mdpi shown instead of ones in drawable-hdpi. seems device "thinks" it's mdpi device reason... any ideas? ok, wasn't long until found solution here, here others how might same problem. in android manifest, did not mention min sdk version using element. default values 1 , means application says supports versions, including old 1.x versions. in screen support article ( http://developer.android.com/guide/practices/screens_support.html ) noticed rather small sentence: " all applications written android 1.5 or earlier (by definition) designed baseline hvga screen used on t-mobile g1 , similar devices, size normal , density mdpi. " it seems since did not mention value min sdk version, device treats app compatible old versions , ignores whole screen range support! d...

java - How to create a commons-net FTPClient from a URL -

is there way construct ftpclient instance url such ftp://user:pass@foo.bar:2121/path , similar ftpurlconnection in jdk? if problem parsing use code below parse , create wrapper class ... import java.net. ; import java.io. ; public class parseurl { public static void main(string[] args) throws exception { url aurl = new url("http://java.sun.com:80/docs/books/tutorial" + "/index.html?name=networking#downloading"); system.out.println("protocol = " + aurl.getprotocol()); system.out.println("authority = " + aurl.getauthority()); system.out.println("host = " + aurl.gethost()); system.out.println("port = " + aurl.getport()); system.out.println("path = " + aurl.getpath()); system.out.println("query = " + aurl.getquery()); system.out.println("filename = ...

audio - pause sound in flash using as2 -

i'll using as2 in pause button on (press) { if (pause!=true) { playing=false; paused=true; stopped=false myconditiontext="paused"; mymusicposition=_root.my_sound.position/10000; _root.my_sound.stop("sound1"); } } but whn play sound 1 time i want loop sound how can loop sound... please me. on pause button is: on (press) { if (playing!=true) { playing=true; paused=false; stopped=false myconditiontext="playing"; _root.my_sound.start(mymusicposition,0); } _root.my_sound.onsoundcomplete = function() { _root.mycondition.textcolor = 0x00ff00; myconditiontext="completed"; } } you can specify number of loops when calling sound.start() . or listen onsoundcomplete (like do) , start sound over.

Java String contains extraneous data -

i have input in utf16le encoding. time input reaches code been through fileinputstream encased in filereader encased in linenumberreader. the first line read gives string like: "1 piece of data string" however, looking string value along lines of: [, 1, p, i, ...] notice empty element start. no string passed through couple of functions here , there, converted object , being put through paces. @ point, should first part of string (the 1 or in case number including decimals) passed function has parse actual number. the content of string appears "1" in value says: [, 1, p, i, ...] so whole string still in there. in case returns parseexception , print unparseable number exception messages , logging tels me "1" unparseable number. the real problem appears leading empty element subsequent lines show similar behavior except leading empty element , parse. a string (at least implementation in openjdk) stores char[] , offset ...

sql - MYSQL: COUNT with GROUP BY, LEFT JOIN and WHERE clause doesn't return zero values -

i'm sure has simple answer, can't seem find (not sure search on!). standard count / group query may this: select count(`t2`.`name`) `table_1` `t1` left join `table_2` `t2` on `t1`.`key_id` = `t2`.`key_id` `t1`.`another_column` = 123 and works expected, returning 0 if no rows found. however: select count(`t2`.`name`) `table_1` `t1` left join `table_2` `t2` on `t1`.`key_id` = `t2`.`key_id` `t1`.`another_column` = 123 group `t1`.`any_col` only works if there @ least 1 row in table_1 , fails miserably returning empty result set if there 0 rows. return 0! enlighten me on this? beer can provided in exchange if in london ;-) the reason returns 0 rows grouping on value in table_1. since there no values in table_1, there no rows return. said way, if returned t1.any_col in query group so: select `t1`.`any_col`, count(`t2`.`name`) `table_1` `t1` left join `table_2` `t2` on `t1`.`key_id` = `t2`.`key_id` `t1`.`another_column` = 123 group `t1`....

c++ - Create and access frozenset with Boost Python -

i have c++ methods have std::set<std::string> argument or return value. map python frozenset (or regular set ) there not seem straightforward way this. know how 1 may accomplish task. unfortunately, standard indexing_suite boost.python not support std::set . there indexing_suite v2, works on stl containers. (http://mail.python.org/pipermail/cplusplus-sig/2009-july/014704.html) it may not have made official distribution, can find asking around. (http://mail.python.org/pipermail/cplusplus-sig/2009-july/014691.html) i found harder use original indexing_suite , might fit needs. if not work, can manually wrap std::set<std::string> other class. std::set<std::string> python, can turn python set easily. i think both of more work called though. here do: first, wrap function in c++ 1 has same signature, stuffs returned data in std::vector<std::string> instead of std::set<std::string> . expose function rather original now have data ...

Multiplication in Django view -

i trying represent decimal values percentages in template. specifically, have several fields in model values such '0.4000000059604645'. in models.py have representated as information_percent = models.floatfield(blank=true) and in view have: org = organizationaldata.objects.get(name=organization) information_percent = org.information_percent what cannot figure out how show as, instance, '40.0' in template. have done lot of searching , can't figure out how multiply value 100, or other technique deliver intended result. and suggestions appreciated. sounds need built-in floatformat template filter . for example: views.py org = organizationaldata.objects.get(name=organization) information_percent = 100 * org.information_percent template.html <span>info percent: {{ information_percent|floatformat:1 }}</span>

c# - Extension methods require declaring class to be static -

why extension methods require declaring class static? compiler requirement? it's dictated in language specification, section 10.6.9 of c# 4 spec: when first parameter of method includes modifier, method said extension method. extension methods can declared in non-generic, non-nested static classes. first parameter of extension method can have no modifiers other this, , parameter type cannot pointer type. it's not clear me why all of these restrictions necessary - other potentially compiler (and language spec) simplicity. can see why makes sense restrict non-generic types, can't see why have non-nested , static. suspect makes lookup rules considerably simpler if don't have worry types contained within current type etc, dare possible. i suspect complexity of not having these restrictions deemed less benefit gained. edit: clear, i'm not suggesting make sense have instance methods extension methods - i'm suggesting make se...

internet explorer - Fill remaining screen height with CSS -

i'm building page layout 3 divs: header , footer fixed heights in pixels, , content div in middle of page should fill remaining screen height. furthermore, want able set height 100% in inner content divs, because 1 of them host kind of drawing area need fill remaining screen height. so, it's important inner divs not leak under header or footer. far, achieved 100% valid css solution work in majors browsers except internet explorer 6 & 7. is there can fix layout ie6 & 7? or, see way want? here code: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>the #content div fill remaining height , appears have height</title> <style type="text/css"> <!-- * { ...

java - what is the parameter passing to the OnClickListener()? -

i'm new java c family background. i'm unable dissect code. if me identifying inner classes , interfaces in block: startbutton.setonclicklistener(new view.onclicklistener(){         public void onclick(view view)         {                                               usrnameobj = (edittext)findviewbyid(r.id.et_usename);            usrpassobj = (edittext)findviewbyid(r.id.et_password);         string username = usrnameobj.gettext().tostring();         string password = usrpassobj.gettext().tostring();                 intent i=new intent(getapplicationcontext(),androidxmlresource.class);         i.putextra("entry",username.tostring() + password.tostring());         startactivityforresult(i,req_code);               }          }); i can imagine to: startbutton.setonclicklistener(new view.onclicklistener()); but nothing between { } onclicklistener interface defined view class . imagine this: class view { static interface onclicklistener...

VS2010 asp.net: executing parameter less stored proc to update record -

i execute stored proc updates record. @ point keep parameter less. in future, adding parameters stored proc. can via sqldatasource? save me writing few lines of code execute stored proc in traditional ado.net. if possible, please supply me sample code? thanks you use system.data.sqlclient.sqlcommand something this... sqlcommand command = new sqlcommand("p_updatesomething", connectionstring); command.commandtype = commandtype.storedprocedure; command.executenonquery(); or using sqldatasource like <asp:sqldatasource id="sqlds" runat="server" updatecommand="pupdatesomething" updatecommandtype="storedprocedure"></asp:sqldatasource> update parameters can added sqldatasource.

php - Switch placement of values in comma delimited string -

i have comma delimited string held within database field contain number of values: 23,45,21,40,67,22 i need able somehow switch 2 values, example know need move 45 1 position down string, end with: 23,21,45,40,67,22 the reason numbers correspond ids held in database table, , position in sting determine order items printed on screen. before ask database design - i've inherited , cannot changed without significant work entire application. so i've thought exploding string, identifying position of target number , swapping 1 next-door, i'm unsure of how can achieved when total number of values not known. any things? suspect solution cumbersome, needs must!! assuming need move desired value down 1 position in array: $values = explode(',', $data_string); $value_to_move = 45; $value_count = count($values); for($i=0;$i<$value_count;$i++) { if($values[$i] == $value_to_move) { if($i < ($value_count-1)) { // if value ...

java - Could someone explain Spring Security BasePermission.Create? -

i working on project involves spring security acl , came across create permission basepermission.create . please explain how supposed work or allows do? it understanding each object has acl, , each acl has many ace's, , each ace has sid , permission. how can grant permission on object create it, if must created in order attach acl it? spring security grants permissions on domain objects indirectly via objectidentity interface. as mention, far usual case create or obtain domain object first, , construct objectidentityimpl domain object: mydomainobject secured = new mydomainobject(); objectidentity securedidentity = new objectidentityimpl(secured); you use objectidentity instance retrieve acl using spring security framework. however, not way use object identity. can pass reference objectidentity not actual business object, has means of identifying it, if created. for example, imagine wanted secure files. create objectitentity java.io.file instance being s...

Best Lightweight HTML Parser for Delphi -

i need parse out values data select boxes. example: <option value="1">apple</option><option value="2">chicken</option> usage: if option = apple value. any suggestions? dihtmlparser ? i'm not sure how "lightweight" is, ralf's components seemed put together. he's active , response on embarcadero's forums. if it's one-off , not complex, split on symbols manually.

java - Use a subclass object to modify a protected propety within its superclass object -

sorry crappy title failed think of better version java question. right using java version: 1.6.0_18 , netbeans version: 6.8 now question. what i've done created class 1 protected int property , next made public method set int property given value. made object of class , used said public method set int property 5. need create class take said object , expose it's protected int property. the way think of doing create sub class inherit said class , create method int property of super class. kind of succeeded create code int property can't figure out how use new sub class reference object of super class. here 2 classes have far: public class { protected int inumber; public void setnumber ( int anumber ) { inumber = anumber; } } public class b extends { public int getnumber() { return super.inumber; } } i created object of 'a' , used method set property 5, this: obja = new a(); obja.setnumber ( 5 ); now want create object of ...

iphone - Should I save in plist or Core Data? -

i'm wondering if should save data in app plist or using core data.. my app saving tweets timeline , other users now. less few hunderd kb (about 200 kb in testing). what's advantages of using core data? i not consider plists other saving simple preferences , basic data structure. plus performance wise, retrieving , saving data plists can quite slow. after struggling coredata long time, choose on day. yes have bit of steep learning curve there "for free" it, i'd invest time learn , explore it. coredata give flexibility expand object models needed, fetch objects persistant storage based on parameters, create relationships between models, memory management , list goes on. coredata documented apple find need started plus more. there examples, sample projects, videos, name - i'd definitly recommend have if interested in performance, scalability , having bit of fun :)

php - MySQL Query problem in CodeIgniter -

so i'm using following: $r = new record(); $r->select('ip, count(*) ipcount'); $r->group_by('ip'); $r->order_by('ipcount', 'desc'); $r->limit(5); $r->get(); foreach($r->all $record) { echo($record->ip." "); echo($record->ipcount." <br />"); } standard: select `ip`, count(*) ipcount (`soapi`) group `ip` order `ipcount` desc limit 5; and last (fifth) record echo'ed out , no ipcount echoed. is there different way go around this? i'm working on learning datamapper (hence questions) , need figure of out. haven't quite wrapped head around whole orm thing. is there way set count(*) ipcount without funny select() statement? don't think it's triggering reason. bug in datamapper, i'm less of that. also found if use $r->query() method doesn't return except last entry if use select ip from soapi where 1; . ...

sql server - SQL Complex Select - Trouble forming query -

i have 3 tables, customers, sales , products. sales links customerid productid , has salesprice. select products.category, avg(saleprice) sales inner join products on products.productid = sales.productid group products.category this lets me see average price sales category. however, want include customers have more 3 sales records or more in db. i not sure best way, or way, go this. ideas? you haven't mentioned customer data anywhere i'll assume it's in sales table you need filter , restrict sales table first customers more 3 sales, join product category , average across categories select products.category, avg(saleprice) (select productid, saleprice sales group customerid having count(*) > 3) s inner join products on products.productid = s.productid group products.category

Upgrading from visual studio 2005 to visual studio 2010 -

our development team planning upgrade visual studio 2005 visual studio 2010 -- skipping out visual studio 2008. most of projects vb asp.net projects , using sql server 2008 database. does know if vs 2005 projects upgrade seamlessly vs 2010, or should first upgraded vs 2008? there gotchas? they upgrade normal, no need go through vs2008 first. i've upgraded vc++ 6 projects straight vs2010 without issue! (well, except c++ non-conformance problems inherent in vc6 project)

.net - Performance: XmlReader or LINQ to XML -

i have 150 mb xml file used db in project. i'm using xmlreader read content it. want know if better use xmlreader or linq xml scenario. note i'm searching item in xml , display search result, can take long time or moment. if want performance use xmlreader. doesn't read whole file , build dom tree in memory. instead, reads file disk , gives each node finds on way. with quick google search found performance comparison of xmlreader, linqtoxml , xdocument.load. https://web.archive.org/web/20130517114458/http://www.nearinfinity.com/blogs/joe_ferner/performance_linq_to_sql_vs.html

ruby on rails - Keyboard Shortcut for RoR pair of brackets -

i have ruby on rails (ror) document opened , want make <%= %> pair of brackets. in textmate, it's under bundles > ruby > insert erb's , key command looks ^ > how type on mac? tried alt + right bracket , shift + alt + right . you need use key combination ctrl + shift + >

Why do browsers allow switching off Javascript? -

am curious why modern browsers allow switching off javascript. it's clear substantial modern web application need integrate high level of javascript, why cant javascript made integral part of browser? becomes more annoying when option off default (ie!!) my opinion is, should made standard browsers have javascript option enabled default. what guys think? i'm sure you're venting here, being able turn off javascript thing many reasons both developer , otherwise: makes easier debug problems html , css helps lot of privacy issues can avoid malware , other security issues speeds browser, reduces memory leaks, etc also, fwiw, there no browser ships default of javascript being off, ie included. perhaps you're dealing corporate installation customized defaults?

python - How to get debugging of an App Engine application working? -

i've got 10+ years in c/c++, , appears visual studio has spoilt me during time. in visual studio, debbuging issimple: add breakpoint line of code, , code executed, breakpoint triggers, @ point can view callstack, local/member variables, etc. i'm trying achieve functionality under app engine. assume possible? all searching i've done point has led me using pydev in eclipse. best can tell, launching simple 'hello world' program in debug mode. but ide doesn't seem have option set breakpoint? must missing something. i've googled long , hard this, having no luck. results trace same old threads don't deal directly issue. can shed light on how basic debugging setup using pydev/eclipse app engine? alternatively, if there's easier way debug app engine using pydev/eclipse, i'd love hear it. thanks in advance. in fact setting breakpoint in eclipse easy. have 2 options: in grey area next line numbers, doubleclick or right mouseclick...

emacs - Move to next message -

i have messages line this: message 1 answer 1.1 answer 1.1.1 answer 1.2 answer 1.3 massage 2 ... and have line in .gnus.el: (global-set-key [f9] (lambda () (interactive) (gnus-summary-lower-score-by-subj-substr-temp))) when select "message 1" , press f9 next lines: message1 answer 1.1 answer 1.1.1 answer 1.2 answer 1.3 change score. but need selection move next message (message 2) when press f9. how can it? i have found solution: (global-set-key [f9] (lambda () (interactive) (gnus-summary-lower-score-by-subj-substr-temp) (gnus-summary-next-thread 1))) ;; lower subject

Magento 1.4.2 - Set Address Fields During Registration -

i trying populate address fields during registration, using data system. in observer, able use $customer = $observer->getcustomer(); $customer->setfirstname($value); $customer->setlastname($value); and information saved in database, but $customer->setstreet($value); $customer->setpostcode($value); $customer->settelephone($value); do not. how set address fields? thanks! addresses not stored in mage_customer_model_customer object. should instead like: $address = mage::getmodel('customer/address'); $address->setstreet(...); ... $customer->addaddress($address);

javascript - jQuery - Simple Ajax Error, Or complex Safari Issue? -

this following code snippet works in ff, ie , chrome. not work in safari 5.0.3! safari not return error message of kind. ( please take note 'debugger;' command reason never catches in browser , alert pop never happens 'alert ('pop close');', ajax seems work in mentioned 3 still somehow ) $(document).ready(function(){ // debugger; <-- works $(".oscform").click(function(){ debugger; // <-- doesn't alert ('pop close'); getcodeez(''+$(this).attr('lmgthing'),''+$(this).attr('ezprod'),''+$(this).attr('count')); $.ajax({ url: '/shopping_cart.php?oscsid=<?php echo $oscsid; ?>', type: "post", data: 'sort=2a&amp;ezprod='+$(this).attr('ezprod'), async:false, error: function(xhr,err){}, success: function(data){} } ...

javascript - How to fade in with jQuery -

my idea fade in tab loaded. this code seems should work, doesn't fade in. wrong? $(document).ready(function() { $("#logo").click(function(event) { $("#central").fadein("slow").load('page.html'); }); }); you have hide #central first, before fading in: $('#central').hide().fadein('slow').load('page.html');

cocoa - On OSX, how do I gradient fill a path stroke? -

using plethora of drawing functions in cocoa or quartz it's rather easy draw paths, , fill them using gradient. can't seem find acceptable way however, 'stroke'-draw path line width of few pixels , fill stroke using gradient. how done? edit: apparently question wasn't clear enough. responses far, figured out. want this: squares http://emle.nl/forumpics/misc/squares.png the left square nsgradient drawn in path followed path stroke message. right want do; want fill stroke using gradient. if convert nsbezierpath cgpath , can use cgcontextreplacepathwithstrokedpath() method retrieve path outline of stroked path. graham cox's excellent gcdrawkit has -strokedpath category method on nsbezierpath without needing drop down core graphics. once have outlined path, can fill path nsgradient .

html - How to set the margin or padding as percentage of height of parent container? -

i had been racking brains on creating vertical alignment in css using following .base{ background-color:green; width:200px; height:200px; overflow:auto; position:relative; } .vert-align{ padding-top:50%; height:50%; } and used following div structure. <div class="base"> <div class="vert-align"> content here </div> </div> while seemed work case, surprised when increased or decreased width of base div, vertical alignment snap. expecting when set padding-top property, take padding percentage of height of parent container, base in our case, above value of 50 percent calculated percentage of width. :( is there way set padding and/or margin percentage of height, without resorting using javascript? thanks in advance. i had problem (+1). i'm annoyed it, stupid have this. the fix yes, vertical padding , margin relative width, top , bottom aren't. so place div inside anoth...

html - How to add background image for input type="button"? -

i've been trying change background image of input button through css, doesn't work. search.html: <body> <form name="myform" class="wrapper"> <input type="text" name="q" onkeyup="showuser()" /> <input type="button" name="button" value="search" onclick="showuser()" class="button"/> <p> <div id="txthint"></div> </p> </form> </body> search.css: .button { background-image: url ('/image/btn.png') no-repeat; cursor:pointer; } what wrong? even inline-ing css didn't seem work. you need type without word image . background: url('/image/btn.png') no-repeat; tested both ways , 1 works. example: <html> <head> <style type="text/css"> .button{ b...

javascript - Load image only when it is viewable? -

i saw web page has large number of images, images inside scrolled viewport displayed, outside images, when scroll down it, loaded. how can done? try jquery lazy load plugin, works great, customizable, , dont have deal cross browser issues : http://plugins.jquery.com/project/lazyload

css - Text overflow even with vertical-align: top -

if take @ screenshot: http://img687.imageshack.us/img687/4350/photobenchmozillafirefo.png you can see text on top right overflow div. eventhough have placed vertical-align: top in there still won't stick on top. how make text appear on top? it @ top. top font doesn't have top visible pixel of character. trying draw higher force set line height smaller font size, or set negative margin. both solutions may cause text cut off on computer and/or browser.

sql - Get Unique Results in a query -

im sure pretty simple t-sql guru. i have following result table idmain idsecondary textvalue 1 1 text1 1 2 text2 2 5 text3 2 6 text5 and want obtain first occurence of idmain only. the result should this. idmain idsecondary textvalue 1 1 text1 2 5 text3 how can achieve this? you should able join sub query, in following example. assumes "first" mean lowest idsecondary : select t.idmain, sub_t.minsecondary, t.textvalue your_table t join (select idmain, min(idsecondary) minsecondary your_table group idmain) sub_t on (sub_t.idmain = t.idmain);

&variablename PHP -

possible duplicate: reference - symbol mean in php? can explain experssion &variablename in php. i have seen around @ many places not able figure out statement do. thanks in advance j php reference. references in php means access same variable content different names. there 3 operations performed using references: assigning reference, passing reference, , returning reference. php reference for example: $example1 = 'something'; $example2 =& $example1; echo("example 1: $example1 | example 2: $example2\n"); //example 1: | example 2: $example1 = 'nothing'; //change example 1 nothing echo("example 1: $example1 | example 2: $example2"); //example 1: nothing | example 2: nothing

c# - Object reference not set to an instance of an object -

i using following code check values added db table in checkboxlist, getting 'object reference not set instance of object' error here: listitem currentcheckbox = chkbx.items.findbyvalue(rdr["memberid"].tostring()); here's code, help! sqldatareader rdr = null; sqlconnection conn = new sqlconnection(getconnectionstring()); sqlcommand cmd5 = new sqlcommand("select memberid projectiterationmember projectiterationid in (select projectiterationid iterations projectid = '" + proj_id + "')", conn); try { conn.open(); rdr = cmd5.executereader(); checkboxlist chkbx = (checkboxlist)findcontrol("project_members"); while (rdr.read()) { listitem currentcheckbox = chkbx.items.findbyvalue(rdr["memberid"].tostring()); if (currentcheckbox != null) { currentcheckbox.selected = true; } } } { if (rdr != null) { rdr.close(); } if (conn ...

jQTouch bind("pageAnimationEnd") when page is loaded dynamically -

in jqtouch fetching page dynamically server per jqt demos per <a href="/page" class="button">the page</a> it loads html snippet <div id="page"> normally i'd able do $('#page').bind("pageanimationend", ...) to know when page had finished loading, doesn't seem work dynamically loaded content. i've been trying find workaround haven't been able to. think question on asking same thing , there didn't seem conclusive answer. if have access "page", put javascript on page , executed when done loading. in page html add ... <script> $(function() { when im finished }); </script>

visual studio 2005 - How to download the prerequiste from a particular remote URL location? -

i have setup project created c# application. want add prerequiste flash player application such downloaded remote "adobe website". location of prerequisite on remote adobe server "http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p2_64bit_activex_092710.exe" in order achieve did following-- 1) right click on set project , goto properties 2) click on prerequistes button. 3) select 3rd option "download prerequiste following location" , enter url "http://download.macromedia.com/pub/labs/flashplayer10/flashplayer_square_p2_64bit_activex_092710.exe" pressed ok. 4) build set project. 5) result of building got 2 files, app.exe & app.msi in release folder of project. but prerequisite not coming when install target application. plz can let me know if missing anything. i posted link in other post: how install flash player adobe site while installing c# application? please use edit feature i...