Posts

jquery - Can't achive a part of json encoded data -

i have response: {"status":"succes","message":"some message!"} all data.status or data.message undefinied... success : function (data, status) { console.log(data); if(data.status=='error'){ console.log(data.message); //$('p.file_error').html(data.message); }else { console.log(data.message); } } my controller has this: $data['status']='error'; $data['message']='some message!'; echo json_encode($data); you should have this, think you're missing datatype value should type "json" works properly. $.ajax({ url : base_url() + '/controller/method', data : {param1: 'val1', "param2" : val2}, type: "post", datatype: "json", success: function(response) { console.log(respo...

javascript - Change in child accordion indicator icon twitter bootstrap -

i have 2 level twitter bootstrap accordion drop down indicator icons. problem when close sub-group indicator changes in parent too. (sorry bad english) $('.accordion-body').on('show', function() { $(this).siblings('.accordion-heading').children('.ui-icon').removeclass('ui-icon-triangle-1-e').addclass('ui-icon-triangle-1-s'); }); $('.accordion-body').on('hide', function() { $(this).siblings('.accordion-heading').children('.ui-icon').removeclass('ui-icon-triangle-1-s').addclass('ui-icon-triangle-1-e'); }); jsfiddle uhm, pretty obscure, here's cause: "show" , "hide" events bubble default, hide/show event firing in sub-collapsible getting catched parent collapsibles. the solution tweak listeners way: $('.accordion-body').on('show', function(e) { e.stoppropagation(); … } here working version of fiddle: http://jsfiddle.n...

wolfram mathematica - How to combine two lists to plot coordinate pairs? -

i have read x-data (from text files) list1, , y-data list2: list1 = { 0.0, 0.172, 0.266, ..} list2 = {-5.605, -5.970, -6.505, ..} how combine 2 lists in order plot points {0.0, -5.605}, {0.172, -5.970}, {0.266, -6.505},.... if don't pinguin dirk's suggestion try transpose[{list1,list2}]

mysql - Bulk INSERTs from multiple hosts preformace optimization -

i have 15 amazon aws ec2 t1.micro inctances simultaneusly populate amazon rds mysql d2.m2.xlarge database data using large inserts (40000 rows in query). the queries send continuously. table innodb, 2 int columns, there index both columns. cpu utilization of rds instance 30% during data receiving. when have 1 ec2 instance, speed in orders faster run 15 instances simultaneusly. , 15-instances group work slower , slower until speed becomes totally unsatisfactory. how can optimize performance of process? upd: show create table results following: create table `userdata` ( `uid` int(11) not null, `data` int(11) not null, primary key (`uid`,`data`), key `uid` (`uid`), key `data` (`data`) ) engine=innodb default charset=latin1 i need 2 indexes cause nessecary me fetch data uid , data value. i insert data insert userdata (uid, data) values (1,2),(1,3),(1,10),... 40000 (uid,data) pairs. 15 parallel instances insert ~121 000 000 rows in 2 hours, sure can more fast...

sqlite3 - How to convert an existing sqllite database into a Rails one? -

i have sqlite3 database 3 tables has id column primary key, has no created_at or update_at columns. i want use in rails3 applications. how can convert 'rails database'? it sounds want single rails app access 2 different databases? need 2 things: you need have app connect 2 different databases. "real" database , sqlite3 db after can connect both dbs, may need setup models , override of default rails naming conventions. for first item, can follow this: connecting rails 3.1 multiple databases for second item, if tables don't follow railsy way of naming them, can create model looks this: # app/models/foo.rb class foo < activerecord::base establish_connection "your_sqlite_connection_name_#{rails.env}" self.table_name = "name_of_table_in_sqlite_db" end

php - MAX numeric value from mixed array -

i have array contains both strings , numeric values, while using code keep getting highest string value, how numeric max values array? $maxprice = max($textpieces); i have tried returns number of keys in array $maxprice = max(array_search($textpieces)); thanks help! have looked max function here not give information http://php.net/manual/en/function.max.php i have looked @ solution find highest max() of mixed array possible without building custom function? $maxprice = max(array_filter($textpieces, 'is_numeric')); it @ first filters entries contains digits (integers) , extracts max() it the following solution: $max = array_reduce($textpieces, function($max, $i) { if (is_numeric($i) && $i > $max) { return $i; } return $max; }); var_dump($max); could bit more performance (from both cpu , memory perspectives) more complicated well.

objective c - view controllers: presentation, dismissal -

Image
just purpose of learning particular aspects of xcode, creating simple app has 2 functional view controllers. each contains button can pressed switch other. not using segues. using pointers retrieved app delegate. visual illustration (click higher resolution): when app loads, root view controller presents view 1. when click "switch view 2," following code causes view 2 appear: - (ibaction)buttonpressed:(id)sender { appdelegate *appdelegate = (appdelegate*)[[uiapplication sharedapplication] delegate]; [self presentviewcontroller:appdelegate.view2 animated:yes completion:nil]; } so far, good. but when click "switch view 1" on second view, same code (replacing "view2" "view1") gives following error: application tried present modally active controller. so summarize (where --> = presents), have root --> view1 --> view2 -x-> view1 i don't care retaining history of presents whom. want buttons bring top (make vi...