Posts

Showing posts from 2011

Tip for VIM

For splitting window.    : split ( for horizontal split )    : vsplit ( for vertical split ) Switch between splitted window    Ctrl-ww Resize splitted window    Ctrl-w + / -   ( 1 unit each time, height )    10 Ctrl-w +   ( resize 10 unit height )    Ctrl-w < / >   ( 1 unit each time, width ) Search and replace    :%s/original/replace/g   ( every occur in file )    :1,$s/original/replace/    :s/original/replace/g ( replace all in current line ) For multiple files    :e ( edit file in new buffer )    :bn ( switch to next file in buffer )    :bp ( switch to previous file in buffer )    :bd ( delete file in buffer , ake close file )    :sp ( edit file in new window ) ETC    :sh ( switch to console ) and Ctrl-d to get back    other way    Ctrl-z (switch to console ) and $fg to get back    show path of current editing file    Ctrl-g ( display file's location )    Ctrl 1 g (display full file's location )

Linux : find out if a dir exist or not

for linux command line, do $ [ -d /tmp] && echo 'dir /tmp not found' then if /tmp not found, it's will display "dir /tmp not found".

Basic with Postgresql

For psql command line, We'll start with >>> psql Create User psql::CREATE USER joe; psql::ALTER ROLE joe PASSWORD 'secret_password'; Or psql::CREATE USER username WITH PASSWORD 'xxxxx'; Or Create an account where the user can create db; psql::CREATE USER username WITH PASSWORD 'xxxxx' CREATEDB; Give him a right on superuser psql::ALTER ROLE joe WITH CREATEDB; psql::ALTER ROLE joe WITH SUPERUSER; Create Database psql::CREATE DATEBASE mydb; Or psql::CREATE DATABASE dbname OWNER rolename; Grant all available privileges to user psql::GRANT ALL PRIVILEGES ON mydb TO joe; psql::GRANT admins TO joe;

Insert text in the middle of text file by sed

I found problem on how to add text line in the middle of the hosts file. Just like below 127.0.0.1   localhost < i want to add text line here > xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx and want to use 'sed', My friend, Sajal Kayan (God of Scripting) introduce me on ref#1, actually I quite not understand that. So he get me 2 approaches. #1   for each time i have to add text line, then do   >>> sed -i 's/127.0.0.1   localhost/127.0.0.1   localhost\n this is new line /' /etc/hosts   >>> sed -i 's/127.0.0.1   localhost/127.0.0.1   localhost\n this is new line 1/' /etc/hosts   >>> sed -i 's/127.0.0.1   localhost/127.0.0.1   localhost\n this is new line 2/' /etc/hosts   then we'll get   127.0.01   localhost   this is new line 2   this is new line 1   this is new line   this is good enough if we don't care about the order. But if you care , Sajal has 2nd approach #2   >>> sed -i 's/127.0.0.1

Do you wanna know what linux's codename you using and its 32 or 64 bits

If you wanna know that, try     >>> lsb_release -cs # for code name or      >>> lsb_release -a # for all information then     >>> uname -m # for display 32/64 bits (i686 or xxx) of     >>> uname -a # for show more information 

Celery issue

(Thank for http://permalink.gmane.org/gmane.comp.python.amqp.celery.user/1695) To create a queue? You know celery automatically declares queues right? You wouldn't 'create' a queue per se, you only declare them, in some context the queue is only actually created when a message is delivered to it. For some transports queues and exchanges *must* be declared by every process that uses them. If you use RabbitMQ then you can create a queue manually like this: from celery import current_app as celery from kombu import Queue, Exchange q = Queue("foo", Exchange("foo", type="direct"), routing_key="foo") with celery.broker_connection() as conn: with conn.channel() as channel: q(channel).declare()

Lubuntu : add kb layout switching

It's just. >> setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,ar (thank  matata   on  http://ubuntuforums.org/showthread.php?t=1039107 )

Python Advanced Ref

(thank  Gaël Varoquaux)  http://gael-varoquaux.info/computers/python_advanced/index.html

A Toy model in Russia Museum, Cool!!!

You guys should take a look at it :) , deep detail on tiny things (thank englishrussia) http://englishrussia.com/2011/11/29/tiny-russia-in-a-st-petersburg-museum/

