Wednesday, July 5, 2017

Get Memory information in Linux

sudo dmidecode --type 17

Watch CPU Frequencies in real time

sudo watch -n 1  cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq

Monday, June 19, 2017

Unblock a specific port from the firewall in Centos 7

Following is a example which unblocks port 8888

firewall-cmd --permanent --add-port=8888/tcp
firewall-cmd --reload
firewall-cmd --list-all

Wednesday, December 21, 2016

opencv: Install opencv CentOS

sudo yum install opencv opencv-python opencv-devel-docs 

sudo yum install -y python-devel gtk2-devel libdc1394-devel libv4l-devel ffmpeg-devel gstreamer-plugins-base-devel
sudo yum install -y libpng-devel libjpeg-turbo-devel jasper-devel openexr-devel libtiff-devel libwebp-devel
sudo yum install -y gcc  cmake  git gtk2-devel pkgconfig  numpy  ffmpeg

If your using virtual environment, copy the relevant cv files to the virtual environment.

 cp /usr/lib64/python2.7/site-packages/cv* .venv/lib/python2.7/site-packages/

Tuesday, December 20, 2016

Caffe: Visualizing Caffe Network prototxt file using GraphViz:

Visualizing Caffe Net topology/ntwork/prototxt file using GraphViz
From the Caffe root directory, you can generate a graph in image format from a .prototxt model file:

$ make pycaffe
$ pip install pydotplus
$ yum install graphviz

Visualize a CNN in left-to-right:

$ python/ mynetwrk.prototxt mynetwrk.png

Output formats could be : PNG, PDF, DOT or other GraphViz supported formats.
Visualize a CNN in top-to-bottom:

$ python/ --rankdir TB mynetwrk.prototxt mynetwrk.png

Following errors can be eliminated if you install the PRE-REQS (pip install pydotplus; yum install graphviz)

pydotplus.graphviz.InvocationException: GraphViz's executables not found
Exception: "dot" not found in path.
ImportError: No module named pydot

Monday, December 12, 2016

Github: Merging two branches

git remote add remote-name remote-github-url 
git fetch remote-name 
git merge remote-name/branch-name 
git status

Github: Update a GitHub forked repository;

git remote add upstream github-URL
git fetch upstream 
git merge upstream/master master 
git pull upstream master 
git push

Friday, October 10, 2014

Sublime Text: Multiple cursors or Multi-selection

Multiple cursors or Multi-selection in sublime text is easy

  • Press Alt/Command and then click in each region where you require a cursor. 
  • Select a block of lines : Shift + Command + L. 
  • Place the cursor over a particular word, and press Control/Command + D repeatedly to select additional occurrences of that word. 
  • Add an additional cursor at all occurrences of a word : Alt+F3 on Windows or Ctrl+Command+G on Mac.

Tuesday, September 30, 2014

Laravel: Debug by Printing Eloquent Query

Use ->toSql() method like shown below to get the SQL

use Log;

$name = "hawk";

$userResults = DB::table('users')
       ->leftJoin('planets', function($join) {
         $join->on('users.planet_id', '=' , '');
       ->where('users.lname' , 'like', '%'.$name.'%');

//You can print the SQL in your log file
Log::info('My search sql: '.($userResults->toSql()));

// OR you can save into a string variable
$mySQL = $userResults->toSql();

//Then use your get function
$userResults = $userResults->get(array('users.fname', ''));

The above code will print the following into your /storage/logs/laravel.log file

[2014-09-30 17:58:07] production.INFO: My search sql: SELECT * FROM  users LEFT JOIN planets ON (users.planet_id = WHERE users.lname LIKE '%hawk%'