Posts

c# - WPF Dynamic TabControl SelectionChanged bug? -

i creating simple application using c# , wpf using mvvm pattern. there main window few buttons , contentcontrol containing list of view models, 1 of them being searchviewmodel. buttons flip between view models. the searchviewmodel bound searchview , contains tabcontrol. itemssource property bound list of searchtabviewmodels. in constructor of searchviewmodel, initializing observablecollection of searchtabviewmodels , adding 2 tabs. first tab has "+" header , other normal search tab. tabcontrol's selectionchanged event bound method checks if "+" tab clicked. if is, new tab inserted before "+" tab , tabcontrol's selectedindex property set index of inserted tab. simple setup. the issue i'm having when application first run, can click "+" tab , insert new tab "+" tab dead , nothing happens when click it. selectionchanged event not fire. i've checked , selectedindex set tab before it's not selected tab. fix it, ha...

ios - How to shift items in a NSMutableArray -

i have nsmutablearray . checking each item in array 1 1 using loop , remove current item. want next index item 1st index. like array = 1,2,3,4,5,6 array = 3,4,5,6 i remove indexes using loop. how can shift next element removed index position updated (int i=0; i<[m3u8 count]; i++) { nsstring *str=[nsstring stringwithformat: @"http://cp2.comci.com:1000/server/default.stream/%@", [mutarraymp3files objectatindex:i] ]; [audioplayer queue:str]; [mutarraymp3files removeobjectatindex:i]; // here want make array continous one. // let's removed object @ index 0, 1st object should move 0th location, // 2nd should move 1st.... likewise } you cannot modify nsmutablearray while you're in midst of iterating on it. , if shrinking array loop, can't keep incrementing index use or "run off end" eventually. can make copy, , modify that; or, use while loop instead of iterator: ns...

php - CakePHP counterCache with contain -

i have following database structure: users id, username, ..., silver_medal_counter, gold_medal_counter, bronze_medal_counter badges id, name, description, points, medal (silver, gold, bronze) userbadges id, user_id, badge_id, created if userbadge added, countercache should update relevant medal_counter field in users table. what have: class userbadge extends appmodel { public $belongsto = array( 'user' => array( 'countercache' => array( 'silver_medal_counter' => array('userbadge.badge.medal' => 'silver'), 'gold_medal_counter' => array('userbadge.badge.medal' => 'gold'), 'bronze_medal_counter' => array('userbadge.badge.medal' => 'bronze') ) ), 'badge' => array('classname' => 'badge') ); } note: $actas = array(...

javascript - How to set up an array of images and loop through them individually -

this simple task more experienced javascript. i'd have array of images , loop through them display each 1 interval of time between each one. store images in array: var anarray = [image1, image2, image] (can put images array put src in in array this? when tried treated each string.) create loop go through each image in array , fadein each image: (var = 0; <= array.length; i++) don't want want fade in images @ once, want 1 @ time. set interval of time: setinterval(functioin() {}, 1000); each image displayed 1 second or many seconds after each other. i know use plugin, i'm trying learn javascript want avoid taking shortcuts(except of course shortcut of asking on here!) thanks var img; for(length) { img[i]=new image(); img[i].src="src"; } //for storing image array var count=0; var timerid = setinterval(function() { //fade in image count++; if(count > length)clearinterval(timerid); }, 1000); better option a...

Android:Take pictures to send them with WebService -

i want take number of photos and, when completing , send of them on webservice without keeping them on device. i tried deleting them after sending didn't succeed. what best way this? this image capturing activity. private imageview imgpreview; private button btncapturepicture; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.image_capture); context = getapplicationcontext(); imgpreview = (imageview) findviewbyid(r.id.imgpreview); btncapturepicture = (button) findviewbyid(r.id.btncapturepicture); /** * capture image button click event * */ btncapturepicture.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // capture picture captureimage(); } }); } gpstracker gps; @override protected void onactivityresult(int requestcode, int resultcode, intent data) { // if res...

C++ How to create a function writing data in file for multiple use with different names -

i have data in array manipulated in 5 or 6 steps. after each step want program write file manipulated data. working code that: ofstream mirroreddata("mirroreddata.dat", ios::out); (int = 0; < n_values; i++) { mirroreddata << datavector[i] << "\n"; } mirroreddata << endl; mirroreddata.close(); the problem is, don't want write thing multiple times. want create function have call name of file (here: mirroreddata) , n_values , datavector. giving function datavector , n_values no problem, how tell writing data in new file? code fragment not right: void createdataoutputfile(int n_values, double* datavector) { ofstream mirroreddata("mirroreddata.dat", ios::out); (int = 0; < n_values; i++) { mirroreddata << datavector[i] << "\n"; } mirroreddata << endl; ...

Ansible - how to keep only 3 release -

i have vps sever deploy releases , dir structure have current dir, symlink actual release under releases dir. how can achieve, x ( in case 3) releases stay in releases dir, rest can deleted, spare free hdd , because don't need them more. setup capifony uses. perhaps bit off-topic, give place start: there ansible role in galaxy pointed @ replacing capistrano/capifony. example symfony2 project :-) https://galaxy.ansible.com/list#/roles/732 example usage: https://github.com/sweetlakephp/sweetlakephp/blob/master/ansible/deploy.yml to answer question more specifically: the loop required clean releases folder either shell script or composition of ansible tasks (saving ls output, sorting , removing). make smoother process, decided place logic in ansible module. module used in project_deploy role linked above. if prefer wrote own role, module extracted , placed in ot's own galaxy role: https://galaxy.ansible.com/list#/roles/2266 finally, if you'...