Posts

profiling - Why is a function/method call in python expensive? -

in this post , guido van rossum says function call may expensive, not understand why nor how expensive can be. how delay adds code simple function call , why? a function call requires current execution frame suspended, , new frame created , pushed on stack. relatively expensive, compared many other operations. you can measure exact time required timeit module: >>> import timeit >>> def f(): pass ... >>> timeit.timeit(f) 0.15175890922546387 that's 1/6th of second million calls empty function; you'd compare time required whatever thinking of putting in function; 0.15 second need taken account, if performance issue.

alertdialog - How To Make Custom Alert Dialog on Android? -

i want make custom alert dialog different style. know, default style square. want make on candy crush game if ever seen. i've try change background style, default background still appear. xml file dialog layout. <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="vertical" android:background="@drawable/dialog" > <imageview android:id="@+id/ivpic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true"/> <scrollview android:id="@+id/svalert" android:layout_width="wrap_content" android:layout_below="@+id/ivpic" android:layout_height=...

java - How to make MigLayout 4.2 collaborate with JavaFX 8? -

trying update application java 8, found javafx ui became unusable. there severe validation , repainting issues throughout screens, , suspect miglayout (4.2) culprit, since others seem suffer well: https://code.google.com/p/miglayout/issues/detail?id=6 i have provided running example of issue on github: https://github.com/urskr/miglayout-repaint it illustrates issue triggered when adding nodes migpane after initial layout computed. how make 2 of them collaborate java 7/javafx 2? there documented changes in way layouts behave in javafx 8? edit: have reported corresponding bug javafx , file regression. maybe there no way of making behave correctly. speaking developers miglayout , javafx, found out there no way make javafx 8 , miglayout 4.2 cooperate. for moment, solution update miglayout 5.0-snapshot, available in sonatype's snapshot repo . the reason - far understand - javafx 8 triggers layouts once per pulse, instead of multiple times case in javafx 2. migl...

owl - How to correctly specify RDF graph in an SPARQL UPDATE statement -

i created ontology in protege following iri: http://www.marketplace.org/carrierblueprint# and prefix gave mp now uploaded ontology in fuseki server , trying run update statements. in ontology there class called carrierprofile, want create new carrier profile using insert statement (1) tried insert data { graph <http://www.marketplace.org/carrierblueprint#> { mp:carrierprofile3 rdf:type mp:carrierprofile. } } -- fuseki server shows update success , when query dont new carrier profile name carrierprofile3 but (2) when use insert data { mp:carrierprofile3 rdf:type mp:carrierprofile. } it successful , when query time new carrier profile name carrierprofile3 i don't understand doing wrong in code 1. not mentioning graph properly? creating ontology given iri not give uri when upload store. each store has own way of specifying graph new data loaded, in case of fuseki when uploaded ontology file went default graph un...

scipy - Python- Chi Squared Minimization Problems -

i have been trying fit fourier series solution given equation 21 paper http://arxiv.org/ftp/arxiv/papers/1202/1202.4380.pdf . code not minimizing chi_squared function correctly. have looked through documentation of scipy.optimize , have managed minimize other functions. please suggest fix code or suggest alternative. from __future__ import division import numpy import scipy.optimize z = 0.0314 #m length between thermocouples t1_data = numpy.array( [20.0,20.1,20.4,21.0,21.8,22.4,23.1,23.8,25.5,25.2,26.0,26.7,27.3,28.0,28.7,29.3,29.9,30.6,31.2]) t_theory = numpy.array( [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]) t2_data = numpy.array( [20.0,20.6,21.7,22.6,23.6,24.4,25.0,25.7,26.5,27.2,27.9,28.6,29.3,30.0,30.7,31.3,31.9,32.6,33.2]) time_diff = 10 f = 100 t1_max = t1_data.max() t1_data = t1_data/t1_max t2_max = t2_data.max() t2_data = t2_data/t2_max def omega_n(n): return ((...

sql - SQLPLUS dont create row -

i have unusual problem sqlplus connected oracledb 10g. have table sequence , trigger autoincrement id. created script inserting data table. when called form sqlplus goes ok (without error), rows not visible in object browser. when call same command sql command show in table without problems. any ideas? creating tables script: -- create table drivers create table drivers ( id number not null, name varchar2(30) not null, forname varchar2(30) not null, plate_nr varchar2(7) not null, engine number(2,1) default 1.4 null check(engine > 0), -- check allow values meets statement passanger_space number default 3 null check(passanger_space > 0), luggage_space number default 150 null check(luggage_space > 0), primary key (id) -- id unique inside table , important ); create sequence drivers_seq; -- create sequence table create or replace trigger drivers_trg -- create trigger before insert on drivers -- if ...

c# - Unity IoC Lifetime per HttpRequest for UserStore -

i'm trying clean default implementation of accountcontroller.cs comes out of box in new mvc5/owin security implementation. have modified constructor this: private usermanager<applicationuser> usermanager; public accountcontroller(usermanager<applicationuser> usermanager) { this.usermanager = usermanager; } also, have created lifetime manager unity looks this: public class httpcontextlifetimemanager<t> : lifetimemanager, idisposable { private httpcontextbase _context = null; public httpcontextlifetimemanager() { _context = new httpcontextwrapper(httpcontext.current); } public httpcontextlifetimemanager(httpcontextbase context) { if (context == null) throw new argumentnullexception("context"); _context = context; } public void dispose() { this.removevalue(); } public override object get...