Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Friday, August 29, 2014

Turn off the spotlight and turn it on

Turn off the spotlight and turn it on using these commands in terminal.
sudo mdutil -i off

sudo mdutil -E /

Monitor Temperature in Mac using bash script command line

The code is simple thanks to the temperature monitor app
Just do ./runTapp.sh &
in the terminal, and you are good to go!
#!/bin/sh
cd /Applications/TemperatureMonitor.app/Contents/MacOS/
./tempmonitor -th > ~/Desktop/CPUtempData.csv
while true
do
    ./tempmonitor -tv >> ~/Desktop/CPUtempData.csv
    /bin/sleep 60
done

Reference:
http://www.bresink.com/osx/216202/Docs-en/commandline.html

Tuesday, October 22, 2013

Install wget in Mac using terminal

This is my history from the terminal installing wget in mac

210  which wget
  211  curl -O http://ftp.gnu.org/gnu/wget/wget-1.13.4.tar.gz
  212  tar -xzf wget-1.13.4.tar.gz
  213  cd wget-1.13.4
  214  ./configure --with-ssl=openssl
  215  make
  216  sudo make install
  217  wget --help
  218  cd .. && rm -rf wget*
  219  ls
  220  history

Tuesday, April 3, 2012

Assigning shortcut keys in Keynote: Mac

I needed to make a picture of neural network. The picture is too much work as it has a lot of connected blocks to be constructed.
So, in order to reduce the pain, I looked for shortcuts.

I wanted to assign shortcut keys to connect the blocks. So, I went to :

  • System preferences
  • Keyboard
  • Keyboard Shortcuts
  • Application Shortcuts
  • From there I had to browse the keynote and put the exact word. In this case "Connection Line", and assign the shortcut.
  • This method is true in general. So, if I wanted to assign any set of keyboard shortcut to any task, it should work. 
  • Profit!! :)



In order to connect the blocks, I would need to select two blocks, then press the shortcut key.
I wonder if there is a way to make connection between all selected blocks. (There seems to be none...)

Currently, If I have to connect two blocks, it is set to:
CMD+SHIFT+K

Tuesday, February 14, 2012

Screen Capture in Mac using Terminal

I figured, there should be some kind of terminal script out there which enables us to take the screen capture of the desktop. This will become real handy when we need to produce consistent screenshots for the Google Earth Images for my results. Furthermore, in order to crop it nicely, there is a code too!
http://usefulcodes.blogspot.com/2011/11/using-imagemagick-shell-command-to-crop.html
screencapture ~/Desktop/test.png


Thursday, July 21, 2011

Diff Tool Mac

I have to say FileMerge is one of the best diff tool I have seen.
Just change the folder and do opendiff for two desired files.
I wanted to see the changes I made on two files by using diff, I was immediately sold!

The tool is already included in the system if you have Xcode environment set up

opendiff Jul20.m Jul21.m

Tuesday, July 19, 2011

Changing the bash prompt mac

My bash prompt looked long and clumsy. So I wanted it short.

FIrst I opened the bash profile


nano .bash_profile
Then I added:
export PS1="My-Mac2:"
Write out, and voila!

Wednesday, July 6, 2011

Close mac Terminal after you are done

The exit command:
It works if the following setting is done:
Terminal
>Preferences
>Settings
>Shell
>Prompt before closing: never
or
> When the shell exits:
select: close if the shell exited cleanly

The following kills the terminal:

killall Terminal

So, if I want to kill the terminal after I am done, I will simply add:
killall Terminal
instead of kill

Wednesday, June 22, 2011

Installing Spell Checker in TeXworks (Mac)

Installing spell checker in TeXworks is going to be straightforward after I write this note.
The dicttionary for TeXworks is located at:
/Users/gajab/Library/TeXworks/dictionaries
where gajab is your username.



One easy source of dictionaries is the OpenOffice.org project, which uses the same spelling engine. There is a list of available dictionaries at http://wiki.services.openoffice.org/wiki/Dictionaries (see the All Language Packs download, or links to individual language dictionaries). Note that TeXworks only uses the spelling dictionaries (*.dic and *.aff) for each language ...

  • So I downloaded the dictionary file from
    http://extensions.services.openoffice.org/en/dictionaries
    It is located currently at:
    http://extensions.services.openoffice.org/en/project/en_US-dict
  • However, the file is saved as .oxt.  I simply renamed the package as a zip file
    en_US.oxt >> en_US.zip
    and unzipped the package (well, double click and rename along with the extension. It warns, but you can change the extension). It worked!!
    The package contains:
    META-INF description.xml en_US.aff info
    README_en_US.txt dictionaries.xcu en_US.dic
  • WE only need .dic and .aff files. So I copied it to the library folder for the TeXworks.