Remove PYC function in buildbot package

I play with buildbot around 4-5 days. Then I just found '''  buildbot.steps.python_twisted.RemovePYCs '''. There has content in the method is ''' find . -name "*.pyc" | xargs rm ''' which is interesting. :)

Topic: How to detect computer in promiscuous mode

nmap with nmap.org/svn/scripts/sniffer-detect.nse how to use >> nmap --script=sniffer-detect.nse other can find by google with keyword 'detect promiscuous mode computer' thank ref - http://www.markmmanning.com/blog/2009/03/detecting-computers-in-promiscuous-mode.html

Best of VIM tips

ref  http://www.rayninfo.co.uk/vimtips.html  (thank   zzapper) ref  http://www.viemu.com/vi-vim-cheat-sheet.gif  (thank viemu)

Buildbot master.cfg : issue#1

- Don't use WithProperties within SetProperty 

Screen and Byobu , again

When your linux machine have both screen and byobu. you can do below for daemon mode(-d) with name(-S) , sorry don't know about (-m) yet. >> byobu -dmS then >> byobu -r or just byobu (if there is only one session valid, i think) when you wanna go out from screen but want it still deamon >> (in byobu session) byobu -d more tips - f7 for copy mode - ctrl - a ctrl - a for switch tab(window) - f8 for change tab's title - ctrl - a ctrl - c for create new tab(window) - ctrl - a <0-9> for changing windows

Setup python 2.7 for 10.04(natty)

http://askubuntu.com/questions/17841/will-python2-7-be-available-for-10-04-in-the-future

Building python 2.7.1 on lucid

Today, i got a task for build new version of python (2.7.1) on lucid. I googled then found  http://ubuntuforums.org/showthread.php?t=1529315 . tar xzf Python-2.7.tgz cd Python-2.7 ./configure make sudo make altinstall Then create virtualenv -> virtualenv --no-site-packages -p  / usr / bin / pythonx.x.x

Boom De Ya Da

C - Am - F - G thank DisCh

Beer Beer Beer - Rob Manuel

