Posts

Fill cell array with consecutive numbers in Matlab -

given mycellarray{10,3} = []; , fill in first column consecutive numbers (let's 1 through 10). know this: [mycellarray{1:10,1}] = deal(1,2,3,4,5,6,7,8,9,10) mycellarray = [ 1] [] [] [ 2] [] [] [ 3] [] [] [ 4] [] [] [ 5] [] [] [ 6] [] [] [ 7] [] [] [ 8] [] [] [ 9] [] [] [10] [] [] however, if cell array larger (say 1,000 rows rather 10), writing out comma-separated values becomes tedious: [mycellarray{1:10,1}] = deal(1,2,3, ... ,1000) is there way create comma-separated "list" of numbers automatically? (1:10) ? know assign values via loops, there elegant one-line solution or close that? this 1 way num2cell - mycellarray(:,1) = num2cell(1:size(mycellarray,1)) in place of num2cell , can use mat2cell might not elegant though - mat2cell([1:size(mycellarray,1)]',ones(1,size(mycellarray,1)),1)

twitter bootstrap - Having a difficult time understanding indentation for HAML -

i've been trying learn haml putting simple middleman app, keep running syntax error. i'm using bootstrap theme , followed video tutorial, seems i'm running "illegal nesting" problems. .container .jumbotron %blockquote %p lorem ipsum dolor sit amet, consectetur adipiscing elit. integer posuere erat ante. %small famous in %cite{:title => "source title"} source title "haml::syntaxerror @ / illegal nesting: content can't both given on same line %p , nested within it." i've been messing around try , understand how identation works, have no clue. can make blockquote show if dont have container. advice please! .container .jumbotron %blockquote %p lorem ipsum dolor sit amet, consectetur adipiscing elit. integer posuere erat ante. %small famous in %cite{:title => "source title"} source ...

c# to f# - C# event handler assignment (in CocosSharp), translation to F# -

i trying translate c# code please f#, learning cocossharp ( http://developer.xamarin.com/guides/cross-platform/game_development/cocossharp/first_game/part3/ ). have mistakes either in defining handletouchesmoved or assigning touchlistener or both. c# code: touchlistener = new cceventlistenertouchallatonce (); touchlistener.ontouchesmoved = handletouchesmoved; addeventlistener (touchlistener, this); and handletouchesmoved: void handletouchesmoved (system.collections.generic.list touches, ccevent touchevent) { //... } my faulty f# code (just relevant piece within gamescene class): type gamescene (mainwindow: ccwindow) x = inherit ccscene (mainwindow) let touchlistener = new cceventlistenertouchallatonce () // problem happen touchlistener.ontouchesmoved <- x.handletouchesmoved x.addeventlistener (touchlistener, x) member x.handletouchesmoved (touches: collections.generic.list<cctouch>, touchevent: ccevent) = ...

Did "float: center" ever work in CSS? -

i have seen "float: center;" in code have inherited. was there ever time (or place) did something? or original coder wrong? no there not property called center float. has property float: none; (the element not floated, , displayed occurs in text) float:left (the element floats left) float:right (the element floats right) float:initial (sets property default value) float:inherit (inherits property parent element)

android - How can i write these items for constructor in a for-loop? -

so i'm writing app android, , im still noob in java/android. anyways have 2 strings, 1 names , other emails, , want output them in listview custom adapter. works fine far dont know how set items dynamically (with loop). create adapter , on, used tutorial: http://www.ezzylearning.com/tutorial/customizing-android-listview-items-with-custom-arrayadapter i changed imageview second textview. in tutorials code there 5 items added list, need them dynamically, since im not having same amount of name+emails output i tried putting in for-loop doing: weather weather_data[] = new weather[names.length]; for(int z=0; z == names.length){ weather[z]={new weather(names[z], emails[z])}; } i tried adding "new" infront , trying set null before, trial&error since dont know it. so can tell me how add items dynamically? (ps: sorry if used wrong names describe anything) this should work weather weather_data[] = new weather[names.length]; for(int z=0; z ...

php - Find prefix cms in mysql DB -

i want prefix db of cms. make code, not work when if in db more cms(joomla, opencart, wordpress) or make backup. can access prefix more gracefully? $this->connectdb(); $result = mysql_query("show tables;"); while($row = mysql_fetch_row($result)){ $allrows[] = $row[0]; } $index = preg_grep("/^.+_user$/", $allrows); $pieces = explode("_", array_pop($index)); $this->_prefix=$pieces[0]."_" ; try follow $this->connectdb(); $result = mysql_query("show tables;"); while($row = mysql_fetch_row($result)){ $allrows[] = $row; } $index = preg_grep("/^.+_user$/", $allrows); $pieces = explode("_", array_pop($index)); $this->_prefix=$pieces[0]."_"

php 5.5 - How to clear memory after file_get_contents executes in php -

i trying add variables couple of files have content. i using file_get_contents copy contents of particular file , using file_put_contents paste variable values along existing contents file. the problem that, on first instance works second file pastes has been stored in memory. puts contents first file along contents of second file. is there way can clear memory before next file_get_contents executes. or concept false here. here code... <?php if ($_post["submit"]) { $ip = $_post['ip']; $subnet = $_post['subnet']; $gateway = $_post['gateway']; $hostname = $_post['hostname']; $domain = $_post['domain']; $netbios = $_post['netbios']; $password = $_post['password']; $ipfile = 'one.txt'; $file = fopen($ipfile, "r"); $ipfilecontents = fread($file, filesize($ipfile)); $ipcontent = "ip='$ip'\n"; $ipcontent .= "netmask=...