Archive

Archive for the ‘linux’ Category

VIM cheatsheet

May 7th, 2011 rupert No comments
set nocompatible
set nu
set expandtab
 
"this will change tab to spaces
set ts=2 
set shiftwidth=2
set expandtab
 
set hlsearch
syntax on
 
"Use TAB to complete when typing words, else inserts TABs as usual.
"Uses dictionary and source files to find matching words to complete.
 
"See help completion for source,
"Note: usual completion is on <C-n> but more trouble to press all the time.
"Never type the same word twice and maybe learn a new spellings!
"Use the Linux dictionary when spelling is in doubt.
"Window users can copy the file to their machine.
function! Tab_Or_Complete()
  if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
    return "\<C-N>"
  else 
    return "\<Tab>"
  endif
endfunction
:inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>
:set dictionary="/usr/dict/words"
 
set numberwidth=5
set cmdheight=2
"To map: imap ;f foobar => Type f; foobar will be inserted
 
"RSPEC Where ! is execute command. % is the current file
":!rspec %
 
"Map RSPEC test to ,t
":map ,t :w\|!rspec %<cr>
Categories: linux Tags:

Subversion

November 1st, 2009 rupert Comments off

This post will contain a summary of information regarding subversion scattered from old posts.

Installation on Debian

1. Packages

#apt-get install subversion
#apt-get install libapache2-svn

2. Login as root then create the repository.

#cd /data
#svnadmin create /repos --fs-type fsfs

3. Set the permissions

#groupadd subversion
#addgroup rupert subversion
#addgroup www-data subversion
 
#chown -Rf www-data:subversion /data/repos
#chmod -Rf 770 repos

It’s better to set the necessary users and groups that would use subversion now. Later on, if we need to checkout using svn+ssh and setup a passwordless svn, then we won’t get permission issues.

4. In /etc/apache2/sites-available/2rmobile, add this to the configuration.

        <Location /repos>
        DAV svn
        SVNPath /data/repos
        SVNAutoversioning on
        AuthType Basic
        AuthName "SVN - Your Project"
        AuthUserFile /data/svn-auth-file
        Require valid-user
        </Location>

5. Enable the webdav module then restart apache.

#a2enmod dav
#a2enmod dav_svn
#/etc/init.d/apache2 restart

Passwordless SVN

On your local macbook pro (mbp), we need to generate the ssh keys from the local machine, upload it to the remote machine and append it in the authorized_keys.

On the local machine:

#ssh-keygen -t rsa
...
#cd /Users/rupert/.ssh
#scp -r id_rsa.pub rupert@2rmobile.com:/home/rupert/.ssh/id_rsa_mbp.pub

On the remote machine:

#cd ~/.ssh
#touch authorized_keys
#cat id_rsa_mbp.pub >> authorized_keys

Test on the local machine by doing

ssh rupert@2rmobile.com

. In my mbp, a dialog box from keychain is asking for the password. To circumvent this, we can add the passphrase to our identities.

#ssh-add -K
... enter the passphrase twice...
#ssh-add -k (adds it to the identities)
#ssh-add -l (lists the identities)

Now the benefits of having a passwordless svn:
- ofcourse it saves us a lot of time
- rails capistrano deployment

References:
http://www.howtoforge.com/debian_subversion_websvn

Subversion Tips and Tricks

http://subversion.tigris.org/faq.html#ssh-authorized-keys-trick

1. Checking out using svn+ssh and having passwordless ssh authentication. My personal favorite when working with personal projects since I have full control.

svn co svn+ssh://www.2rmobile.com/data/repos/web/rails/halalan2010 halalan2010

But for work projects, I normally use webdav

svn co "http://www.2rmobile.com/repos/web/halalan2010" halalan2010

2. svn+ssh on a custom or different port other than 22. I have my ssh on 2210, so we need to tell svn+ssh to use 2210

vim ~/.subversion/config
 41 [tunnels]
 42 ### Configure svn protocol tunnel schemes here.  By default, only
....
 53 ### built-in ssh scheme were not predefined, it could be defined
 54 ### as:
 55 ssh = $SVN_SSH ssh -p 2210

http://www.techper.net/2009/01/11/changing-port-number-of-svnssh-subversion-protocol/

3. svn diff – shows you the changes in a directory. This is useful for creating patches.

svn diff -r HEAD
svn st -q

3. svn switch oldURL to newURL - very useful when I’m working at home or in the office, since the svn server has a public/private IP.

4. svn log – shows you who committed and why (from the messages)

5. ignoring specific set of files in a directory.

svn propset svn:ignore "*.log" log

6. ignoring a whole directory.

svn propset svn:ignore dirname .

7. ignoring using an ignore file (.ignore.txt) in a directory (sample.xcodeproj).

*.pbxuser
*.mode1v3
xcuserdata
svn propset svn:ignore - F .ignore.txt .
Categories: subversion Tags:

Rails Note #13: RubyonRails + Oracle on Linux (i386 / x64)

December 11th, 2008 rupert No comments

In summary, install Oracle Instant Client and try to run sqlplus. If sqlplus connects to the oracle sid then go ahead and install the rails adapters for oracle. What is important to note here, is to install the oracle-instantclient for the architecture of your machine.. I have tested this on Debian Lenny (i386) and CentOS5 (x64)

1. Download from http://www.oracle.com/technology/software/tech/oci/instantclient/

a. oracle-instantclient-basic-10.2.0.4-1.i386
b. oracle-instantclient-devel-10.2.0.4-1.i386
c. oracle-instantclient-sqlplus-10.2.0.4-1.i386

2. Unzip everything to /opt/oracle/instantclient . You should have something like the ff:

[root@csapp1 instantclient]# ls -la
total 102704
drwxr-xr-x 3 root root     4096 Dec 10 21:54 .
drwxr-xr-x 3 root root     4096 Dec 10 22:03 ..
-rw-r--r-- 1 root root      228 Dec 10 21:52 BASIC_README
-r--r--r-- 1 root root  1609607 Dec 10 21:52 classes12.jar
-rwxr-xr-x 1 root root    67542 Dec 10 21:52 genezi
-r--r--r-- 1 root root     1525 Dec 10 21:52 glogin.sql
lrwxrwxrwx 1 root root       17 Dec 10 21:54 libclntsh.so -> libclntsh.so.10.1
-rwxr-xr-x 1 root root 21038613 Dec 10 21:52 libclntsh.so.10.1
-r-xr-xr-x 1 root root  3796601 Dec 10 21:52 libnnz10.so
-rwxr-xr-x 1 root root  1664116 Dec 10 21:52 libocci.so.10.1
-rwxr-xr-x 1 root root 72674185 Dec 10 21:52 libociei.so
-r-xr-xr-x 1 root root   138033 Dec 10 21:52 libocijdbc10.so
-r-xr-xr-x 1 root root  1435561 Dec 10 21:52 libsqlplusic.so
-r-xr-xr-x 1 root root   997409 Dec 10 21:52 libsqlplus.so
-r--r--r-- 1 root root  1555682 Dec 10 21:52 ojdbc14.jar
drwxr-xr-x 4 root root     4096 Dec 10 21:52 sdk
-r-xr-xr-x 1 root root     7773 Dec 10 21:52 sqlplus
-rw-r--r-- 1 root root      232 Dec 10 21:52 SQLPLUS_README
-rw-r--r-- 1 root root      516 Dec 10 21:53 tnsnames.ora
[root@csapp1 instantclient]#

3. Make a symbolic link for libclntsh.so.10.1 as shown above.

4. Create the Oracle Environment variables

export ORACLE_HOME=/opt/oracle/instantclient
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME

5. At this point, you should have oracle-instantclient properly installed. You can test by running sqlplus.

[root@csapp1 instantclient]# sqlplus
 
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Dec 11 11:47:40 2008
 
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

NOTE: Sometimes you will get a SEGMENTATION FAULT. If so, try to open a new shell with the environment variables loaded and do an sqlplus in a directory which is not /opt/oracle/instantclient.

6. Install the oracle adapter for rails

7. gem install ruby-oci8

8. gem install oracle_enhanced-adapter –source=”http://gems.rubyonrails.org/”

activerecord-oracle-adapter (1.0.0.9250)
activerecord-oracle_enhanced-adapter (1.1.8)

NOTE: Try to look for the latest gems, the source above is at the time of this writing so it might change.

9. Test using irb

[root@csapp1 instantclient]# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'oci8'
=> true
irb(main):003:0>
Categories: debian, linux, oracle, rails, ruby Tags: , , ,

Chinese Debian Repository

November 7th, 2008 rupert Comments off

Its been a long time I have not updated debian. Now, debian.cn99.com is not working. However, there is a new mirror in town.. www.anheng.com.cn.

http://www.debian.org/mirror/list

Categories: china, debian Tags: ,

Post Install Apache2.x, ColdFusion 8

May 28th, 2008 rupert No comments

After binding Apache2.x and ColdFusion 8, I find it very useful to follow the post-install instructions below:

1. Copying ColdFusion Admin directory to /wwwroot (webroot)

# ln -s /var/www /wwwroot
# cp -Rf /opt/coldfusion8/wwwroot/CFIDE /wwwroot/
# rm /wwwroot/index.html
# cd /wwwroot
# ln -s CFIDE cfide

2. Adding index.cfm to DirectoryIndex.

# vim /etc/apache2/mods-available/dir.conf
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm index.cfm

3. Restart apache

/etc/init.d/apache2 stop 
/etc/init.d/apache2 start

4. Browse Admin page for the first time

Categories: debian Tags: , ,