cp ~/Downloads/en_US/en_US.aff /Users/gajab/Library/TeXworks/dictionaries
cp ~/Downloads/en_US/en_US.dic /Users/gajab/Library/TeXworks/dictionaries

The dictionary worked nicely after I restarted the TeXworks.

Guide to LaTeX (4th Edition)More Math Into LaTeX, 4th EditionLaTeX: A Document Preparation System (2nd Edition)

Monday, May 16, 2011

Kile on Mac

Somehow the Macports evaporated out of my system.
So, I end up reinstalling the Kile via macports.

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
$ sudo port selfupdate

$ port upgrade outdated
Reinstalled KILE:
$ sudo port install kile


I think installing one of the program last week kicked it out... I will need to verify that.

Tuesday, May 10, 2011

Two instances of Matlab in Mac

Typing this on the terminal does the trick!!
$ /Applications/MATLAB_R2010b.app/bin/matlab

Running two instances of matlab: Does it slow down the performance?
Will see...

Thursday, March 31, 2011

Automating file operations in matlab excluding the directories

Automating the work in directory with tree structure is fun. You can leave it overnight and get the output the next day.
However, hidden files/folders can be troublesome.
Specially these:
.
..
and .DS_Store (in mac)
or other set up stuffs

for jj = 1:length(fileList)
if fileList(jj).isdir
% do not operate the file
else
% call the function to operate on it * see footnote

end
%% footnote:

fileTARGET = '/Users/.../monthly';
saveTARGET ='/Users/.../figuresSAVE'
% Do the regular stuff
cd(fileTARGET)
% Do the regular stuff: train
fileLIST = dir;
N = length(fileLIST); % fileLIST.name
fn = fileLIST(4).name;
% fn='asdf.ext';
disp(fn)
trainME(fn) % train the network: takes data and trains
%save the figures here
cd(saveTARGET);
% savefile = fn;
save('savetrained.mat', '-mat', 'net'); % save the network... JIC
% cd(fileTARGET);
% cd(saveTARGET); instead, we can feed the folder structure into function making the code more general see below:
saveFIG(fileLIST, fileTARGET, saveTARGET, net); 

% save the plotted figures; as the target directories and save target directories are taken as input, it is more general for its usages


%%%%%%%%%%

I have also found a better way of working on it:



for jj = 1:length(fileLIST)
fn = fileLIST(jj).name;
[pathstr, name, ext] = fileparts(fn);
if strcmp(ext, '.hdf')
% do not operate the file
% else
disp(['Working on : ', fn])
end
end

Thursday, March 10, 2011

How to block website in MacOS

Say wanted to block facebook...

 Do
 sudo pico /etc/hosts

enter: into the file
 127.0.0.1 facebook.com

 and save out ctrl+O; ctrl+x

refresh cache
 sudo dscacheutil -flushcache

Thursday, March 3, 2011

Using MacPorts and Porticus

Macports (http://www.macports.org/) is awesome, except that it installed stuffs in wierd places so that I could not run netcdf properly. Now I have done it manually.
Came across the GUI for it:

Looks good!
http://porticus.alittledrop.com/index.html
Except that it is also unable to update stuffs!
:(

Wednesday, March 2, 2011

Installing Kile on Mac

 I find it easy to use macport.

  • Simply go to macport site to download the disk image (dmg) for macport. (http://www.macports.org/install.php or google macport kile)
  • do sudo port install kile
    BOOM
  • It will install all the dependencies and kile itself.  

Read setting path after installing macports:
http://usefulcodes.blogspot.com/2011/05/kile-on-mac.html

Thursday, February 24, 2011

Running command line programs in Mac

Type in textwrangler

#!/bin/bash
cd /applications/IDV
./runIDV

Saved it as runIDV.command in home

Right click on the item and then create alias. Move the alias to the Applications folder on the dock.

Bingo!