- Commands:
- starting a new named session
- $ tmux new -s session_name
- you can use a .tmux.conf file in your home directory to tmux as follows
- setw -g mode-mouse on
- # scrollback buffer size increase
- set -g history-limit 500000
- note that with mode-mouse on you cannot copy paste text (you can scroll). You need to do the following Ctrl+B: (note the colon) and then enter the following command
set -g mode-mouse off - when you have finished copy/pasting text you can turn mode-mouse to on so that you can scroll using the mouse wheel
This blog covers various topics from technical tweaks to latest in computational linguistics, Artificial Intelligence, Machine Learning and Wed Data Mining.
Thursday, February 28, 2013
tmux
Saturday, November 17, 2012
Excel Tricks
Keep the header row displayed when scrolling down a large sheet
Assume that you have a large table that you need to scroll to the bottom and at some point the header row disappears. The solution is to click just below the header row and from Window menu select Freeze Pane. Now the header row will be visible throughout the scrolling.
Assume that you have a large table that you need to scroll to the bottom and at some point the header row disappears. The solution is to click just below the header row and from Window menu select Freeze Pane. Now the header row will be visible throughout the scrolling.
Sunday, September 30, 2012
git (using gitosis)
gitosis is a great way to have a private git server. To install gitosis and perform the basic configurations refer to this guide. gitosis can use ssh access to your remote repositories. Unlike svn (and many other version control systems), git keeps an entire snapshot for your commits instead of a series of diffs. This is great because you can see the entire history of your project locally and develop locally. This comes handy when you do not have access to the internet to push your commits to the remote repository. Moreover, even in the event that the remote repository dies, you can still recover your code using your local database. For this and many other reasons (such as the distributed mirroring and the free github), git is the most popular choice for version control.
Installing gitosis in your remote server
Once you have installed gitosis in your remote server, you must clone gitosis-admin repository to your local machine. You can perform numerous administrative tasks locally via this repository such as adding new projects.
The first time you use git to push something you must specify your name and e-mail address. This can be done as follows.
git config --global user.name "Your Name"
git config --global user.email you@example.com
To add a new repository do as explained here.
Installing gitosis in your remote server
Once you have installed gitosis in your remote server, you must clone gitosis-admin repository to your local machine. You can perform numerous administrative tasks locally via this repository such as adding new projects.
The first time you use git to push something you must specify your name and e-mail address. This can be done as follows.
git config --global user.name "Your Name"
git config --global user.email you@example.com
To add a new repository do as explained here.
- cd gitosis-admin
- git pull This will update your gitosis-admin repository
- If you do not have your gitosis-admin repository, then you must first clone it by
git clone gitosis@server:gitosis-admin.git - Now edit the gitosis.conf file and add your newproject details
[group helloproject]
members = mylogin@myhost
writable = helloproject
Note that the last one is "writable" and not "writeable" - Now commit the changes you made to gitosis-admin repository by,
git commit -am "added the project helloproject"
next push the commit to the local db by git push - Now move to the directory that contains files for your new project "helloproject". Then do git init
- This will initialize the new repository. You can add individual files to track using
git add filename
You cannot add an empty directory to git repository. When you add a file from a directory that directory will be automatically added to the repository. However, if you want to add an empty directory to the repository you can either place a dummy README file in that directory or write a .gitignore file in the directory that you want to add. The .gitignore directory must contain the following two lines.
# Add everything in this direcory
*
# Except for this file.
!.gitignore - Once you have added the files for the newly created helloproject you must commit them.
git commit -am "Initial commit for helloproject" - Now you need to add this new project to your remote repository by
git remote add origin ssh://gitosis@myserver/helloproject.git - You can now push the changes to your remote repository
git push --all - In order to be able to pull back to the same directory (without cloning the pushed project from the remote server) you must edit .git/config file as follows.
[branch "master"]
remote = origin
merge = refs/heads/master - That is it.
Git development cycle (command used frequently)
- You would either add an existing project to git as explained above or will clone a project from the remote repository. To clone do as follows.
git clone gitosis@myserver:helloproject.git - Now you will modify some tracked files and/or add new files to be tracked using
git add filename - Note that there is this concept of staging in git which means you must first "stage" files to be committed and then perform the actual committing. This means you will have to add again any files that you have modified in order for them to get committed. This additional staging step can be skipped by using the -a option during commit.
git commit -am "message" - Commit actually commit things to your local repository. It does not push your changes to your remote server. To push your changes to the server do as follows.
git push - This is the basic (frequent) development cycle. Note that if someone else have pushed before you (i.e. origin has been modified by some other person other than you), then git push will fail. You must first git pull their changes and then check them with your modifications (git fetch will not merge but git pull will try to merge) and then git push again.
Git useful tricks
- Use git status to see what are the changes that are going to be committed in the next commit.
- You can use tags to easily refer (and checkout) important milestones of your project.
To list the current tags do
git tag -l - To create a new tag do as follows
git tag -a v1.0 -m "first version" - To push your tags to the remote server do,
git push origin v1.0 - Now when someone clones this repository that person will also receive the tag v1.0. After cloning a project you can checkout a specific tag as follows.
git checkout v1.0 - If we want to delete the tag see here.
Git hub
- cloning a repository from github
- git clone git://github.com/Bollegala/svdmi.git
- You might not be able to push to the original git directory if you have not set the git url as follows
- git remote set-url origin git@github.com:Bollegala/svdmi.git
Saturday, September 29, 2012
fish shell vs. bash
fish shell is a great tool. But it can be confusing in the initial stages especially to adapt from bash to fish shell. Some important differences are highlighted below.
- escaping wildcards such as *
use double quotes
rm "*.pyc" - command expansion using backticks
the bash command
rm `find -type d -name .svn` would be
rm (find -type d -name .svn) in fish shell
Wednesday, August 29, 2012
Multiprocessing in Python
There are numerous ways to multiprocess in python. Pools give a very easy way.
Note: If you do not catch keyboard interrups as shown in the code then you will have to wait until all workers have finished even if you send Ctrl+C to the parent process. There are other methods such as map (blocks until each result is received and orders sequentially), apply and apply_async where you can provide a callback function that actually determines what must be done with the result. If the task items are not iterable then you must use apply or apply_async and handle the input in the callback.
Note: If you do not catch keyboard interrups as shown in the code then you will have to wait until all workers have finished even if you send Ctrl+C to the parent process. There are other methods such as map (blocks until each result is received and orders sequentially), apply and apply_async where you can provide a callback function that actually determines what must be done with the result. If the task items are not iterable then you must use apply or apply_async and handle the input in the callback.
from multiprocessing import Pool from functools import partial import time import sys def doWork(i, x): """ Does the actual work. """ print i time.sleep(2) return (x * i) pass def multi(): """ Does the actual multiprocessing. """ # Create the pool. pool = Pool() # We must convert the doWork to a function of one argument. # This argument will be filled in by an iterator. partialWorker = partial(doWork, x=5) tasks = range(100) p = pool.map_async(partialWorker, tasks) try: results = p.get(0xFFFF) except KeyboardInterrupt: print "Received Ctrl-c" sys.exit(1) pool.close() pool.join() pass if __name__ == "__main__": multi()
Saturday, August 18, 2012
Using lambda functions for sorting in Python
Give a list L = [56, 78, 98, 34] the following one linear will sort the elements in the descending order of their values.
L.sort(lambda x, y: 1 if y > x else -1)
L.sort(lambda x, y: 1 if y > x else -1)
Wednesday, August 15, 2012
Subscribe to:
Posts (Atom)
Continuously monitor GPU usage
For nvidia GPUs do the follwing: nvidia-smi -l 1
-
If you used Adobe acrobat to annotate a PDF file and you had Acrobat crashed or had to restart the computer abruptly during the annotation p...
-
This is explained here https://docs.anaconda.com/anaconda/user-guide/tasks/remote-jupyter-notebook/ Follow the following steps to use Jupyt...
-
It is possible to arrange multiple references within the same brackets by doing \cite{paper1,paper2} instead of \cite{paper1}\cite{paper2}....