Posts

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...