Wednesday, December 17, 2014

Show Hidden Files in Mac

The long way...
1. In Terminal:
defaults write com.apple.finder AppleShowAllFiles YES
2. Press return
3. Holt alt key on keyboard, right click, relaunch
4. To hide:
defaults write com.apple.finder AppleShowAllFiles NO

Making aliases for show and hide hidden files
1. In Terminal:
sudo nano ~/.bash_profile
2. Enter your root password, and hit return
3. Paste the following in open .bash_profile file:
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'hit return
4. Paste the following:
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'hit return
5. Ctrl+O and hit return to save file
6. Ctrl+X to exit


So the next time, you can just use the aliases in Terminal, showFiles to show hidden files, and hideFiles to hide them.

Thursday, December 11, 2014

Traffic Flow and Modelling with CA

Quick references:

  1. http://sjsu.rudyrucker.com/~han.jiang/paper/#_Toc40035685
  2. http://publish.uwo.ca/~jmalczew/gida_5/Pursula/Pursula.html

Enable select text in Quick Look Mac OS X

Quick Look in Mac OS X is very useful if you just want to have a glance at certain file without launching the needed application. You can do so by just hit the space bar. Quick look can be even better if we can select the text without launching its application. It can be done and reversible as follow:


1. Launch Terminal
2. Type the following command
defaults write com.apple.finder QLEnableTextSelection -boolean YES;
killall Finder


3. Want to put it back the way it was?
defaults write com.apple.finder QLEnableTextSelection -boolean NO;
killall Finder

Tuesday, December 9, 2014

Mac Must-Know Keyboard Shortcuts

For my own reference
Collection of Mac keyboard shortcut. The list will go on...

Cmd+C - Copy
Cmd+Opt+V - Paste
Shift+Cmd+4 - Print Screen and save to desktop
Shift+Ctrl+Cmd+4 - Print Screen and save to clipboard (no image will save to your desktop)
Hold cmd+RightClick Trash - Securely empty trash

Cellular Automata 101

Disclaimer - This is my collection of personal quick reference, that I learned from blogs, books, articles, papers, journals. I'm by no means an expert/professional, my opinions/understanding at the specific time of writing may not be accurate. So don't take my words and apply to your homework/assignment, however I'll try to quote the reference link below.

I don't take responsibility for much more than waking myself up in the morning =)

The term cellular automata is plural, if a code is simulate just one cell - it's a cellular automaton (singular),

A cellular automaton is a model of a system of a cell objects. Its characteristics:
  1. Cells live on a grid
  2. Each cell has a state (1 or 0, on or off, alive or dead)
  3. Each cell has a neighbourhood
Analogy - think of filling in some square on a piece of graph paper. Consider a set of simple rules 
that would allow that pattern to create copies of itself on that grid.

A most important detail of how CA work - time, for CA to live over a period of time (a.k.a generation/frame count/iteration)




References:
http://natureofcode.com/book/chapter-7-cellular-automata/

Monday, December 8, 2014

Terminal Must-Know Commands (Mac)


Commands:
  1. clear - clear the screen
  2. pwd - present working directory
  3. ls - list all files
  4. cd - change directory
  5. cd folder_name&&ls - change directory and list all the files inside
  6. mkdir -p Dir_Name/{subDir1,subDir2} - make directory and subdirectories
  7. rm -rf file_path  - delete file permanently (not goin to trash)


Keyboard:
  1. ctrl+c or ctrl+z - to stop process in terminal

Adding multiple ports to scope in Matlab Simulink

1. Click the scope
2. Select setting
3. On the general tab, change the number of axes









You may also use the 'mux' block to display multiple inputs.

Tuesday, December 2, 2014

Editing Text in GUI-Matlab

On command windows,
>> guide(charGUI2.fig)

can edit the text by:

  1. double click on text
  2. Look for 'String' and click the 'left alignment'




Thursday, October 9, 2014

Extract Video Frame (non-avi) in Matlab

The original author for this code can send me an email so that I can credit back to him/her.
Work for both avi and non-avi file

clc;
close all;

%% USE THIS IF - open a non-avi file
mov = mmreader('n3.mp4')
frame = read(mov,200); %LONG WAIT
mov.NumberOfFrames;

%% or USE THIS IF - Open an avi file
%filename = 'n3.wmv';
%mov = mmreader(filename);

%% continue here
% Output folder

outputFolder = fullfile(cd, 'frames');
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end

%getting no of frames

numberOfFrames = mov.NumberOfFrames;
numberOfFramesWritten = 0;
for frame = 1 : numberOfFrames

thisFrame = read(mov, frame);
outputBaseFileName = sprintf('%3.3d.png', frame);
outputFullFileName = fullfile(outputFolder, outputBaseFileName);
imwrite(thisFrame, outputFullFileName, 'png');
progressIndication = sprintf('Wrote frame %4d of %d.', frame,numberOfFrames);
disp(progressIndication);
numberOfFramesWritten = numberOfFramesWritten + 1;
end
progressIndication = sprintf('Wrote %d frames to folder "%s"',numberOfFramesWritten, outputFolder);

disp(progressIndication);

Saturday, August 2, 2014

Batch Renaming Files using Automator (Mac OSX)

Cmd+spacebar to search for Automator

Steps:

  1. On left panel, select Files & Folders
  2. Drag 'Get Selected Finder Items' to the right panel
  3. Drag 'Rename Finder Items' to the right panel
  4. Change the default 'Add date or time' to 'Replace text'
  5. My initial files start with 'IMG_' (refer Fig. 2). Change yours accordingly
  6. Replace all the files with 'Date-Occasion' (make sure all the related files are selected, refer Fig.2, and the folder you are working is current active windows)
  7. Hit 'Run'


Fig. 1 Automator

Fig. 2 Select related files for batch renaming