- sudo apt install ~/Downloads/google-chrome-stable_current_amd64.deb
- sudo apt-get install gnome-browser-connector
- sudo apt install libreoffice
- sudo apt install git-all
- ssh-keygen -t rsa
- sudo snap install code
- sudo apt install python3-venv
- python3 -m venv ~/.venv/ibkr_python
- https://extensions.gnome.org/extension/1160/dash-to-panel/
- settings -> ungroup applications
- settings -> system -> date/time -> show weekday
- Install vscode, extensions- python
Friday, September 6, 2024
New Linux installation checklist
Tuesday, September 3, 2024
git commands
git fetch
Security cameras from desktop
Need to install ffmpeg in order to access rstp streams
* sudp apt install ffmpeg
Once it is installed, you can access the cameras via
* ffplay rtsp://hpatil:<pass>@<ip_address>:554/stream1
Monday, August 26, 2024
More than one ssh key for the github
* Generate new key:
[18:05:20 harsshal@dell:~/projects]$ ssh-keygen -t ed25519 -C "harsshal@gmail.com"
[18:07:35 harsshal@dell:~/projects]$ cat ~/.ssh/configTCPKeepAlive yesHost 10.234.1.112HostName 10.234.1.112User harshal# Default GitHubHost github.comHostName github.comUser gitIdentityFile ~/.ssh/id_rsaHost github-publicHostName github.comUser gitIdentityFile ~/.ssh/id_ed25519.pubHost github-personalHostName github.comUser gitIdentityFile ~/.ssh/id_ed25519
[18:09:02 harsshal@dell:~/projects]$ git clone git@github-personal:harsshal/icarus_gl.git
Friday, July 5, 2024
Monday, June 3, 2024
Installing a module directly from repo
pip install git+https://github.com/blampe/IbPy.git
pip install git+https://github.com/atreyuxtrading/atreyu-backtrader-api.git
Friday, July 15, 2022
command line / bash variable in awk command
This is how we use a command line / bash variable (named num) in a awk command. We define an awk variable 'var' with -v option. This also shows use of BEGIN block.
awk -F, -v var=$num 'BEGIN{srand(var)} {print $1","$2","rand()}' file_name
Sunday, July 3, 2022
Change nameserver entries in resolve.conf
We can directly change the contents of the file but they dont seem to be in effect. So I added Google's nameserver in the file as follows :
$ sudo cat /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8
nameserver 8.8.4.4
And then updated the file as follows :
$ sudo resolvconf -u
we can also just update /etc/resolve.conf and it will be in effect immediately.
$ sudo sed -i '1 i\nameserver 8.8.8.8\nnameserver 8.8.4.4' /etc/resolv.conf
To remove the changes :
$ sudo sed -i '1,2d' /etc/resolv.conf
Wednesday, June 22, 2022
renaming all the files in a folder
IF we want to rename all the files with a part of the file we can do something following:
for file in $(ls); do nn=$(echo $file | awk -F'_' '{print($2)}'); mv $file $nn; done
Friday, March 11, 2022
shell loop through dates
Easy command to loop through the dates :
for i in 2022-01-{01..31} 2022-02-{01..15}; do echo $i; done
More comprehensive command :
d=2015-01-01
while [ "$d" != 2015-02-20 ]; do
echo $d
d=$(date -I -d "$d + 1 day")
done
Tuesday, October 27, 2020
tp-link archer t3u on ubuntu
Recently got tp-link T3u mini wifi adapter but as usual ubuntu did not have its drivers. So executed following commands and it worked perfectly.
cd /opt
git clone https://github.com/cilynx/rtl88x2bu.git
cd rtl88x2bu
VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf)
sudo rsync -rvhP ./ /usr/src/rtl88x2bu-${VER}
sudo dkms add -m rtl88x2bu -v ${VER}
sudo dkms build -m rtl88x2bu -v ${VER}
sudo dkms install -m rtl88x2bu -v ${VER}
sudo modprobe 88x2bu
Monday, October 26, 2020
sudo access to ldap user
Typically, if you dont have sudo and "gain" sudo access, you cant just add yourself to sudo group. In that scenario, we need to reboot in "advanced mode" and gain access to root shell. Once in, you can have following :
$ sudo cat /etc/sudoers.d/hpatil
hpatil ALL=(ALL) ALL
and then we will have sudo access.
Thursday, February 20, 2020
Bootable USB
sudo dd bs=4M if=~/Downloads/ of=/dev/sdc1 status=progress oflag=syncyou can find out /dev/sdc1 via df command.
Highlight mouse with win + F5
sudo apt install libx11-dev libxcomposite-dev libxdamage-dev libxrender-dev
mkdir ~/git
cd git
git clone https://github.com/Carpetsmoker/find-cursor.git
cd find-cursor
make
echo "bindsym $mod+F5 exec /home/maahi/git/find-cursor/find-cursor -of" >> ~/.config/i3/config
docker commands
sudo echo 'deb https://apt.dockerproject.org/repo debian-stretch main' > /etc/apt/sources.list.d/dockertemp.listOnce installation was done, these were basic commands I used :
sudo apt-get update
sudo apt-get install docker-engine
sudo rm /etc/apt/sources.list.d/dockertemp.list sudo service docker start
https://sakuli.readthedocs.io/en/v1.0.0/docker-containers/
sudo docker pull harsshal/tws:first
sudo docker run -it -p 5901:5901 -p 8000:6901 harsshal/tws:first
sudo docker run -it -p 5901:5901 -p 8000:6901 -exec -u 0 harsshal/tws:first /bin/bash
sudo docker run -it -p 5901:5901 -p 8000:6901 -e "VNC_PW=ibtrader" harsshal/tws:first
sudo docker ps -a
sudo docker start
sudo docker commitharsshal/tws:second
sudo docker push harsshal/tws:second
sudo docker images
sudo docker ps -a | awk '{print $1}' | xargs sudo docker rm
Monday, December 16, 2019
Display all dataframe lines in python
import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
Wednesday, December 4, 2019
Vertica creating a temporary list of numbers
So rather than creating a table, I wanted to pass a list of numbers and see what happens. This is how I achieved it :
SELECT median(val) over() FROM (
SELECT * from (SELECT 1 as val, 1 as row
UNION SELECT 2, 2
UNION SELECT NULL,3
UNION SELECT NULL,4
UNION SELECT 4,5)temp
)temp2;
Tuesday, December 3, 2019
Show all columns in ipython
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
Thursday, November 7, 2019
i3 layout reload configuration
i3-save-tree > i3.jsonWe need to edit json file so that "class" entries in "swallows" sections are un-commented.
Enter following in config "~/.config/i3/config" :
exec load_i3_layout.shWhere as contents of the shell scripts are :
i3-msg 'workspace 1; append_layout i3.json'
i3-msg 'exec /usr/bin/chromium-browser'
i3-msg 'exec /usr/bin/dbeaver'
i3-msg 'exec /snap/bin/pycharm-community'
i3-msg 'exec /usr/bin/nautilus'
i3-msg 'exec /usr/bin/gnome-terminal'
i3-msg 'exec /usr/bin/chromium-browser'
Friday, October 12, 2018
awk delimiters
If its just space, we can use :
awk -F' ' '{print $2}'If its bunch of characters, we can use :
awk -F'[.:]' '{print $2}'
But with space, we need to use as follows :
awk -F'[[:space:].]+' '{print $2}'
I have not been able to figure out to associate '+' only to space. But for now this will server the purpose as long as I can combine multiple '.'
Some other classes are:
[[:blank:][:cntrl:]]
[ \t,:;]
Tuesday, September 25, 2018
Python notebook shortcuts
Ctrl + Enter : Execute current cell
Ctrl + / : multi-line comment
Ctrl + Shift + - : Split cell
Shift + m : Merge cells
a : Above current cell, create a cell
b : Below current cell, create a cell
Saturday, September 15, 2018
Linux mint suspend after more than 1 hour
- sudo apt-get install dconf-editor
- Open Menu->dcong-editor
- In dconf-editor, org > cinnamon > settings-daemon > plugins > power and manually set the value for the "sleep-inactive-ac-timeout" (it's in seconds)
Thursday, March 29, 2018
Installing new packages behind proxy
There are 2 main ways to do this :
pip install pandas
python -m pip install pandas --proxy proxy..com:3128
Second option has many other parameters which can be passed.
For installing via notebook, we can do as follows :
import sys
!{sys.executable} -m pip install numpy
!{sys.executable} -m pip list --user
Wednesday, March 14, 2018
Converting screen into tmux ( terminal multiplexer )
tmux
which allows us to see multiple terminal windows at the same time. We can covert screen in doing something similar.
To split vertically: ctrl + a then |.
To split horizontally: ctrl + a then S (uppercase 's').
To unsplit: ctrl + a then Q (uppercase 'q').
To switch from one to the other: ctrl + a then tab
We can save layouts in screenrc so that we wont have to keep doing this as well.
Friday, February 23, 2018
Shell keyboard shortcuts
On Linux shell, imagine you are executing a long command and then you remember that you need to execute other command first.
Just found out an awesome feature where you can put a command in buffer (Ctrl+U), execute another command and then retrieve the buffer(Ctrl+Y).
Awesome!
Of course, Ctrl+A (Ctrl+A+A when you are in screen) to take you to the start of the line and Crtl+E to take you to end of the line.
Thursday, September 14, 2017
Linux mint buzzing sound when using headphones
- Open terminal and type
Alsamixer
- After that select the sound card (usually PCH)
- Go to far right until optiona
Auto-mute mode
- press up arrow to make it disabled.
Sunday, March 26, 2017
sqllite commandline history via up/down keys
worked like a charm for me.sudo apt-get install rlwrap
rlwrap sqlite3 database.db
Saturday, March 18, 2017
increasing brightness on LXDE display on lubunut
harsshal@dell:~$ ll /sys/class/backlight/
lrwxrwxrwx 1 root root 0 Mar 18 12:58 acpi_video0 -> ../../devices/pci0000:00/0000:00:02.0/backlight/acpi_video0/lrwxrwxrwx 1 root root 0 Mar 18 12:58 intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/
harsshal@dell:~$ ll /sys/class/backlight/*/max_brightness -r--r--r-- 1 root root 4096 Mar 18 12:58 /sys/class/backlight/acpi_video0/max_brightness-r--r--r-- 1 root root 4096 Mar 18 12:58 /sys/class/backlight/intel_backlight/max_brightness
harsshal@dell:~$ cat /sys/class/backlight/*/max_brightness 7255000
harsshal@dell:~$ echo 7 | sudo tee /sys/class/backlight/acpi_video0/brightness 7
harsshal@dell:~$ xbacklight -set 60
harsshal@dell:~$ xrandr -q | grep -w connectedLVDS-1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 290mm x 180mmharsshal@dell:~$ xrandr --output LVDS-1 --brightness 1
Wednesday, March 1, 2017
startup scripts in windows to keep screen active
set WshShell = WScript.CreateObject("WScript.Shell") x = 1 do while x = 1 'Loop forever and ever and ever and ever WshShell.SendKeys "%^" 'SEND CTL + ALT WScript.Sleep 290000 '<5 MINS loopI placed this script at location
C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
and no more locking up the screen....
Tuesday, February 28, 2017
Adding right click options
vim ~/.gnome2/nautilus-scripts/terminalFor nemo, we need to have scripts at following locations:
/usr/share/nemo/actions/
for system-wide actions$HOME/.local/share/nemo/actions/
for user actionsType the command you want to have after right click. In this example, I do :
gnome-terminalAnd make that script executable:
chmod a+x ~/.gnome2/nautilus-scripts/terminal
Friday, January 6, 2017
Citrix receiver on linux version LUbuntu
usb-creator-gtkon my previous installation of linux mint.
Installation always used to hang on certain point on installer and could not figure out why. After googling, came to know that it needs network during installation but does not give any error. So connected LAN cable and got it installed.
First task was to make sure that no issues when connecting to office network. I installed receiver from
https://www.citrix.com/downloads/citrix-receiver.html
After installation, logged in and got an verisign ssl error. So did
sudo cp /usr/share/ca-certificates/mozilla/* /opt/Citrix/ICAClient/keystore/cacertsOne issue is chrome does not open citrix application right away. I need to open it via command line by executable located at
/opt/Citrix/ICAClient/wfica
Friday, May 22, 2015
Creating python executables
So these are the steps:
# Install "cx_Freeze"
# Create setup.py
$catsetup.py
from cx_Freeze import setup, Executable build_exe_options = { "includes": ['numpy', 'pandas','matplotlib.backends.backend_qt4agg'], "packages": [], "excludes": ['tk','ttk','zmq','boto','tkinter','_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger','pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl', 'Tkconstants', 'Tkinter'], "include_files": []} setup( name = "appName", version = "0.1", description = "", author = "Dengar", options = {"build_exe": build_exe_options}, executables = [Executable("sectorize.py")] )#python setup.py build
Tuesday, May 19, 2015
Alt+Tab not working in remote desktop of citrix receiver on Linux mint 17
I found this file in installation directory of ICAClient:
Went to link and started edited this file
[17:43:43 harsshal@lenovo:~]$ ll /opt/Citrix/ICAClient/config/All_Regions.ini
lrwxrwxrwx 1 root root 37 Nov 8 2013 /opt/Citrix/ICAClient/config/All_Regions.ini -> /etc/icaclient/config/All_Regions.ini
[17:44:08 harsshal@lenovo:~]$ sudo vim /etc/icaclient/config/All_Regions.ini
Search for "TransparentKeyPassthrough" in "Virtual Channels" section and add "Remote" in front of it.
[Virtual Channels\Keyboard]
TransparentKeyPassthrough=Remote
Wednesday, April 8, 2015
Google CodeJam in python templates
Following program is for http://code.google.com/codejam/contest/351101/dashboard#s=p2
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 7 15:40:09 2015
@author: hpatil
"""
import sys
def read_file( input_file, output_file):
sys.stdin = open(input_file)
if(output_file != '' ):
sys.stdout = open(output_file,"w+")
read_input()
def solver(line):
last_digit=10
for i in line:
#print(i)
#print(len(line))
digit, mystring = digit2string(i)
if(last_digit==digit):
print(' ',end='')
print(mystring,end='')
last_digit=digit
print()
return
def digit2string(char):
dial = [
[' '],
[],
['a','b','c'],
['d','e','f'],
['g','h','i'],
['j','k','l'],
['m','n','o'],
['p','q','r','s'],
['t','u','v'],
['w','x','y','z'],
]
mystring = ""
for digit in range(len(dial)):
for repeat in range(len(dial[digit])):
if(char==dial[digit][repeat]):
for times in range(repeat+1):
mystring+=str(digit)
return digit,mystring
def read_input():
with sys.stdin as file:
testCases = int(file.readline())
for test in range(testCases):
print("Case #{}: ".format(test+1), end="")
line = file.readline().strip('\n')
solver(line)
#read_file('input','')
read_input()
This one is for with integer reading for http://code.google.com/codejam/contest/351101/dashboard
# -*- coding: utf-8 -*-
__author__ = 'hpatil'
import sys
def show_graph(x,y):
import matplotlib.pyplot as plt
plt.plot (x, y)
plt.grid(True)
plt.show()
def solver(credit, nItems, items):
for i in range(nItems):
for j in range(i+1,nItems):
sum = items[i] + items[j]
if( sum == credit):
print(i+1,j+1)
return
def set_io( input_file, output_file):
sys.stdin = open(input_file)
sys.stdout = open(output_file,"w")
def read_input():
with sys.stdin as file:
testCases = int(file.readline())
for test in range(testCases):
print("Case #{}: ".format(test+1), end="")
credit = int(file.readline())
nItems = int(file.readline())
items = list(map(int,file.readline().split()))
show_graph(range(len(items)), items)
solver(credit, nItems, items)
set_io('input','out')
read_input()
Following program is for http://code.google.com/codejam/contest/3214486/dashboard which took me a loooooong time
# -*- coding: utf-8 -*- """ Created on Wed Apr 8 13:08:15 2015 @author: hpatil Solution to problem : http://code.google.com/codejam/contest/3214486/dashboard """ lit = [ #['abcdefg'] '1111110', '0110000', '1101101', '1111001', '0110011', '1011011', '1011111', '1110000', '1111111', '1111011' ] def display_calci(string): if(string=="ERROR!"): print(string) else: display = list(" ") print(''.join(display)) # line 1 if(string[5] =='1'): display[0]='|' if(string[0] =='1'): display[1]='^' if(string[6] =='1'): display[2]='_' if(string[1] =='1'): display[3]='|' display[4]='\n' if(string[4] =='1'): display[5]='|' if(string[3] =='1'): display[6]='_' display[7]='_' if(string[2] =='1'): display[8]='|' print(''.join(display)) def isDigitFeasible(active, disp_digit, digit): for led in range(7): if(active[led]=='1'): if( disp_digit[led] != lit[digit][led]): return 0 return 1 def get_active_leds(active, disp_digits): active= list(active) count = int(disp_digits[0]) for digit in range(1,count+1): for led in range(len(disp_digits[digit])): if(disp_digits[digit][led]=='1' ): active[led]='1' return ''.join(active) def led_unused(active, disp_digits, possible_digit): not_used = list('1111111') active= list(active) count = int(disp_digits[0]) for digit in range(1,count+1): possible_digit= (possible_digit+1)%10 for led in range(len(lit[possible_digit])): if(lit[possible_digit][led]=='1' ): not_used[led]='0' return ''.join(not_used) def print_digit(active, disp_digits, digit): result_string = "" unused = led_unused(active, disp_digits, digit) for led in range(len(active)): if(active[led]=='1'): result_string += lit[digit][led] else: if(lit[digit][led] == '1'): if(unused[led]=='1'): return "ERROR!" else: result_string += '0' else: result_string += '0' return result_string def get_possible_digits(active, disp_digit, possible): possible_return = [ ] for digit in possible: if(isDigitFeasible(active, disp_digit, digit)): possible_return.append(digit) return possible_return def solver(disp_digits): active= list('0000000') active = get_active_leds(active,disp_digits) if(debug): display_calci(active) count = int(disp_digits[0]) possible = [9,8,7,6,5,4,3,2,1,0] for digit in range(1,count+1): possible = get_possible_digits(active,disp_digits[digit], possible) possible = list(map(lambda x: (x-1) % 10, possible)) if(debug): print(possible) possible_soln = list(map(lambda x: print_digit(active,disp_digits,x), possible)) if(debug): print(possible_soln) soln_set = set(possible_soln) if(len(soln_set) != 1): return "ERROR!" else: return list(soln_set)[0] def read_input(): with sys.stdin as file: nTests = int(file.readline()) for tests in range (1, nTests+1): print("Case #" + str(tests)+": ", end="") disp_digits = file.readline().split('\n')[0].split(' ') if(debug): print(disp_digits[1:]) list(map(lambda x: display_calci(x), disp_digits[1:])) print("-----------") answer_string = solver(disp_digits) if(debug): display_calci(answer_string) print(answer_string) import sys debug = int(sys.argv[1]) sys.stdin = open (sys.argv[2]) #sys.stdin = open ('input2') #sys.stdin = open ('A-small-practice.in') #sys.stdin = open ('A-large-practice.in') read_input()
Friday, March 6, 2015
Wake on by USB devices on Linux mint 17
I realized that Linux mint doesn't support wake on USB mouse / keyboard out of the box. so I created following file and it started supporting wake on USB devices again.
[01:35:11 harsshal@dell:~]$ cat /etc/udev/rules.d/90-keyboardwakeup.rules
#idVendor and idProduct taken from 'lsusb'
SUBSYSTEM=="usb", ATTRS{idVendor}=="0461", ATTRS{idProduct}=="4d15" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../power/wakeup'"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="2002" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../power/wakeup'"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="1002" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../power/wakeup'"
PS: When I rebooted machine, for some reason, my idProduct was changed. So if these don't work after reboot, make sure numbers are correct using "lsusb" again.
Wednesday, November 28, 2012
ctrl+left/right arrow by inputrc
1. On your console, press Ctrl + v - Ctrl + RightArraow. It should either print ^[0D or ^[[D.
2. Replace initial "^[" by "\e" and put it in ~/.inputrc as follows
"\e[D": forward-word
3. Restart session or press Ctrl x - Ctrl r . Confirm binding by
bind -P
Make sure your "env" has TERM=linux. (Putty -> Connection -> Data -> terminal-type string= linux)
Final ~/.inputrc should look like :
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line # Home key
"\e[4~": end-of-line # End key
"\e[5~": beginning-of-history # PageUp key
"\e[6~": end-of-history # PageDown key
"\e[3~": delete-char # Delete key
"\e[2~": quoted-insert # Insert key
"\eOD": backward-word # Ctrl + Left Arrow key
"\eOC": forward-word # Ctrl + Right Arrow key
Monday, October 15, 2012
Tabbed vim
vim -p < file1 > < file2 >
You can see that you can open multiple files and go to next file without saving (something you cannot do in multiple buffer). Youcan switch between files using tabn/tabp, but I do it as follows and use F5/6.
:map <f5> :tabp <cr>
:map <f6> :tabn <cr>
Thursday, May 10, 2012
Shell commands in VIM
:%! sed G Double space the entire file.
:1,5! sed G Double space the lines from 1-5.
Sunday, April 1, 2012
Downloading flash videos in ubuntu
$ cat ~/Dropbox/new_installation/scripts/flash_vid.sh
#!/bin/bash
num=1;
for FILE in $(lsof -n | grep "Flash.*deleted" | awk '{printf "/proc/" $2 "/fd/"; sub(/[a-z]+/,"",$4); print $4}'); do
cp $FILE $HOME/Desktop/$num.flv
size=$( stat -c %s $HOME/Desktop/$num.flv);
if [ $size -gt 5000000 ]; then
num=$[$num + 1];
else
rm $HOME/Desktop/$num.flv;
fi
done
Thursday, March 15, 2012
CVS important commands
cvs commit -m "my comment < filename >
cvs update < filename >
cvs -j < what version you want cvs to think it has > -j<what version you want cvs to go to > < filename >
Tuesday, March 13, 2012
linux commandline mail from shell as attachement
(cat mailtext; uuencode surfing.jpeg surfing.jpeg) | mail sylvia@home.com
uuencode $ATTFILE $ATTFILE | mail -s "$SUBJECT" $MAILTO
echo "hi" | mutt -a $ATTFILE -s "$SUBJECT" $MAILTO
Tuesday, November 22, 2011
mysqldump
insert into table1 select * deom database2.table2;
But they are not on the same host you can use following :
$ mysqldump -h host_name -u user_name -p database table_name "--where= date = 20111121" > temp
We can use "-t" option which will exclude table creation definition from the output.
Thursday, September 1, 2011
Finding latest modified file/directory
$ find . -exec stat \{} --printf="%y %n\n" \; | sort -n -r | head -1
$ for i in `ls`; do echo -n $i" "; find $i -exec stat \{} --printf="%y %n\n" \; | sort -n -r | head -1;done
Sunday, August 14, 2011
Mysql Tricks
- How to get current time
select now();
select curdate();
select curtime();
- How to get date in standard format
select date from table;
will give answer as "2011-08-15"
But
select date+0 from table;
will give answer as "20110815"
- To use group by with a summary.
select col from .... group by col with rollup;
This will give a summary(addition) in the last row.
- When performing string operations
Shell "*" => mysql "%"
Shell "?" => mysql "_"
- Conditional statements in mysql
select (sum(case when shares>0 then shares else - end) from table;
- Case-sensetive comparison
select 'A' like 'a';
1
select 'A' like binary 'a';
0
- Using variables
set @total=0;select (@total := 2+@total) as total from table;
- Checking table sizes
select table_schema "Database name", sum(data_length _ index_length)/1024/1024 "size", sum (data_free)/1024/1024 "Free space " from information_schema.TABLES group by table_schema;
- Command line execution and output
bash# mysql -e "select * from table";
mysql> select * into outfile "/tmp/hpatil" from ...;
But watchout for mysqld host and users when searching for outfile on commandline.
Thursday, July 14, 2011
Linux/Unix NFS bug
To solve this issue,
We need to create a temp file.
mv to original file
and then delete this file.
Now, we will be able to create a new file in same location.
Friday, July 8, 2011
Finding database size through mysql query
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
My bashrc
PATH=$PATH:.:~/hpatil/0/
export EDITOR=/usr/bin/vim
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
PS1="[\t \u@\h:\w]$ "
export HISTSIZE=10000
export HISTCONTROL=erasedups
shopt -s histappend
BC_ENV_ARGS=~/.bcrc
export BC_ENV_ARGS
export INPUTRC=~/.inputrc
#alias vim="vim -c 'set nopaste'"
alias ll="ls -l"
alias rl="readlink -f"
alias vim='vim -c"set nopaste" '
alias vr='vim -MR -c"set nopaste" '
alias li='less -niFX'
alias grep_dir='_(){ bd;grep -a "mt=j" app.$1.tlog | grep -av "not active" | li;}; _'
Tuesday, June 28, 2011
Setting autofs timeout option
OPTIONS="--timeout=86400"
Friday, June 24, 2011
Compression bzip2 command
find ./04 -type f | grep -v bz2 | xargs bzip2
Wednesday, June 9, 2010
Friday, April 30, 2010
Best way to get IE on ubuntu
sudo apt-get install wine
sudo apt-get install cabextract
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-2.99.0.1.tar.gz
tar xzvf ies4linux-2.99.0.1.tar.gz
./ies4linux-2.99.0.1/ies4linux
ln /root/bin/ie6 /usr/bin/ie6
ie6
And nice IE for testing...
Tuesday, April 27, 2010
popup=popup, not popup=newtab
Change:
browser.link.open_newwindow
Mine was set to 3, which told the popups to always open in a new tab. I like that, mostly. But some web sites, TinyMCE editor in this case, like to open a popup and return you back the the original page. I keep losing that original popup. So I wanted to turn off my popup forced to new tab option. To make this behave normally, I set it to 2. All worked just peachy!
Monday, April 19, 2010
Disabling touchpad while typing
cat >> /etc/hal/fdi/policy/shmconfig.fdi << END
<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
<device>
<match key="input.x11_driver" string="synaptics">
<merge key="input.x11_options.SHMConfig" type="string">True</merge>
</match>
</device>
</deviceinfo>
END
In start-up programs, add command
syndaemon -i 1 -d
and reboot!!!
Thursday, April 15, 2010
Listing files by decreasing directory size / space left
If you want to see how is your disk being used, you can use
du -s * | sort -k 1 -rn
If you want to see hidden files,
du -s .* | sort -k 1 -rn
Unfortunately, I couldn't combine both of them and also couldn't use -h option of du
If you want to see size of different partition, you can also use
df -h
Monday, April 12, 2010
Removing ^M from end of the line in VI
:%s/^V^M//g
The ^v is a CONTROL-V character and ^m is a CONTROL-M. When you type this, it will look like this:
:%s/^M//g
In UNIX, you can escape a control character by preceding it with a CONTROL-V. The :%s is a basic search and replace command in vi. It tells vi to replace the regular expression between the first and second slashes (^M) with the text between the second and third slashes (nothing in this case). The g at the end directs vi to search and replace globally (all occurrences).
Friday, April 2, 2010
Invisible plugin in pidgin
wget http://fahhem.com/pidgin/gtalkinvisible.tar.gz
tar -vxf gtalkinvisible.tar.gz
mv gtalkinvisible/gtalkinvisible.so ~/.purple/plugins/
rm -rf gtalkinvisible*
Friday, March 26, 2010
Changing base of a number
echo "ibase=16; obase=A; FACE" | bc
'ibase' is input number base.
'obase' is output number base in ibase number.(10 is A in hexadecimal format).
'FACE' is the number.
when we dont specify any of the value, its assumed to be 10.
Saturday, February 27, 2010
Linux or UNIX password protect files
gpg -c pwd.txt
This will ask you to set new password and create a file called pwd.txt.gpg
Now you can delete pwd.txt.
If you want to retrieve pwd.txt, you can say
gpg pwd.txt.gpg
and it will ask you to enter password and create pwd.txt
Monday, February 22, 2010
Keep Firefox Open When Closing the Last Tab
Changing the behaviour back to the way it used to work is very simple: just type about:config into the address bar and find the browser.tabs.closeWindowWithLastTab entry in the list—using the filter makes it easy. Once you've found that key, double-click on it to change the value from true to false, and Firefox should no longer close when you close the last tab.
Sunday, February 21, 2010
Disabling selinux
echo 0 >/selinux/enforce
Permanent disabling.
vim /etc/selinux/config
.. just change SELINUX=enforcing to SELINUX=disabled, and you're done.
Or we can also change /boot/grub/grub.conf.
On the kernel line of current distribution, add enforcing=0 at the end.
Tuesday, February 2, 2010
New wallpaper script
cat >> ~/Dropbox/new_installation/wallpaper/mast/wall.sh << END
folder="Dropbox/new_installation/wallpaper/mast/"
rm -f ~/$folder/*.jpg
limit=`wc -l < ~/$folder/list`
my_number=`expr $RANDOM % $limit`
name=`tail -n $my_number ~/$folder/list| head -n 1`
wget -O ~/$folder/pics_list http://www.wallpaperbox.com/Celebrities/$name/
limit=`wc -l < ~/$folder/pics_list`
limit=`expr $limit - 10`
limit=`expr $limit / 2`
my_number=`expr $RANDOM % $limit`
echo $my_number
wget -O ~/$folder/$name.jpg http://www.wallpaperbox.com/Celebrities/$name/$name-$my_number.JPG
gconftool-2 -t str --set /desktop/gnome/background/picture_filename ~/$folder/$name.jpg
END
and a bit improvised version of that is
#!/bin/bash
#folder=`pwd`;
folder="/root/Dropbox/new_installation/wallpaper/celeb";
cd $folder;
rm -f *.jpg;
limit=`wc -l < list`;
my_number=`expr $RANDOM % $limit`;
name=`tail -n $my_number list| head -n 1`;
wget -O pics_list http://www.wallpaperbox.com/Celebrities/$name/ ;
limit=`wc -l < pics_list`;
limit=`expr $limit - 10`;
limit=`expr $limit / 2`;
my_number=`expr $RANDOM % $limit`;
wget -O $name.jpg http://www.wallpaperbox.com/Celebrities/$name/$name-$my_number.JPG;
gconftool-2 -t str --set /desktop/gnome/background/picture_filename $folder/$name.jpg;
Tuesday, December 1, 2009
Undo the settings of pppoeconf command
To undo this on ubuntu, follow these steps :
1) Edit nm-system-settings.conf
vim /etc/NetworkManager/nm-system-settings.conf
You have to write
managed=true
under [ifupdown]4) Edit interfaces
vim /etc/network/interfaces
This file must look like this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 dhcp
5) Restart your computer
reboot
6) Finished.
Friday, November 13, 2009
Finding out your external IP address
wget -O - -q icanhazip.com
wget options:
'-O -' will display output on terminal instead of saving it in a file.
'-q' will suppress wget's output (e.g. connecting ,saving)
This are other sites which can be used instead of icanhasip.com
http://www.canyouseeme.org/
http://www.formyip.com/
http://www.checkip.org/
http://www.whatismyip.org/
Monday, November 9, 2009
Multiple line comments and designs
/**************************/
/* Different all twisty a */
/* of in maze are you, */
/* passages little. */
/**************************/
or like
__ _,--="=--,_ __
/ \." .-. "./ \
/ ,/ _ : : _ \/` \
\ `| /o\ :_: /o\ |\__/
`-'| :="~` _ `~"=: |
\` (_) `/
.-"-. \ | / .-"-.
.---{ }--| /,.-'-.,\ |--{ }---.
) (_)_)_) \_/`~-===-~`\_/ (_(_(_) (
( qwe )
) asd (
( zxc )
) (
'---------------------------------------'
I even tried creating a one in one of my files. Then I had to change my message and my design was screwed.
Today in casual browsing I found this and all questions which have been there for years were solved.
All you need to do is
1.
yum/apt-get install boxes
2. Open vim select the text you want inside the box in visual mode.
3. Type : (Prompt will be :'<,'>)
4. And then type !boxes (Prompt will be :'<,'>!boxes)
And you will have nice designed comments.
If you want to undo boxes, select the whole box using visual mode(only box,not starting of next line), and say !boxes -r
Friday, November 6, 2009
Cross-platform Browser Sync - Xmarks
But now I found this and its really working great. I suggest you to try this out too.
http://www.xmarks.com/
Thursday, October 29, 2009
Dropbox - online storage/backup
This is why I always looking for option for getting things off of the local computer.
Recently I came across Dropbox. I am really liking it. It gives you 2 GB of storage free of cost.
To Setup follow these commands
For Ubuntu :
1. Go to https://www.getdropbox.com/downloading and download appropriate package.
2.
# dropbox start -i
For Redhat/Fedora (without Nautilus plugin):
1. If 32 bit,
wget http://www.getdropbox.com/download?plat=lnx.x86
If 64 bit,
wget http://www.getdropbox.com/download?plat=lnx.x86_64
tar zxof dropbox-*.tar.gz
mv .dropbox-dist ~/.dropbox-dist
wget http://dl.getdropbox.com/u/6995/dbmakefakelib.py
wget http://dl.getdropbox.com/u/6995/dbreadconfig.py
python dbmakefakelib.py
It will ask all the information,fill it and let it sync. Then close it using icon->stop or ^C.
python dbreadconfig.py
cat >> ~/.bash_profile << END
~/.dropbox-dist/dropboxd &
END
You will get a folder ~/Dropbox. Create anything in that folder and it will be backed up automatically. Also they have a folder called ~/Dropbox/Public where you can put a document and its available to non-dropbox users too.
Here are other options available
http://en.wikipedia.org/wiki/List_of_online_backup_services
http://tomuse.com/ultimate-review-list-of-best-free-online-storage-and-backup-application-services/
Ubuntu has its own online storage too. Its called Ubuntu_one.
Wednesday, September 30, 2009
my ~/.vimrc
"-------------------------------------
" always show this custom status line
set notitle " to avoid vim renaming the title of the xterm window
set nonumber " we don't need line numbers on the left, because we have status line
set laststatus=2 " always show the status line
set statusline=%<%F%h%m%r%h%w%y\ %{&ff}\ %{strftime(\"%c\",getftime(expand(\"%:p\")))}%=\ col:%c%V\ line:%l\,%L\ %P
" -------------------------------------
" use 2-space indentation
" set tabstop=2 " read :help tab for explanation of tabstop, softtabstop, shiftwidth
" set softtabstop=2 "
set shiftwidth=2 "
" set expandtab " inserts spaces instead of tab (for real tab use ctrl-V - tab)
" -------------------------------------
set showmatch " When a bracket is inserted, briefly jump to the matching one if it is visible on the screen.
set matchtime=3
" -------------------------------------
" set autoindent
" set smartindent
" set paste " you can set paste temporarily, but be aware that it interferes with autoindent
" it turns it off (and many other settings). Read :help paste
" -------------------------------------
set incsearch " search incremental
set ignorecase " search case-insensitive
set smartcase " search case-insensitive for small chars, case-sensitive if at least 1 capital char
set nohlsearch " search highlighting
" -------------------------------------
" This only works if you have plugin under .vim in home dir
" or if you include here a command to source plugin, for example:
" source ~lselector/lselector/.vim/plugin/taglist.vim
:map :TlistToggle
let Tlist_Exit_OnlyWindow = 1
" -------------------------------------
set ignorecase
set smartcase
set incsearch
set title
set wrap
set wildmenu
set noautoindent smartindent
set hlsearch
set paste
set ic
set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab
match ErrorMsg '\%>80v.\+'
match
nnoremap :set invpaste paste?
set pastetoggle=
set showmode
nnoremap :set nowrap!
"set wrap!=
"set showmode
":set mouse=a
":map
":map
":map
":map
:map
:map
noremap :call ToggleMouse()
function! ToggleMouse()
if &mouse == 'a'
set mouse=
else
set mouse=a
endif
endfunction
if match($TERMCAP, 'Co#256:') == 0 || match($TERMCAP, ':Co#256:') > 0
set t_Co=256
endif
command -nargs=1 T2 :2match Search //
2nd paragraph is for not putting tab as /t ( instead, put it as 2 spaces).3rd paragraph is for limiting column to 80. It will start highlighting if it goes after 80. For undoing it in some cases you can say ':match'.
Monday, September 28, 2009
Editing multiple lines in vim
2.Select lines you want to append to.
3.Press I{string}<ESC>
(Note: Its I = capital i = shift+i)
In our case, {string} = #. It takes a while for changes to appear after you press <ESC>.
Saturday, September 19, 2009
Searching using/in URL bar
2. Right click on text box where you enter your query.
3. Click on "Add a keyword for this search".
4. Enter <keyword>(e.g. wk) in keyword box.
5. Save.
Whenever you want to search 'something' in Wikipedia, just type 'wk something' in URL bar. If search doesn't work, try to analyse and modify location field.
Wednesday, September 16, 2009
'rename' command
I wanted to rename all files in a folder from *_vXXX.sh to *_vYYY.sh.
Thus I used
rename XXX YYY *_vXXX.sh
We can specify the number of wild characters in searching pattern by ? e. g. reaplce only a_vXXX.sh but not ab_vXXX.sh
rename XXX YYY ?_vXXX.sh
Monday, September 7, 2009
'ndiswrapper' on fedora 11
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stabl
yum install kmod-ndiswrapper
mkdir ~/new_installation/ndiswrapper_driver
cd ~/new_installation/ndiswrapper_driver
wget http://www.jbg.f2s.com/bcm43.bz2
tar jxvf bcm43.bz2
cd bcmwl5\ driver
ndiswrapper -i bcmwl5.inf
Now reboot your machine and execute these commands.
modprobe ndiswrapper
ndiswrapper -ma
Wednesday, September 2, 2009
Installing GUI on a non-GUI/Command line terminal
yum -y groupinstall "X Window System" "GNOME Desktop Environment"
Friday, August 28, 2009
Comparing 2 files
But diff itself has flag which will compare files line by line.
diff -ay file1 file2 | less
Friday, August 21, 2009
Creating your own file/web host
yum install httpd
ln -s /directory_to_share /var/www/directory_to_share
chmod 777 /directory_to_share
service httpd restart
i take drastic approach when it come to directories.:)
Wednesday, August 19, 2009
Connecting to windows machine from linux machine
Problem will rise on windows machine(of course!!).
1.Go in Start -> Control Panel -> Windows firewall.
2.Goto "Exceptions" tab.
3.Check "Remote Desktop" entry.
4.Press OK.
5.Open System Properties menu (Computers -> Right Click -> Properties)
6.Goto Remote tab
7.In Remote Desktop menu, check "Allow users to connect remotely to this computer"
8.Press OK.
Other variants with similar setting are tsclient on Linux(which is for both VNC and rdesktop),vncviewer(again by default in Linux ,but need VNC on windows machine)
Monday, August 10, 2009
KVM live migration
Before :
[root@euclid ~]# virsh list
Id Name State
----------------------------------
4 veuler running
[root@gauss ~]# virsh list
Id Name State
----------------------------------
Migration Command :
[root@euclid ~]# virsh migrate --live veuler qemu+ssh://gauss/system
root@gauss's password: *****
After :
[root@euclid ~]# virsh list
Id Name State
----------------------------------
[root@gauss ~]# virsh list
Id Name State
----------------------------------
4 veuler running
QEMU Vs KVM :
QEMU provides virtualization purely by means of software, and can be used as a stand-alone package.
KVM--which stands for "Kernel-based Virtual Machine"--provides for hardware-assisted virtualization. It can only be used with newer processors, such as Intel Core 2's or more recent AMD Athlon64's. It must be used in conjunction with QEMU.
Thursday, August 6, 2009
Opening qcow files
losetup -f
Get a free loop-back device, say /dev/loop0.
losetup /dev/loop0 harshal.qcow
kaprtx -av /dev/loop0
vgscan
Get the name of the volume group in qcow file, say vg_harshal.
vgchange -ay vg_harshal
Enable that volumegroup.
lvdisplay
Get logical volume name for that volume group, say /dev/vg_harshal/root1
mount /dev/vg_harshal/root1 /mount_point
Good to Use.
Once done, we need to undo the changes.
umount /mount_point
vgchange -an vg_harshal
kpartx -dv /dev/loop0
losetup -d /dev/loop0
Sunday, July 19, 2009
"Firefox already running" error
I mean
# ps -aux | grep firefox
#
Then do this
cd ~/.mozilla/firefox/[profile_name]
rm lock .parentlock
Wednesday, July 15, 2009
Network tweaks
ifconfig eth0 'new_ip' netmask 255.255.255.0 up
Do not forget to fill in the IP adress you want.
Also if the default routes are screwed up, fix it like this
cat >> /etc/sysconfig/network << END
GATEWAY='Gateway_IP'
END
Friday, July 10, 2009
Setting up NIS server
On server side :
yum -y install ypserv
domainname SCRC
cat >> /etc/yp.conf << END
ypserver 127.0.0.1
END
cat >> /etc/sysconfig/network << END
NISDOMAIN=SCRC
END
service ypserv start
chkconfig ypserv on
/usr/lib/yp/ypinit -m
service ypbind start
chkconfig ypbind on
service ypxfrd start
chkconfig ypxfrd on
cd /var/yp
make
On client side :
yum -y install ypbind
domainname SCRC
cat >> /etc/yp.conf << END
ypserver pioneer
END
cat >> /etc/sysconfig/network << END
NISDOMAIN=SCRC
END
service ypbind start
chkconfig ypbind on
Do not forget to change /etc/nsswitch.conf
Friday, June 12, 2009
SVN Introduction
svn checkout http://fileextensiontype.unfuddle.com/svn/fileextensiontype_fi/ local_directory_name
svn status
svn add *
svn commit
You may also have to do this
export EDITOR=vim
Monday, June 8, 2009
Wordweb Equivalent on Linux
yum install xbindkeys
yum install xclip
xbindkeys --defaults > ~/.xbindkeysrc
xbindkeys -k
Now a small window will appear and you can get code for the key-combination pressed. Use this combination in configuration file ~/.xbindkeysrc. (I got m:0x1c + c:52 for alt+ctrl+e)
cat <<- END
"gnome-dictionary $(xclip -o)"
m:0x1c + c:52
END
echo "xbindkeys &" >> ~/.bashrc
killall -HUP xbindkeys
Equivalent to "delimiter cat" is "echo -e".
That's it. Just select any word you don't know and press your key combination. We will get its meaning.
Friday, June 5, 2009
Using cscope and ctags
1. Cscope
find . -name '*.c' > cscope.files
cscope -i cscope.files
cscope.files is default file name, thus just cscope command would work. To exit, you can type Ctrl+D and to see help, you can type "?".
2.Ctags
cd /path/to/your/project
ctags -R *
vim -t
Once inside a file, hitting ctrl-] while the cursor is over a function/class name, Vim will attempt to open the file with that tag. Pressing ctrl-t will take you back a step. To exit, , regular ":q" should work.
Friday, May 29, 2009
KVM setup
1. Confirm your CPU has virtualisation support
egrep 'vmx|svm' /proc/cpuinfo
2. Install kvm packages
yum install kvm kmod-kvm qemu
3. Install appropriate kernel module
modprobe kvm-intel
OR
modprobe kvm-amd
4.Check whether the module is installed or not
lsmod | grep kvm
Also make sure the kvm is present as a device
ls -l /dev/kvm
5.Mount same NFS share at same path (say /mount_point)
mount server:/nfs_share /mount_point
6.Download ISO file for creation on virtual machine
wget -O /mount_point/fedora.iso http://mirror.cc.vt.edu/pub/fedora/linux/releases/10/Fedora/i386/iso/Fedora-10-i386-DVD.iso
7. Create VM image file
qemu-img create fedoraroot.img -f raw 10G
8. I do not know if there is a command line version of qemu. So if your server does not have GUI, you can use following commands
On server
export DISPLAY=your_machine:0.0
On your_machine
xhost +
You can specify server's name after + sign. But I prefer accepting whole world to avoid routing problems.
9. Start VM using
qemu-kvm -m 512 -cdrom fedora.iso -boot d fedoraroot.img
10. Once installation is done, change boot flag to "c"( which is default). You can also remove CD-ROM from VM.
qemu-kvm -m 512 fedoraroot.img
Wednesday, May 20, 2009
Wallpaper changer script
Here is the script:
rm -f ~/wallpaper/w.jpg ~/wallpaper/widescreen_rss.php
wget -O ~/wallpaper/widescreen_rss.php http://www.mlewallpapers.com/widescreen_rss.php
wget -O ~/wallpaper/w.jpg `grep enclosure ~/wallpaper/widescreen_rss.php | cut -d \" -f 2`
gconftool-2 -t str --set /desktop/gnome/background/picture_filename ~/wallpaper/w.jpg
Put it in your cron so that it will execute daily. You can modify this to fetch picture from any site which will give new picture daily.
All this can be done using following :
mkdir -p ~/new_installation/wallpaper
cat > ~/new_installation/wallpaper/wallpaper_changer.sh << END
rm -f ~/new_installation/wallpaper/w.jpg ~/new_installation/wallpaper/widescreen_rss.php
wget -O ~/new_installation/wallpaper/widescreen_rss.php http://www.mlewallpapers.com/widescreen_rss.php
wget -O ~/new_installation/wallpaper/w.jpg \`grep enclosure ~/new_installation/wallpaper/widescreen_rss.php | cut -d \" -f 2\`
gconftool-2 -t str --set /desktop/gnome/background/picture_filename ~/new_installation/wallpaper/w.jpg
END
chmod a+x ~/new_installation/wallpaper/wallpaper_changer.sh
cat >> /etc/sudoers << END
# crontab root scripts
action-owl ALL=(ALL) NOPASSWD:~/new_installation/wallpaper/wallpaper_changer.sh
END
For fedora :
cat >> /var/spool/cron/root << END
0 12 * * * ~/new_installation/wallpaper/wallpaper_changer.sh >/dev/null 2>&1
END
For ubuntu :
cat >> /var/spool/cron/crontabs/root << END
0 12 * * * ~/new_installation/wallpaper/wallpaper_changer.sh >/dev/null 2>&1
END
This will change wallpaper on 12 noon every day.
Tuesday, May 19, 2009
Installing 64 bit adobe in firefox
wget -O flash.tar.gz http://download.macromedia.com/pub/labs/flashplayer10/libflashplayer-10.0.22.87.linux-x86_64.so.tar.gz
tar xvzf flash.tar.gz
mkdir -p ~/.mozilla/plugins
mv libflashplayer.so ~/.mozilla/plugins
pkill firefox
firefox
Friday, May 15, 2009
Open terminal in current folder
So my workaround is this :
echo gnome-terminal > ~/.gnome2/nautilus-scripts/terminal
chmod a+x ~/.gnome2/nautilus-scripts/terminal
Monday, May 11, 2009
MS office 2007 in openoffice
http://rpm.pbone.net/index.php3/stat/4/idpl/10821603/com/odf-converter-integrator-0.2.0-2.i386.rpm.html
Thursday, May 7, 2009
Radio in linux
mplayer -playlist http://asx.abacast.com/arabian_radio-city-64.asx -loop 0
mplayer - playlist http://www.1.fm/TuneIn/WM/energybbfm128k/Listen.aspx -loop 0
mplayer mmsh://citadelcc-wplj-fm.wm.llnwd.net/citadelcc_WPLJ_FM?MSWMExt=.asf
"-loop 0" because dont let a single corrupt packet stop your radio.
You can always find a radio station of your choice. One radio station which I would really like to promote is http://wnyu.org/.
Friday, May 1, 2009
Sopcast in linux
Here is what I found.
1. Download sopcast for linux from http://code.google.com/p/sopcast-player/.
(No need to download player. Just the source i.e. sp-auth is enough)
2. Create a small script ('~/sop' in my case) as follows :
#!/bin/sh
while [ 1 ]
do
sp-sc $1 3908 8908 > /dev/null &
mplayer http://localhost:8908/tv.asf
done
pkill sp-sc
(while loop because mplayer doesn't start the stream in first attempt.)
3. Search the forums like http://myp2p.eu/index.php?part=sports for your favourite channel and get the sopcast link which will look like sop://broker1.sopcast.com:3912/10912
4.
./sop sop://broker1.sopcast.com:3912/10912
then sit back and enjoy!!!
Tuesday, April 28, 2009
passwordless SSH Log in and even more secure
1.On your Home-comp
ssh-keygen -t rsa
This will generate ~/.ssh/id_rsa.pub file
2.
cat ~/.ssh/id_rsa.pub | ssh office-user@office-comp "cat >> ~/.ssh/authorized_keys"
This will ask you password for one last time. Note that we have used cat command over ssh. Hence we will require the password at least once.
Make sure that you have following permissions on "office-comp" :
chmod 750 ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Monday, April 27, 2009
Getting CD-ROM info in linux
/proc/sys/dev/cdrom/autoclose
/proc/sys/dev/cdrom/autoeject
/proc/sys/dev/cdrom/check_media
/proc/sys/dev/cdrom/debug
/proc/sys/dev/cdrom/info
/proc/sys/dev/cdrom/lock
All the files are readable by all and produce ASCII output when read. They reflect the current state of the CDROM subsystem. This location is part of the procfs's window through to the sysctl configuration mechanism (see man sysctl). All but info are writable by the superuser. There is a column for each CDROM and DVD player in the system in info (not just SCSI devices).
As an example, the auto eject feature can be turned on by the superuser with the command echo "1" > /proc/sys/dev/cdrom/autoeject. This will cause cdroms to be ejected from the drive when unmounted.
Sunday, April 26, 2009
NYU wireless/VPN on linux
Approach 1 :
First off you'll need to get the Verisign Root CA certificate:
1.Go to https://getca.verisign.com/ and download the current Root CA Certificate. It downloads for me as 'getrootcert.cer'.
2.Convert the .cer file to a .pem file:
openssl x509 -in getrootcert.cer -inform d -out verisign.pem
3.Save verisign.pem wherever you want (/etc/ssl/certs would make sense).
4.You need to go to the network manager (usually on the top bar) where you select wireless networks, click the left mouse button and select 'connect to other wireless network'.
5.Select 'WPA2 Enterprise' for a 'Wireless Security', and a whole bunch of new options will appear.
Network Name is 'nyu'
EAP Method is PEAP
Key Type: Automatic (or, I believe AES)
Phase2 Type is MSCHAPv2
Identity is you NYU NetID (eg. js123 -- don't include the @nyu.edu )
Password is your NetID password.
Anonymous Identity, Client Certificate File, Private Key File, and Private Key Password should be left blank.
6.For CA (Certifying Authority, I guess) Certificate file use the verisign.pem file.
It should work fine.
Approach 2:(NYU VPN)
After a while I found second one.I got this thing working in first attempt but the problem is we never know when will NYU-ITS will shut off NYU-Roam3.Here is the procedure.
1.Connect to NYU-ROAM3.
2.Create a VPN connection using cisco VPN.
3.Gateway : vpn.nyu.edu
4.Group name : nyu-vpn
5.User password : NYU net ID password
6.Group password : nyu-net
7.User : NYU net ID
For ubuntu:
Install vpnc and network-manager-vpnc using synaptic first.
Approach 3:
Simplest of all.
1. Get guest username and password from library.
2. Connect to NYU-GUEST.
3. Put that username and password.
But dont get too excited, this user name and password is changed every Monday.