Posts

Showing posts from February, 2011

Django - Custom Model Method - How to specify datatype so Admin formats it properly? -

example: class mymodel(models.model): field1=models.charfield(..) field2=models.datetimefield() def today(self): return self.field2 when @ in admin site, field2 formatted differently today field. how can tell admin site treat today it's treating field2? i.e., tell django admin 'today' models.datetimefield? here it's showing: field2 today april 5, 2011, 9:10 a.m. 2011-04-11 08:47:27 that's really weird behaviour. @ total guess , may have django settings; datetime_format (and related) settings. framework introspection on fields, , if of datetime type, rendered according aforementioned settings. introspection on methods wouldn't make sense in majority of cases, understand behaviour if case. try modifying settings accordingly (provide different datetime formats), , see if fields change , method remains same. edit: looking @ django.contrib.databrowse.datastructures, there section of code like: i...

android pause an image -

hi im using display images screen imageview myimageview = (imageview)findviewbyid(r.id.imageview); myimageview.setimagebitmap(bitmap); and <imageview android:id="@+id/imageview" android:layout_gravity="center" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaletype="center" /> my question how can make pause couple of seconds switch next image slideshow .... thank you implement handler . here more updating ui timer

c# - How to re-bind ListView on OnClick event of a button? -

this seemed simple @ first can't work. i have following scenario: <asp:listview id="commentslistview" runat="server"> <layouttemplate> <asp:placeholder id="itemplaceholder" runat="server" /> </layouttemplate> <itemtemplate> <uc:comment runat="server" commentitem="<%# currentcomment %>" /> <br /> </itemtemplate> </asp:listview> <asp:textbox id="newcomment" runat="server" /> <asp:imagebutton imageurl="/images/ball.png" runat="server" onclick="submitcomment" /> code: protected void page_load(object sender, eventargs e) { renderlistview(); } protected void renderlistview() { commentslistview.datasource = //...

arrays - How do I consolidate a hash in Perl? -