Chord : Beer beer beer F - C  Bb - F - C  thank -> rob manuel and ultimate guitar ( http://tabs.ultimate-guitar.com/m/misc_unsigned_bands/rob_manuel_-_beer_beer_beer_crd.htm )

Setup wget for mac/linux

For mac 1. download wget.xxx.tar.gz from official web. 2. unpack it. 3. run ./configure 4. sudo make install ref to http://www.thelinuxblog.com/linux-man-pages/1/wget

TIP for setup psycopg2 for mac/linux

If something like 'cannot find pg_config' , we should add /path/to/postgres/x.x/bin to PATH environment. That's all for this post.

Revise linux screen (knowledge)

Linux screen is useful! :) Enter to scroll/copy mode. >> Ctrl - a - [  Begin and end copy text >> press space bar to begin copy then space bar to end copy Paste copied text >> Ctrl - a - [ ref : http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/ (thank to samsarin)

Using python-linkedin

After follow instruction from http://code.google.com/p/python-linkedin/ Then you have use the ACCESS_TOKEN that NOT the REQUEST_TOKEN

Purge queues with amqplib

Use amqplib from amqplib import client_0_8 as amqp # Create connection conn = amqp.Connection(     host="localhost:5672",     userid="xxxxx",     password="xxxxxxxxx"     virtual_host="/",     insist=False ) chan = conn.channel() # Get list of queues (list type) # # ex. list_queues = ['queue-1','queue2',....] # for queue in list_queues:     chan.queue_purge(queue) Preparation Data ( thk juacompe )         sudo rabbitmqctl list_queues name > queues.py    inside vim let's do        $s/^/"/  # for insert " infront of queue name       $s/$/",/ # for insert ", infront of queue name       fill queue=["xxxx for the first line       then you will get something like this       ----------------------------       queues_list = ["xxxxx",       "xxxxx",       ...       "xxxxx"]       ----------------------------    Bring your ipython and env

Prepare for python development on Mac

Here's instruction 1. Get the dmg file of python from www.python.org, then install it. 2. Get the dmg file of setuptool from pypi, then install it. 3. Follow step from http://blog.praveengollakota.com/47430655 (very thank to praveen)

Check If host is up

Yah, we will use >>> sudo nmap -sP xxx.xxx.xxx.1-254 -sP: Ping Scan - go no further than determining if host is online

The Story from Proteus's Productivity seeker

Proper install guide I try to install psycopg2 (2.4.1 bcoz 2.4.2 does not work with django 1.3) on Ubuntu Natty today and got ImportError: can't import mx.DateTime module . Hmm... weird. I googled around and found a sequence of command to do a proper installation of psycopg2. $ sudo apt-get build-dep python-psycopg2 $ virtualenv ENV $ source ENV/bin/activate $ easy_install psycopg2 $ easy_install egenix-mx-base ref: http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/ Damn mx and psycopg2==2.4.1 The sequence of commands above did not fix my ImportError: can't import mx.DateTime module . I wasted a day searching until i found its defect on psycopg2 issue tracker . In sum, if you try $ ls /usr/include/python2.6/ | grep mx and you found that you have mx folder there, you're screwed. Psycopg2 will try to use this damn mx instead of default datetime package and that will prevent you from installing psycopg2 in a virtualenv with --

Supervisord and Celery

For setting up supervisord >>> sudo pip install supervisor  note:     Please take care supersivord.conf For setting up celery >>> pip install celery For setting up rabbitmq >>> sudo apt-get install rabbitmq-server

Django : create migration script

Django : create migration script >>> python manage.py schemamigration --initial # for first create migration >>> python manage.py schemamigration --auto # for second and more *** folder migration will be created in Thank, Pam 

Mid night shift - with Intrastructure and Project manager

New Knowledge - Removing package   >> aptitude purge # do remove lib or package. - Be looking for pid file, because its keep pid. - Kill supervisor process and its children   >> supervisorctl -c /etc/ shutdown Thank Joe , PPam

Return Code 127

Exit codes and kill-job signals The exit code from a batch job is a standard Unix termination status, the same sort of number you get in a shell script from checking the " $? " variable after executing a command. Typically, exit code 0 (zero) means successful completion. Codes 1-127 are typically generated by your job itself calling  exit()  with a non-zero value to terminate itself and indicate an error. In BaBar we don't make very much use of this. The most common such value you might see is 64, which is the value used by Framework to say that its event loop is being stopped before all the requested data have been read, typically because time ran out. In recent BaBar releases you might also see 125, which we use as a code for a generic "severe error"; the job log should contain a message stating what the error was. Exit codes in the range 129-255 represent jobs terminated by Unix " signals ". Each type of signal has a number, and what's r

Some Tips for setting up xampp on windows 7 ( and skype )

for command line >> netstat -a -no # look for PID which take port 80, 433 >> tasklist # match app with PID very thank for  http://www.netshinesoftware.com/component/option,com_myblog/Itemid,65/show,Apache-wont-start-on-XAMPP.html/

Command for kernel checking part 1

For Debian User >> dpkg --list | grep linux-image # To list all kernel. ex.result ii linux-image-2.6.38-10-generic 2.6.38-10.46 Linux kernel image for version 2.6.38 on x86/x86_64 ii linux-image-2.6.38-11-generic 2.6.38-11.48 Linux kernel image for version 2.6.38 on x86/x86_64 ii linux-image-2.6.38-8-generic 2.6.38-8.42 Linux kernel image for version 2.6.38 on x86/x86_64 ii linux-image-generic 2.6.38.11.26 Generic Linux kernel image >> uname -r OR uname -mrs # To display current kernel.

A New Semantic File Launcher for Ubuntu

Synapse Installation To install Synapse on Ubuntu 10.10, launch the terminal (Applications >> Accessories >> Terminal), then issue these commands: sudo add-apt-repository ppa:synapse-core/ppa sudo apt-get update sudo apt-get install synapse Then .... space ,ta use it. ref : http://www.spotht.com/2010/12/install-synapse-new-semantic-file.html

Simple restart nautilus

Yahh, it's just. >> nautilus -q

New Knowledge for command : xrandr

xrandr: Linux Resize / Set The Screen Size Quickly Via Command Line Options ex : >> xrandr -q ### get information from connected/disconnected, list of resolution. ref : http://www.cyberciti.biz/tips/linux-resize-screen-size-quickly.html

Fedora needed package (for vbox setup)

sudo yum install make automake gcc gcc-c++ kernel-devel or BIG change sudo yum groupinstall "Development Tools" yum install kernel-devel kernel-headers ref (http://www.fedoraforum.org/forum/showthread.php?t=198819)

Great font - settings for Kubuntu

May be we have have to check Kubuntu-restricted-extra pack for liberation If not, let's get standalone >> sudo apt-get install ttf-liberation then change the system font by going to System-Settings/Appearance/Fonts and click Adjust all fonts -> select liberation sans from the list and fixed width -> Liberation Mono for that time I use - "Use anti-aliasing: Enabled, check Use sub-pixel rendering>RGB, Hinting style:Slight" - "Force fonts DPI> 96 DPI" then make this to .fonts.conf file in your home directory rgb true hintslight true this above is for GTK application. That's all :) Cool stuff and fonts goes smooth ( ps - for font-setting : fixed width i select liberation mono instead of monospace - this is good for thai language:) ) SUPREME THANKS FOR (http://bigbrovar.aoizora.org/index.php/2010/01/16/my-smooth-fonts-se

Setting for Kubuntu (sing)

sec WEP: Hex or Ascii for 64 or 128 aut:shared key

Something about css:margin

margin : 1px; -> margin all = 1px; margin : 1px 2px; -> margin top-bottom = 1px, margin left-right = 2px; margin : 1px 2px 3px; -> margin top = 1px, margin left-right = 2px, margin bottom = 3px margin : 1px 2px 3px 4px; You know that top-right-bottom-left yah, that's all

What to do if you lost your ipythonrc file.

# -*- Mode: Shell-Script -*- Not really, but shows comments correctly # $Id: ipythonrc,v 1.16 2005/04/07 00:08:27 fperez Exp $ #*************************************************************************** # # Configuration file for IPython -- ipythonrc format # # The format of this file is simply one of 'key value' lines. # Lines containing only whitespace at the beginning and then a # are ignored # as comments. But comments can NOT be put on lines with data. # The meaning and use of each key are explained below. #--------------------------------------------------------------------------- # Section: included files # Put one or more *config* files (with the syntax of this file) you want to # include. For keys with a unique value the outermost file has precedence. For # keys with multiple values, they all get assembled into a list which then # gets loaded by IPython. # In this file, all lists of things should simply be space-separated. # This allows you to build hierarchies of fi

May be monitor is good.

In linux, many way to monitor website. Use curl. >> time curl -l | grep HTTP Use ab ( apache benchmark ) >> ab -n 100 -c 10 other will come

Change default jre in linux (ubuntu11.04)

Change default jre >>> sudo update-alternatives --config java

Make external monitor to be PRIMARY

For ubuntu 11.04 ( search keyword ) - for HDMI >>> xrandr --output HDMI1 --primary - for others monitor >>> xrandr --output --primary # press tab until it show the list of display then it's show >>> CRT1 DFP1 DFP2 LVD2

Difference between apt-get update and apt-get dis-upgrade

The “sudo apt-get upgrade” isn’t necessary. It’s a different type of upgrade from “dist-upgrade” You either run one or the other. “apt-get upgrade” will only update your existing packages while “apt-get dist-upgrade” will update your existing packages, remove obsolete packages and install new available packages as well. You can get breakages either way since new packages might be required as dependencies for upgraded packages in the case of “sudo apt-get upgrade” so using “apt-get dist-upgrade” is still the best way so far. Note: This only applies to LMDE since LMDE is a true rolling release. For any other flavor of Mint you’d use MintUpdate levels 1, 2 and 3 all the way. Perhaps someday Clem and Co. will figure out how to tailor MintUpdate so it works properly in LMDE but considering the rolling aspect of LMDE, I’m at a loss as to how theyn would do that. ref http://b10gger.wordpress.com/2011/03/20/difference-between-apt-get-upgrade-and-apt-get-dist-upgrade/ (thank for this website)

About Generate SSH KEY

usage: ssh-keygen -t e.g. >>> ssh-keygen -t dsa Choose passphrase whatever you want and then its appear at ~/.ssh/id_dsa.pub

New Knowledge from Joe The Infra

>>> aptitude search for search app we can download >>> aptitude install postfix for installing MTA >>> aptitude install mailutils don't know what for, but come with postfix >>> vi /etc/postfix/main.cf edit mydestination value for domain. >>> /etc/init.d/postfix restart to restart postfix service >>> tail -f /var/log/mail.log to monitor mail log

Amazing !!! Company :)

Today, I just saw my boss were tuning guitar's string by listen to harmonic's sound. It's locate on fret 5 and 7. I think I will try to do it , soon.

Install firefox plugins (so files) manually

Yahh Hi Again. If we have just a xxxx.so file that we know what it is (so file). Thing we need to do is put that to ~/.mozilla/plugins directory if that directory is not there just mkdir

Yahh Ben's Linux command

Yahh When u have trouble with eject disc by GUI. " just sudo eject " ... ben's said

Setting Up adobe air for ubuntu 11.04 (64bit)

You can build package by yourself using these commands: wget http://airdownload.adobe.com/air/lin/download/2.6/adobeair.deb mkdir adobeair dpkg-deb -x adobeair.deb adobeair dpkg-deb –control adobeair.deb adobeair/DEBIAN sed -i “s/i386/all/” adobeair/DEBIAN/control dpkg -b adobeair adobeair_64.deb rm -rf adobeair sudo dpkg -i adobeair_64.deb Thank Johnny (http://www.ubuntu-corner.com/author/johnny/) ref http://www.ubuntu-corner.com/2011/06/how-to-install-adobe-air-on-ubuntu-11-04-x64/

How do I know what in my box that I used.(linux)

- We can start with command: >>> lspci That's list all PCI devices, But we can advance it by >>> lspci -v - We can see cpuinfo >>> cat /proc/cpuinfo and guess what!!! we have >>> lshw but you have to use super-user for running it.

Quote from The Kirit

" Python not just load module from import but do execute that module so becareful about import order " ... The Kirit

Setup Python/DJango Environment with Virtualenv

for Linux environment.( general purpose ) - sudo apt-get install python-setuptools - sudo easy_install pip - pip install virtualenv (additional pip install virtualenvwrapper) - virtualenv --no-site-packages - source /bin/activate - pip install yolk - pip install ipython ( additional for other module please do - sudo apt-get install python-dev build-essential )

Quote from The Ruxo 2

"The view that you see, Should be in abstract" ... The Ruxo

Quote from The Ruxo

"There are more than one solution to solve the problem." ...The Ruxo

New app from linux

While I do something with my mac, I hear my friend talking about 'iftop' in chatting room, So I start sudo apt-get install iftop then.... boom I do 'sudo iftop', App start!!! new one I have never knew it before , Thank my friend! ------------------------------------- FTOP(8) IFTOP(8) NAME iftop - display bandwidth usage on an interface by host SYNOPSIS iftop -h | [-nNpbBP] [-i interface] [-f filter code] [-F net/mask] DESCRIPTION iftop listens to network traffic on a named interface, or on the first interface it can find which looks like an external interface if none is specified, and displays a table of current bandwidth usage by pairs of hosts. iftop must be run with sufficient permissions to monitor all network traffic on the interface; see pcap(3) for more infor‐ mation, but on most systems this means that it

Way to GO

Today, I create new inspiration with my gf. That we should do something to make people realize what we can do. So I decide to - get my code when I implemented data mining related code for my friend. - improve that code to make it more efficient. - write blog about how to matplotlib and scientific tools.

Yahh Admin Command - skill

I don't know why it's called 'skill'. It end up with an options that provide ability to KILL, STOP, CONT an users. examples -------- >>> skill -KILL -u user_yahoo # send signal kill user by username : user_yahoo or >>> skill -KILL -t pts/1 # send signal kill user by user's tty : pts/1 or you can HALT then let them CONT

Install step for pyearthquake

for ubuntu 10.04 (may be kubuntu,too) - sudo apt-get install python-matplotlib - get basemap from http://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/basemap-0.99.4/ - sudo apt-get install python-matplotlib python-numpy libgeos-dev python-httplib2 python-imaging python-dev checkinstall - sudo apt-get install build-essential - sudo easy_install pyearthquake Great refer to http://pyevolve.sourceforge.net/wordpress/?p=1471