Posts

php - PDO extend for a crud querys and Fatal error -

i'm trying make query class crud , want extend connection other class, error : fatal error: call member function prepare() on non-object !? miss ? or stupito extend ? here mysql_connection extend querys class. both different php files. class mysql_connection extends querys { protected $dbh = null; function __construct() { try { $this->dbh = new pdo('mysql:host=host; dbname=db','user','pass', array(pdo::mysql_attr_init_command=> 'set names utf8')); $this->dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception); $this->dbh->setattribute(pdo::attr_default_fetch_mode, pdo::fetch_assoc); } catch(pdoexception $e) { $this->dbh = null; print('error on connection'.$e->getmessage()); die(); ...

Does the Linux scheduler prefer to run child process after fork()? -

does linux scheduler prefer run child process after fork() father process? usually, forked process execute exec of kind so, better let child process run before father process(to prevent copy on write). i assume child execute exec first operation after created. is assumption (that scheduler prefer child process) correct. if not, why? if yes, there more reasons run child first? to quote the linux programming interface (pg. 525) general answer: after fork() , indeterminate process - parent or child - next has access cpu. (on multiprocessor system, may both simultaneously access cpu.) the book goes on differences in kernel versions , mentions cfs / linux 2.6.32: [...] since linux 2.6.32, once more parent is, default, run first after fork() . default can changed assigning nonzero value linux-specific /proc/sys/kernel/sched_child_runs_first file. this behaviour still present cfs although there some concerns future of feature. looking @ cfs implementa...

refresh <table> using AngularJS or javascript -

i'm struggling hours <table> refresh using onclick button. want refresh random values, once button clicked. i've set id="mytable" on <table> , used .reload() function, doesn't seem work. ideas? demo on jsfiddle html: <table id='mytable'> <tr> <td id="rand1"></td> </tr> <tr> <td id="rand2"></td> </tr> </table> <button onclick="parent.document.getelementbyid('mytable').reload()">refresh random</button> js: var random = function() { return math.random(); } document.getelementbyid("rand1").innerhtml = random(); document.getelementbyid("rand2").innerhtml = random(); try this <html> <body> <table id='mytable'> <tr> <td id="rand1"></td> </tr> <tr> <td id="rand2"></td> ...

javascript - How to disable Jquery prompt save button on first click -

i using jquery prompt prompt user save. so, user clicks save button, jquery prompt displays , asks if user sure he/she wants save changes or not. problem is, user able click multiple times on jquery save prompt button before prompt closes. result, save routine runs once each time prompt save button clicked, results in duplicate records in database. need disable prompt save button on first click or close prompt window on first click prevent multiple saves. how can this? client code: $.prompt("are sure want save? not able change decision after it's been saved.", { title: "save?", buttons: { "save": true, "cancel": false }, submit: function (e, v, m, f) { if (v) { response = saveupdates(loandetails); } } }); i created fiddle here: http://jsfiddle.net/smurphy/4fqjr/ the solution little convoluted. thought there simpler way after looking through documentation cannot find built i...

cordova - SimpleWebRTC with PhoneGap -

is there way use simplewebrtc (from simplewebrtc.com) , cordova? know if webkit safari supports it? i trying to: create phonegap project include simplewebrtc js connect room currently webrtc not supported in browsers safari , internet explorer. more on that: http://iswebrtcreadyyet.com/ http://www.webrtc.org/ http://caniuse.com/#feat=stream meaning simplewebrtc not run on safari browser or in phonegap. can use webrtc phonegap using opentok's services: http://www.tokbox.com/blog/opentok-now-on-phonegap/ (note: works on ios) or try: https://github.com/alongubkin/phonertc

python - Simple Numpy Vectorization -

i have 2 1d numpy arrays start , stop , both of contain integers (which used index other array). have following piece of code. index_list = [] in range(len(start)): temp = range(start[i], stop[i]) index_list.extend(temp) index_list = np.array(index_list) is there simple way vectorize this? you can vectorize follows: def make_index_list(start, stop): lens = stop - start cum_lens = np.cumsum(lens) # sequential indices same length expected output out = np.arange(cum_lens[-1]) # starting index each section of `out` cum_lens = np.concatenate(([0], cum_lens[:-1])) # how each section of `out` off correct value deltas = start - out[cum_lens] # apply correction out += np.repeat(deltas, lens) return out with made data: start = np.random.randint(100, size=(100000,)) stop = start + np.random.randint(1, 10 ,size=start.shape) we can take code test ride: in [39]: %%timeit ....: index_list = [] ....: in range(len(st...

zend framework - Design pattern of translations files -

i'm developping international website based on php zendframework 1.12 , , i'm going use zend_translate managing translations. my translations put php array key=>value : (one file per language) <?php return array( 'key' => 'translation', 'key2' => 'translation2', ); my question : what best way manage keys files? my opinion : in first hand, use default language keys . : 'submit' => 'valider', 'share' => 'partager', //... in other hand, use special keys able directly found text appear : 'label_loginform_login' => 'login', 'button_mixed_submit' => 'submit', 'links_mixed_share' => 'share', //... but in option, best tree use keys? how many levels ('type' / 'placement' / 'action' ...)? and each level, how many items? example level 'type' label : used...