i have array of hash references. hashes contain 2 keys, user , pages. goal here go through array of hash references , keep running total of pages user printed on printer (this comes event logs). pulled data excel spreadsheet , used regexes pull username , pages. there 182 rows in spreadsheet , each row contains username , number of pages printed on job. script can print each print job (all 182) username , pages printed want consolidate down show: username 266 (i.e. show username once, , total number of pages printed whole spreadsheet. here attempt @ going through array of hash references, seeing if user exists , if so, += number of pages user new array of hash references (a smaller one). if not, add user new hash ref array: my $criteria = "user"; @sorted_users = sort { $a->{$criteria} cmp $b->{$criteria} } @user_array_of_hash_refs; @hash_ref_arr; $hash_ref = \@hash_ref_arr; foreach $index (@sorted_users) { %hash = (user=>"",pages=>"...

numpy - Python library for Gauss-Seidel Iterative Solver? -

is there linear algebra library implements iterative gauss-seidel solve linear systems? or maybe preconditioned gradient solver? thanks edit: in end used kind of crude correct way solve it. had create matrix (for ax=b) anyway, partitioned matrix a = m - n with m = (d + l) , n = -u where d diagonal, l lower triangular section, , u upper triangular section. then pinv = scipy.linalg.inv(m) x_k_1 = np.dot(pinv,np.dot(n,x_k)) + np.dot(pinv,b) also did convergence tests. works. there example implementation go through various implementations here: http://www.scipy.org/performancepython another example here: http://www.dur.ac.uk/physics.astrolab/py_source/kiusalaas/v1_with_numpy/gaussseidel.py you might want check out python bindings petsc : http://code.google.com/p/petsc4py/

database - CakePHP: Unsure how to handle a semi difficult relationship -

i'm working on first cakephp app, order/invoice system. order-part coming along nicely, invoices kinda need help. the database structure i'm using; delivery note consists of multiple products , in turn exist of multiple re-usable elements (like number of trays , product itself). because customer order larger quantities, lower rates, time-based (from week 1 9 €1 element y, , week 10 8 €1.20 same element). of course customers have use daily prices, stored same way, witha nulled customer_id. now problem; have absolutely no idea how should tackle invoice view, or more specifically; best way data, or if should go , practice sql-writing skills. i'm not seeing major problems schema. containable behavior should make things easy here. add invoice model: var $actsas = array('containable'); make life easier adding defaultprice relationship each element. in element model: var $hasone = array( 'defaultprice' => array( 'cl...

asp.net - Spreadsheet connection in vb web app -

my client wants price list on website. i'm trying use spreadsheet (.xlsx) data source limit processing of data before appears on website. the site running on iis 7. server windows server 2008. i've updated .net framework on 4.0 well. it doesn't have office packages installed on it, , have hunch thats problem lies, i'd sure. heres error text i'm getting: system.invalidoperationexception: 'microsoft.jet.oledb.4.0' provider not registered on local machine. @ system.data.oledb.oledbserviceswrapper.getdatasource(oledbconnectionstring constr, datasourcewrapper& datasrcwrapper) @ system.data.oledb.oledbconnectioninternal..ctor(oledbconnectionstring constr, oledbconnection connection) @ system.data.oledb.oledbconnectionfactory.createconnection(dbconnectionoptions options, object poolgroupproviderinfo, dbconnectionpool pool, dbconnection owningobject) @ system.data.providerbase.dbconnectionfactory.createnonpooledconnection(dbconnection owningconnectio...

drawable - Does blackberry applications support 9 patch images? -

i want know if 9 patch images can used in blackberry. need design button images. need know more information on assets creation, assets library structure in blackberry. does blackberry applications support 9 patch images? no. @ least there no bb apis available right out of box. have write own code this.

windows phone 7 - Align TextBlock inside a ListBoxItem -

i'm developing windows phone 7 application. i want center vertically textblock inside listboxitem. here xaml code: <listboxitem x:name="singlegameitem" height="79" margin="10,5"> <textblock horizontalalignment="center" height="31" margin="5" textwrapping="wrap" text="textblock" verticalalignment="center" width="431" textalignment="center"/> </listboxitem> how can that? the solution is: <listbox x:name="options" margin="12,8,8,8" grid.row="1"> <listboxitem x:name="singlegameitem" height="79" margin="10,5" verticalalignment="center"> <textblock horizontalalignment="center" height="31" margin="5" textwrapping="wrap" text="textblock" verticalalignment="center" width="431...

windows - What is the best and most straighforward way to start a GUI application via a HTTP request? -

what best , straighforward way start gui application via http request? this question specific windows server , gui application running local system user. http request outside of servers network i.e. on web. i've tried making use of php , failed miserably, else can try? thanks all update i tried perl suggestion seems run app in background: #!c:/perl/bin/perl.exe print "content-type: text/html\n\n"; $execstring = 'start c:/www/csharp/test.exe 8998 "test message"'; exec $execstring; create cgi binary. run web-server. have binary start application. a perl script job, too. the cgi/perl/whatever need have appropriate local permissions, or os forbid start application.

NHibernate LINQ 3.0 Oracle Expression type 10005 is not supported by this SelectClauseVisitor -

i have following linq query queryresult<list<persondemographic>> members = new queryresult<list<persondemographic>>(); var query = (from ms in this.session.query<membersummary>() ms.namesearch.startswith(firstname.toupper()) && ms.namesearch2.startswith(lastname.toupper()) select new persondemographic { firstname = ms.firstname.topropercase(), lastname = ms.lastname.topropercase(), personid = ms.id, address = new address { line1 = ms.addressline1.topropercase(), line2 = ms.addressline2.topropercase(), city = ms.city.topropercase(), state = ms.state, zipcode = ms.zipcode, }, phonenumber = new phone...

php - probably wood for trees - mysql won't return fulldataset -

i run following php , first record in table , that's it, array containing 1 element. $sql = 'select id users'; $pass = mysql_query($sql); var_dump($pass); $row = mysql_fetch_assoc($pass); var_dump($row); but exact same sql fed straight database gives me full dataset, on 300 records. flip doing wrong php? thanks :) you have loop through each row: $sql = 'select id users'; $pass = mysql_query($sql); while( $row = mysql_fetch_assoc($pass) ) { var_dump($row); }

c - Installing rb-gsl gem using Cygwin -

i'm having issues installing rb-gsl under windows using cygwin. i'm using rubyinstaller windows dev kit installed. i've installed cygwin , gsl runtime, gsl-apps, gsl-devel , gsl-doc packages. when issuing gem install command following: $ gem.bat install "c:\documents , settings\jzh3fd.2ua1071fgf\desktop\gsl-1.14 .7.gem" temporarily enhancing path include devkit... building native extensions. take while... error: error installing c:\documents , settings\jzh3fd.2ua1071fgf\desktop\gsl -1.14.7.gem: error: failed build gem native extension. c:/ruby192/bin/ruby.exe extconf.rb checking gsl version... 1.14 checking gsl cflags... -i/usr/include checking main() in -lcblas... no checking gsl libs... -l/usr/lib -lgsl -lgslcblas -lm checking round()... no checking rngextra/rngextra.h... no checking qrngextra/qrngextra.h... no checking ool/ool_version.h... no checking tensor/tensor.h... no checking jacobi.h... no checking gsl/gsl_cqp.h... no checking gs...

iPhone - Knowing when an UIImageView has loaded its image -

i'm loading 5mp image uiimageview calling self.imagecontainer.image = myuiimage . myuiimage image coming camera of iphone. this takes time before image can seen on screen, , if can reduce time, need start process when image displayed on screen. how may know image loaded , displayed, , not still being processed uiimageview ? well... first thing shouldn't setting 5mp image in imageview. imageview meant on screen display , though scales image set display purposes original retained memory footprint goes way up. if @ best have poor performing app deals lots of memory warnings. @ worst, you'll crash often. so, should resize image smallest size meets onscreen display needs , set image within imageview. favorite blog post on how resize images: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way . now, question. can't know sure when image displayed happen once scaled can assume displayed set it. scaling on background thread. when scaling...

c++ - Using a class function in int main() -

i having problems calling functions main program. these functions have in class. how access them int main()? #include <iostream> #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <math.h> #include <sys/types.h> #include <semaphore.h> #include <synch.h> using namespace std; class mycountingsemaphoreusingbinarysemaphore { public: void waitsemaphore(pthread_mutex_t *thread) { pthread_mutex_lock(*thread);// makes value 1 (not available) } void signalsemaphore(pthread_mutex_t *thread) { pthread_mutex_unlock(*thread); // makes value 0 (available) } void deletesemaphore(pthread_mutex_t *thread) { pthread_mutex_destroy(*thread);// deletes } }; int readercount; int database = (rand() / 100); // number less 1000 void reader_writer(void); int main(int argc, char *argv[]) { mycountingsemaphoreusingbinarysemapho...

javascript - Analyzing DOM Event via Firebug :hover -

i have issue i'm trying debug, , use firebug's awesome :hover status toggle (under "style" dropdown tab on right). however, in case need inspect dom element y being dynaimcally generated javascript when element x hovered. toggling firebug's ":hover" option under style tab not locking dom , can't element y visible inspection. please? call onmouseover event handler manually firebug console. (most javascript frameworks provide shortcuts this, e.g. if use jquery hover handling, can $('#some-element').trigger('mouseover') (or possibly mouseenter , though both work).)

osx - Imagemagick jpeg decode delegate missing with OS X Homebrew install -

i converted macports homebrew , previous macports imagemagick install working fine. followed homebrew instructions chown /usr/local (somewhat apprehensively) , remove /usr/local/include , /usr/local/lib. when trying work jpeg images, imagemagick chokes with: no decode delegate image format here list of relevant command output. can see, no jpeg/jpg delegate can found. convert -list configure => delegates bzlib freetype png x11 xml zlib identify -list configure => delegates bzlib freetype png x11 xml zlib however, jpeg lib installed part of imagemagick dependencies, i'm not sure what's going on here. brew list => imagemagick jasper jpeg libtiff little-cms nginx pcre brew doctor => your os x ripe brewing. troubles may experiencing purely psychosomatic. identify --version => version: imagemagick 6.6.7-9 2011-04-06 q16 any ideas? andrei, solution got me in right direction. but a brew install --...

ios4 - how to make the background of UITableView cell transparent in iphone? -

i wrote following code make cell transparent uitableview - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ static nsstring *cellidentifier = @"nsubject"; subjectscell *cell = (subjectscell*)[tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { [[nsbundle mainbundle] loadnibnamed:@"mysubjectcell" owner:self options:nil]; cell=subjcell; uiview* backgroundview = [ [ [ uiview alloc ] initwithframe:cgrectzero ] autorelease ]; cell.backgroundview = backgroundview; ( uiview* view in cell.contentview.subviews ) { view.backgroundcolor = [ uicolor clearcolor ]; } } [cell settitle:[subjectsarr objectatindex:indexpath.row]]; return cell; } anybody can me in viewdidload can add self.tableview.backgroundcolor = [uicolor clearcolor]; you not need make own view have above.

How to define "inflation" in Android -

hello i'm trying learn android , don't understand inflate does; i've seen different examples on used inserting layout inside i'm not sure on used. can examples? thanks , greetings c. "inflation" term refers parsing xml , turning ui-oriented data structures. can inflate view hierarchy, menu structure, , other types of resources. done behind scenes framework (when call setcontentview(r.layout.main) , instance). typical case when explicitly inflate when creating menus, described in guide subject creating menus .

asp.net - Trouble with ajax POST call to WCF service -

i calling wcf service ajax , can work request not post request. so: [operationcontract] [webinvoke(method = "get", requestformat = webmessageformat.json, responseformat = webmessageformat.json)] public userobject getuser(string name) { // add operation implementation here var uo = new userobject() { custclass = "guest", fname = "chris", email = "chris@something", ismobile = false }; uo.fname = name; return uo; } and var json = { "name": "test" }; $.ajax({ //get user name , customer class type: "get", url: "writinganalysisservice.svc/getuser", data: json, processdata: true, contenttype: "application/json", timeout: 10000, datatype: "json", cache: false, success: function (data) { //get user name , customer class customerclass = data.d.custclass; ffname = data.d.fname; }...

c - Allocating a fixed sized object to a pointer (pointing to a struct) without using malloc -

i have pointer struct list* ptr struct contains char , pointer next struct , these used array of structures so: list array[setsize]; //setsize defined 20 without using malloc, need initialize list* ptr has elements of array. i have tried following , segmentation fault. believe utterly misunderstanding how pointers work. (i haven't touched c in long while) int j = 0; ptr = sizeof(array[j]); //i thinking allocate space for(j; j < setsize; j++) array[j].next = array[j+1].next; ptr = array; //i thought point beginning of array i have looked @ lot of sites c , linked list. had books don't give enough detail particular use of pointers or structures. have been trying while sure missing something. i need understand going wrong , direction head towards. thanks , help. below re-post more code: //this should initialize array ptr contains array elements void initialize ( list array[] ) { int j; for(j = 0; j < setsize - 1; j++){ array[j].next = ar...

windows - Convert Subversion commit messages to Unicode -

currently have local subversion repository lot of commit messages in cp1251 encoding. is there way can convert commit messages utf-8 encoding? your commit messasges are stored utf-8 : subversion internally handles bits of data—for example, property names, pathnames, , log messages—as utf-8-encoded unicode. not interactions subversion must involve utf-8, though. general rule, subversion clients gracefully , transparently handle conversions between utf-8 , encoding system in use on computer, if such conversion can meaningfully done (which case common encodings in use today). if you've somehow double-encoded them, though, assuming you're using fsfs-style repository easiest way work through revprop files find in db/revprops/*/* underneath repository , re-write them correct encoding, e.g. using iconv command-line tool gnuwin32 . (note these files should have unix line endings i.e. lf not crlf).

iphone - Programmatically fire button click event? -

is there way programmatically fire button click event? have button placed there in uiview, , in particular scenario want click button via code, not manually user. possible in ios development? please provide suggestions , guide me how that. thanks. sort of ken's answer, more flexible it'll keep track of buttons actual actions if change them or add more one. [button sendactionsforcontrolevents:uicontroleventtouchupinside];

forms - HTML5 textarea character limit attribute -

is there html5 attribute set maximum amount of characters in textarea or other form? want yes/no answer not other method using javascript. yup, maxlength works still: http://jsfiddle.net/xhqsb/1/ (demo has textarea , input type of text) beware easy client bypass these restrictions, if submitting data form, have server-side script check length of submitted data.

visual studio 2010 - Stop VS Entity Framework Designer from reverting to the name "Entities" -

Image
i have visual studio 2010 entity framework 4 wpf project , i'm not saving connection string in app.config. seems confusing ef designer, since wants take name of entity container name of connection string, doesn't exist. main problem i'm having every time update database, entity container renamed "entities". since isn't name want, have refactor name after every update. other adding named connection string app.config, there way stop visual studio messing entity container name? the name of context has nothing connection strings. retrieves name model property entity container name . open .edmx file , assign property whatever like.

regex - Regular Expression for Mod rewrite via HTACCESS -

i need regular expression can use in htaccess file rewrite: http://www.sample.com/dir/1-2-3.php 1 = lower case letters only, no limit on how many 2 = alpha numeric (lower case letters only) , dashes, no limit on how many characters 3 = alpha numeric (upper case letters only), no limit on how many characters (note: dashes between 1, 2, 3 intentional, , present in url) to http://www.sample.com/dir/sub/page.php?v=abc12345 where abc12345 #3 original url. if i'm understanding correctly, following should work. rewriteengine on rewriterule ^([a-z]*)-([a-z0-9-]*)-([a-z0-9]*)\.php /$1/$2.php?v=$3 [l] hope helps.

windows phone 7 - How much time is too much? -

given standard number of ticks cycle in wp7 app 333,333 ticks (or if set such), how of time slice have work in? to put way, how many ticks standard processes eat (drawing screen, clearing buffers, etc)? i worked out process doing in spike (as do) eating (14 ms) of time right (about half time slice have available) , concerned happen if runs past point. the conventional way of doing computationally intensive things them on background thread - means ui thread(s) don't block while computations occurring - typically ui threads scheduled ahead of background threads screen drawing continues smoothly though cpu 100% busy. approach allows queue work want to. if need computational work within ui thread - e.g. because part of game mechanics or part of "per frame" update/drawing logic, conventionally happens game frame rate slows down bit because phone waiting on logic before can draw. if question "what decent frame rate?" depends bit on type of app/gam...

android - I am using .asx link in the Uri.parse function and it is not working -

uri myuri = uri.parse("http://www.munichshardesthits.com/ondem/timeless%20rock.asx"); i using .asx link in parse function , not working. basically,i want make .asx link work here. please help. edit it may more not support space character '%20' escapes. a valid uri cannot contain '%' character. see '2.4.3. excluded us-ascii characters' here: http://tools.ietf.org/html/rfc2396

loading - Problem with NHibernate mapping when Id is in abstract base class -

i'm quite new nhibernate, doing right until face problem, looks nhibernate bug, being newbie it, can fault having base class id , equality stuff public abstract class objetoconid { public objetoconid() { id=newid(); } public virtual guid id {get;private set;} public override bool equals(object o) { if (object.referenceequals(this,o)) return true; if (o==null) return false; objetoconid oid; oid= o objetoconid; if (!object.referenceequals(oid,null)) return (id.equals(oid.id)); return (base.equals(o)); } public override int gethashcode() { byte[] bid; bid=id.tobytearray(); return ((int32)(bid[8]^bid[12])<<24) + ((int32)(bid[9]^bid[13])<<16) + ((int32)(bid[10]^bid[14])<<8) + ((int32)(bid[11]^bid[15])); } public virtual bool equals(objetoconid o) { ...

javascript - get iframe src in a page loaded via jquery $.get? -

i'm loading page using $.get, page load has iframe . know iframe id, reason cant src value... assuming code function loadpage(postid) { $.get("/post/" + postid, function(data) { var p = $(data).find("iframe").attr('src'); console.log(p) }) } i undefined result... but console of data object complete valus need...i'm not sure if problem of selecting in right way the following should work: $.get('/somescript', function(result) { var framesource = $('iframe', result).attr('src'); alert(framesource); }); here's live demo . make sure not violating same origin policy . that's why it's better use relative urls when performing ajax requests ( /somescript ).

jquery image flip-rotation effect -

is there jquery plugin known rotate image around imagecenter-x axis, flipping around? thnx! this one! https://github.com/heygrady/transform/wiki/

Drupal 7 - What is the variable in template.php that dictates which page template is used? -

ok, here's deal: constructing drupal website has several different sections. each section view displays content type. (each section has it's own content type) example, have view points ?q=blog displays content type blog . all sections little different each other. not 'website-within-a-website' different different enough can't use same template file , each modified css. each section needs it's own page.tpl.php . unfortunately, afaik drupal theme's .info files can either assign 1 page.tpl.php entire theme or assign page-node-####.tpl.php each node. there going lots of content on website setting drupal make new identical page-node-####.tpl.php every created node unmanagable fast. to solve problem, going use pathauto create alias each content type. example, nodes of content type blog given alias ?q=blog/[post title] . modify template.php use page-blog.tpl.php page who's alias starts word 'blog'. other people have tried doing sort ...

css - How can i prevent content to not exceed the length of container? -

i showing list of clients on page , on right side have calendar showing schedule new date appoinment. when testing output found if there lot of clients coming on day, list exceeds length of container. this.. some code: container: #container { background-color: #ffffff; margin:0 auto; min-height: 600px; width: 900px; border:0px solid #999999; margin-top:30px; font-size:15px; color: #000000; margin-bottom:60px; position:absolute; } #calendar { margin-left:400px; } do want #container expand @ all? if not, change min-height height, , add overflow:hidden; an better solution modify whatever supplying data receive pre-determined number of clients @ given time.

freepascal - How to read byte headers of untyped files and then use and display that data when they are file streams in Free Pascal and Lazarus -

i trying learn free pascal using lazarus , 1 of pet projects involves reading 64 byte headers of particular set of untyped files cannot read , displayed using text or ascii related procedures (so cannot outputted directly memo boxes etc). so far, have devised following code does, think, read in 64 bytes of header , using tstreams , "select directory" dialog box this, based on advice received via lazarus irc. question though how use data read buffer header? example, in headers, there sequences of 8 bytes, 16 bytes, 2 bytes , on want "work on" generate other output converted string go string grid. some of have far based on found here written mason wheeler near end (http://stackoverflow.com/questions/455790/fast-read-write-from-file-in-delphi) shows how read in, not how use it. read (http://stackoverflow.com/questions/4309739/best-way-to-read-parse-a-untyped-binary-file-in-delphi) again, shows how read data too, not subsequently use data. guidance wamrly receiv...

Javascript Class : create and destroy elements -

i'm new javascript classes, or lack of real support classes. in case, i'd create function can create , destroy dom elements. i'm ok creating elements destroying them bit trickier. how can call destroy without having provide id? function workzone() { this.create = function(id) { $('<div>', { id: id, class: 'work-zone' }).appendto('body'); } this.destroy = function(id) { $(id).remove(); } } $(function() { var zone = new workzone(); zone.create(); zone.destroy(); }); use jquery instead of creating custom code: http://api.jquery.com/category/manipulation/ you full browser support , optimal code , ability these sorts of dom manipulations lots of different kinds of selectors.

Manipulating Dictionary Values Python -

i have dictionary following values. d = {'a': 0, 'b': 1, 'c': 2} print d['c'] this print 2. how go changing value given key word? when keyword 'c' given return besides 2. just set using key: >>> d = {'a': 0, 'b': 1, 'c': 2} >>> print d['c'] 2 >>> d['c'] = 9000 >>> print d['c'] 9000

c# - LINQ: Rewrite an inline query into Linq method style? -

how re-written using linq methods instead of inline query style? var cp = datarow r in rptdatapkg.datasets.item(0).result.rows (r.field<string>("unititem") == "pc") && (r.field<string>("unititem") == "hs") && (r.field<string>("unititem") == "u") select new currprojected { doaddup = (r.field<decimal>("fld1") + r.field<decimal>("fld2")) == r.field<decimal>("fld3") }; try following var cp = rptdatapkg.datasets.item(0).result.rows .cast<datarow>() .where(r => (r.field<string>("unititem") == "pc") && (r.field<string>("unititem") == "hs") && (r.field<string>(...

Python and Phidgets: want to send event/message from object to its parent -

i have phidgets stepper controller (stepper class) , allows event handlers methods of class: self.setonattachhandler(self.stepperattached) self.setondetachhandler(self.stepperdetached) these useful can perform tasks when stepper controller attached/detached pc. i have created stepper object in wxframe in python , know how send messages wxframe can, example, indicated controller has been attached/dettached without polling. or in general, how send events/messages object parent in python? thanks! the canonical way pass reference of parent object down children. from phidgets.devices.stepper import stepper class parent(object): "parent class" def stepperattached(self, event): print 'connected device ', event.device.getserialnum() def eventhandler (self, event): print "event fired!", event.state class child(object): "child class" def __init__(self, parent): self.parent = parent ...

visual studio 2010 - How can I reinstall MVC2 in VS2010 Ultimate? -

some how lost mvc2? have mvc3 bit 2 goner. have uninstalled , reinstalled no success. sounds need reinstall default project templates. in command prompt, navigate location of devenv.exe. file located in <visual studio installation path>\common7\ide . type "devenv /installvstemplates" , press enter. reference here http://msdn.microsoft.com/en-us/library/ms247116.aspx

iphone - iOS: Stream audio file with pause, forward functions -

i know how stream audio file iphone. know how include functions pause, or having slider bar fast forward downloaded portions of audio? help appreciated! i've used audiosteamer classes in this project matt gallagher lot of success. simple enough implement own progress slider using nstimer poll current duration, , classes implement seektotime: function allow moving slider change position in stream.

Sending a object to server with jQuery -

i have jsfiddle set because there decent amount of code cp here. but first problem. send shape object server processing on mouseup . problem having when add jquery ajax or load functions test ajax sort of run away code , freezes. first code add can try in jsfiddle $('body').load('index.php/main/add_shape', shape, function () { shape.points["x"]}); now code on js fiddle sake of being able @ here , indexing. html <body> <canvas id="drawn" height="200" width="200"> <p>your browser doesn't support html5 , canvas element. should upgrade 1 of following<br> <a href="http://www.google.com/chrome">google chrome</a><br> <a href="http://www.mozilla.com/">firefox</a><br> <a href="http://www.apple.com/safari/">safari</a><br> <a href="http:...

c++ - expected constructor, destructor, or type conversion before & token -

i'm getting mysterious error in project says: expected constructor, destructor, or type conversion it's not allowing me use overloaded operator<< . worked before made class ( myvector ) template //myvector class //an implementation of vector of integers. template <class t> class myvector{ public: //purpose: initialize object of type myvector //parameters: none. //returns: nothing. myvector(); //------------------------------------------------ //purpose: initialize object of type myvector //parameters: integer. //returns: nothing. //------------------------------------------------ myvector(int); //purpose: destroys objects of type myvector //parameters: none. //returns: nothing //------------------------------------------------ ~myvector(); //purpose: returns current size of myvector. //parameters: none. //returns: size. int size() const; //------------------------------...

ruby on rails - Fetch all rows that column_id is in the array of id's, then order by id -

i trying this, not sure if doing correctly: user.where("region_id => ?", region_ids).order("id asc") region_ids = [1234,234322,234324,2343,....] also, work if region_ids empty (not null, empty) i seeing error: check manual corresponds mysql server version right syntax use near '=> null) order id asc' @ line 1: when in debugger mode, output region_ids , []. you're mixing ruby , sql syntax within string. want more ("region_id in (?)", region_ids) or ({ "region_id" => region_ids }) .

C++ -- why the operator= return a reference to *this rather than an object to *this? -

class myclass { public: ... myclass & operator=(const myclass &rhs); // return myclass& ... } why not class myclass { public: ... myclass operator=(const myclass &rhs); // return myclass ... } is reason more efficient return reference in case? thank you // * updated * i think found key reason follows: int i1, it2, i3; (i1 = i2) = i3; // i3 assigned i1 if return type of operator= myclass rather myclass&, following statement doesn't perform same internal data type. myclass mc1, mc2, mc3; (mc1 = mc2) = mc3; it considered practice following rules used built-in types. // *** update *** #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _tchar* argv[]) { int i1, i2, i3; i1 = 0; i2 = 2; i3 = 3; (i1 = i2) = i3; cout << "i1: " << i1 << endl; cout << "i2: " << i2 << endl; co...

dynamics crm - CRM 2011 PRM Portal - error on solution import -

i trying import prm portal solution rtm crm 2011 on-premise installation -currently busy taking snapshots of envronment can install update rollup 1. i following error when upload completed: errorcode: 0x80048425 errortext: form xml not conform required schema. schema validation error has been detected @ line 0, position 0. details: 'ordinalvalue' attribute not declared. the account entity customized , have couple of other managed solutions imported, odata query designer metadata browser . any or tips appreciated. problem fixed installing kb2461082 , updating crm 2011 rc crm 2011 rtm

authentication - Facebook Connect for the website - database connection and logic -

i trying let users login website using facebook account. have tried reading information related process facebook developers (http://developers.facebook.com/docs/) page - while process , logic sort of make sense, still lost regarding big picture. how 'facebook connect' link existing database of users , attributes. there user called john walker, registered user (login: jwalker pass:1234 account balance:$10). when come website, , try login using facebook login, how know direct him? in other words, how facebook know right john walker, , should sent user page? i sorry if question trivial, can't think though myself. in advance! zachary well zachary, have little bit misconception regarding facebook connect. when user clicks on facebook connect button placed on site, facebook doesn't go database authenticate user. authenticates user in database whether current user having facebook account or not... if he/she having account facebook issues access token particu...

c99 - Nongreedy fscanf and buffer overflow check in c -

i'm looking have fscanf identify when potential overflow happens, , can't wrap head around how best it. for example, file containing string **a**bb**cccc** i char str[10]; while (fscanf(inputf, "*%10[^*]*", str) != eof) { } because i'm guaranteed between ** , ** less 10. might a **a**bb**cccc* (without last *) or potentially buffer overflow. i considered using while (fscanf(inputf, "*%10[^*]", str) != eof) { } (without last *) or even while (fscanf(inputf, "*%10s*", str) != eof) { } but return entire string. tried seeing if check presence or lack of *, can't work. i've seen implementation of fgets, i'd rather not make complicated. ideas? i'm not clear on want. skip on number of stars, , read 9 non-star characters buffer? if so, try this: void read_field(file *fin, char buf[10]) { int c; char *ptr = buf; while ((c = getc(fin)) == '*') /*continue*/; while ...

mysql - How to use linked server with stored procedure? -

anyone have idea how use view stored procedure on linked server? don't have credentials linked server @ it. ?? if don't have access server, can't view anything. if have execute permissions on stored procedure, sure, can execute it. believe syntax exec "linkname"."dbname"."schema"."procedure"

php - Is it possible not to load the bootstrapping mechanism at every call? -

this not php question, expertise php frameworks. a lot of frameworks have bootstrapping (loading of classes , files) mechanism. (drupal, zend framework name few) everytime make request, complete bootloading process needs repeated. , can optimized using apc automatically caching intermediate code the general question is: for language, there way not load complete bootstrapping process? there way of "caching" state (or starting at) @ end of bootstraping process not load again? (maybe answer in other language/framework/pattern) it looks me extremely inefficient. in general, it's quite possible perform bootstrap / init code once per process, instead of having reload every request. in specific case, don't think possible php (but knowledge of php limited). know have seen criticism of php's architecture... fair php, it's not language or framework things way. go detail... the style of "run every request" came "cgi" script...

Getting X-Mailer attribute in php imap -

how can x-mailer attribute in php imap lib ? i can't find fetch function attribute http://php.net/manual/en/function.imap-fetchheader.php $inbox = imap_open($hostname,$username,$password) or die('cannot connect gmail: ' . imap_last_error()); $header = imap_fetchheader($inbox, 1); var_dump($header); /* close connection */ imap_close($inbox); output getting string(405) "mime-version: 1.0 received: 10.42.228.195; wed, 16 feb 2011 21:18:06 -0800 (pst) date: wed, 16 feb 2011 21:18:06 -0800 message-id: <aanlktikj8ngggkg=of=v6vvnst2qz3wlnkuvzxpcs4tk@mail.gmail.com> subject: gmail on mobile phone from: gmail team <mail-noreply@google.com> to: test case2 <email@gmail.com> content-type: multipart/alternative; boundary=20cf302234f1c34163049c73853c " method: fetch headers imap_fetchheader() extract x-mailer field headers extract value field example: $inbox = imap_open($hostname,$username,$password); if (!$inbox) { ...

ruby on rails - Routing to static html page in /public -

how can route /foo display /public/foo.html in rails? you can this: add this, routes.rb file. match '/foo', :to => redirect('/foo.html') update in rails 4, should use "get", not "match": get '/foo', :to => redirect('/foo.html') thanks grant birchmeier

mysql - Query Performance Optimization -

i have mysql query : select tbl.userid, tbl.name, tbl.courseid, tbl.fullname, ifnull(tbl.instance, '-') instance, ifnull(tbl.activityname, '-') activityname, ifnull(tbl.module, '-') module, ifnull(tbl.attempt, '-') attempt, ifnull(tbl.score, '-') score, case tbl.module when 'quiz' ( case when (tbl.attempt null , tbl.score null) 'not yet' when (tbl.attempt not null , tbl.score null) 'attempt' when (tbl.attempt not null , tbl.score not null) 'finish' end) when 'scorm' ( case when tbl.attempt null 'not yet' else (select `status` mdl_scorm_logs scormid = tbl.instance , userid = tbl.userid) end) else '-' end `status` ( select tbl1.userid, tbl1.name, tbl1.courseid, tbl1.fullname, tbl2.instance, case tbl2.module when 'quiz' (select `name` mdl_quiz id = tbl2.instance , course = tbl1.courseid) ...

activesync - windows mobile 6.5 - Motorola MC55 - strange directory names in device explorer view -

Image
on windows xp in device explorer view while explore content of connected via active sync motorola mc55 device can see strange content. @ attached file. what may wrong? regards that looks whole lot fat corrupted on file store. bad flash driver can cause well, typically show , on every device. if it's single device, or happened after time it's flash sector corruption. reformatting flash correct (though how on harward don't know).

android - What is the fastest way to draw an array of lines? -

i need draw array of lines in overlay. currently, use canvas , bitmap , draw 500 lines. drawing time high - around 200 ms bad, acceptable. now need add 500 lines more , time grows significantly. fastest way this? need use opengl? , how? best approach? turning off anti-aliasing speed things lot. sure profile code make sure rendering place time going. once have optimized things , majority of time spent in rendering , have made rendering simple possible, next step you'll have take move opengl.

Zend Framework - Add new input element using javascript -

i'm working on project using zend framework. i'm creating form on users can add set of elements pressing + sign. zend framework uses subforms , decorators array of values form. these show when page displayed how new fields created javascript integrate in model? the best demo of dynamically adding fields on client zend_form familiar comes jeremy kendall: http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/ the upshot of technique add/call prevalidation() method on form check post fields missing in form. if finds such fields, added form object. time isvalid() , getvalues() called, zend_form_element objects have been attached form, processing runs normal.

c# - Enum to dictionary and format each name -

i need convert enum dictionary , after format each name (value) of dictionary. public static dictionary<int, string> enumtodictionary<tk>(func<tk, string > func) { if (typeof(tk).basetype != typeof(enum)) throw new invalidcastexception(); return enum.getvalues( typeof(tk)) .cast<int32>() .todictionary( currentitem => currentitem => enum.getname(typeof(tk), currentitem)) /*. func each name */; } public enum types { type1 = 0, type2 = 1, type3 = 2 } public string formatname(types t) { switch (t) { case types.type1: return "mytype1"; case types.type2: return "mytype2"; case types.ty...

iphone - MonoTouch - should we go with the enterprise or professional license? -

we software development company willing develop iphone/ipad apps 1 of our clients. we understand being able deploy our application @ our client, have register in apple's ios developer enterprise program , add in development team. it unclear if need buy monotouch license enterprise distribution or simple professional license allow sign , deploy application on large number of devices long client registered in apple's enterprise program. although question targeted @ monotouch's licensing options, practical advice on how handle common scenario described in first phrase of great help. thanks. there 2 differences between professional , enterprise licences monotouch: the professional license requires assign license named developer. means cannot share license between employees in organization. enterprise licenses not have restriction. in addition, enterprise license allows deploy applications outside app store. useful applications deployed internally in org...

list - Help creating exam grading program in Python -

i trying create program reads multiple choice answers txt file , compares them set answer key. have far problem that when run it, answer key gets stuck on single letter throughout life of program. have put print statement right after answerkey line , prints out correctly, when compares "exam" answers answer key gets stuck , thinks "a" should correct answer. weird because 3rd entry in sample answer key. here's code: answerkey = open("answerkey.txt" , 'r') studentexam = open("studentexam.txt" , 'r') index = 0 numcorrect = 0 line in answerkey: answer = line.split() line in studentexam: studentanswer = line.split() if studentanswer != answer: print("you got question number", index + 1, "wrong\nthe correct answer was" ,answer , "but answered", studentanswer) index += 1 else: numcorrect += 1 index += 1 grade = int((numcorrect / 20) * 100) prin...

mysql - PHP opening times & embassy holidays -

i've been using code: $rawsql = "select * _erc_foffices n inner join _erc_openings o on n.id = o.branch_id , o.dotw = dayofweek(current_date()) inner join _erc_openings_times t on o.id = t.opening_id ( unix_timestamp(current_timestamp()) between unix_timestamp(concat(current_date(), ' ', t.open)) , unix_timestamp(concat(current_date(), ' ', t.close)) ) , ( n.id = %d ) ;"; $sql = sprintf($rawsql, mysql_real_escape_string($id)); $result = mysql_query($sql); /*these if & while statements decide whether or not information should displayed. if no results returned query above alternative message shown.*/ if(mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result, mysql_assoc)) { echo "<div class='address'><p>" . $row["title"] . "<br/>"; echo $row["address_1"] . "<br/> " . $row["address_2"]...