Using ‘grep’ with Subversion

I use ‘grep’ alot, but it false positives when searching in a Subversion working copy. So I’m using the ‘-r’ flag to recursive search for the phrase ‘quick brown fox’:

$ grep -r 'quick brown fox' *
app/controllers/users_controller.php: quick brown fox
app/controllers/.svn/text-base/users_controller.php.svn-base: quick brown fox

This is only a minor annoyance if there are just two entries, but often that’s not the case. The solution is to add the ‘–exclude-dir=.svn’ flag. But the extra characters causes unnecessary fatigue on my fingers, so I’ve added an alias to my .bashrc file:

alias grep='grep --exclude-dir=.svn'

For maximum mileage, combine this with ‘-ir’:

alias grep='grep -ir --exclude-dir=.svn'

On progress

Opened up a terminal window in Linux Mint today; here’s what it told me:

 ________________________________________
( Steady movement is more important than )
( speed, much of the time. So long as    )
( there is a regular progression of      )
( stimuli to get your mental hooks into, )
( there is room for lateral movement.    )
( Once this begins, its rate is a matter )
( of discretion.                         )
(                                        )
( -- Corwin, Prince of Amber             )
 ----------------------------------------
kzhiwei@woteba ~ $

Creating a branch in Subversion

From the root directory of your repository, issue:

$ svn cp trunk/* branches/path/to/your/branch
$ svn cp trunk/.htaccess branches/path/to/your/branch
$ svn cp trunk/.*.sh branches/path/to/your/branch

Doing something like:

$ svn cp trunk/ branches/path/to/your/branch

Which is much easier to understand does not work as I expect; due to the extra “trunk/” suffix; i.e. “branches/path/to/your/branch/trunk”.

Changing hostname

Should you update /etc/hostname — I did — be sure to update the default tnsnames.ora and listener.ora.

Mine were found in /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin.

Otherwise you’ll get an ORA-12541 message.

OCIEnvNlsCreate() failed

Wanted to work on an Oracle project from home last weekend, but I received this message:

Warning (2): ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system – please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories [CORE/cake/libs/model/datasources/dbo/dbo_oracle.php, line 171]

A little bit of system background here. I’m using Linux Mint 8, running oracle-xe 10.2.0.1-1.1. oci8 was compiled via pecl, with one notable difference from my previous guide. I did not use instantclient (i.e. instantclient,/usr/lib/oracle/11.1/client/lib), so the phpinfo output for the oci8 section was quite different.

It looked like:

OCI8 Support enabled
Version 1.4.1
Revision $Revision: 293235 $
Active Persistent Connections 0
Active Connections 0
Compile-time ORACLE_HOME /usr/lib/oracle/xe/app/oracle/product/10.2.0/server
Libraries Used -Wl,-rpath,/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib -lclntsh
Temporary Lob support enabled
Collections support enabled

I did some searching. I figured it was something to do with environment variables, as my colleague had helped me to resolve the problem previously. I’d forgotten the fix, so this post will serve as a reminder, if needed.

Now ORACLE_HOME and LD_LIBRARY_PATH were defined via my .bashrc, which consists of just one line:

. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

$ echo $ORACLE_HOME
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
$ echo $LD_LIBRARY_PATH
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib:

Some people suggested using Apache’s SetEnv — which I tried — but the error did not go away. That same colleague suggested this morning I use the envvars file in Ubuntu instead, which helped to resolve my problem, at least:

Adding these two lines solves my problem:

export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib:

Seriously, my journey with Oracle has always been a rocky one. I wonder why this product is so… inaccessible.

Shell commands for Ubuntu Netbook Edition 9.10

As above, useful when deploying a client PC.

# installing Wine, IEs4Linux
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

# removing games
sudo apt-get remove gnome-games
sudo apt-get autoremove

# clearing command history
history -c

’svnadmin’ dump/load

In case you’re migrating repository data anywhere:

svnadmin dump old_svn_repos --deltas > svnrepos.dmp
svnadmin create new_svn_repos
svnadmin load new_svn_repos < svnrepos.dmp

ORA-01033: ORACLE initialization or shutdown in progress

Encountered this issue when I came into the office this morning.

The verbiage indicates that Oracle is starting up (or down), but waiting a bit doesn’t cause the error to go away. Time for Google-ing.

$ sqlplus sys/xxxxxxx as sysdba

Replace the ‘xxxxxxx’ part with the actual password, of course. If the ’sqlplus’ command is not recognized, it’s probably a problem with your envvars, but that’s a whole can of worms altogether. But I digress. Let’s see whether the db can be mounted:

SQL> alter database mount;
ERROR at line 1:
ORA-01100: database already mounted

OK, that’s a start. How about open-ing?

SQL> alter database open;
ERROR at line 1:
ORA-01113: file 1 needs media recovery

OK let’s do recovery:

ORA-01110: data file 1: '/usr/lib/oracle/xe/oradata/XE/system.dbf'
SQL> recover datafile '/usr/lib/oracle/xe/oradata/XE/system.dbf'
Media recovery complete.
SQL> alter database open;
Database altered.
SQL> quit
Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

Hope this helps somebody.

Advice, like youth, probably just wasted on the young

This was an article written by a (in hindsight) rather wise lady circa 1997, as she attempted to write a “Guide to Life for Graduates”. I was just listening to the song version, and the words still ring true 13 years later. I’m just going to do a cut-and-paste, as there’s pretty much nothing I can add on:

Ladies and gentlemen of the class of ‘97:

Wear sunscreen.

If I could offer you only one tip for the future, sunscreen would be it. The long-term benefits of sunscreen have been proved by scientists, whereas the rest of my advice has no basis more reliable than my own meandering experience. I will dispense this advice now.

Enjoy the power and beauty of your youth. Oh, never mind. You will not understand the power and beauty of your youth until they’ve faded. But trust me, in 20 years, you’ll look back at photos of yourself and recall in a way you can’t grasp now how much possibility lay before you and how fabulous you really looked. You are not as fat as you imagine.

Don’t worry about the future. Or worry, but know that worrying is as effective as trying to solve an algebra equation by chewing bubble gum. The real troubles in your life are apt to be things that never crossed your worried mind, the kind that blindside you at 4 p.m. on some idle Tuesday.

Do one thing every day that scares you.

Sing.

Don’t be reckless with other people’s hearts. Don’t put up with people who are reckless with yours.

Floss.

Don’t waste your time on jealousy. Sometimes you’re ahead, sometimes you’re behind. The race is long and, in the end, it’s only with yourself.

Remember compliments you receive. Forget the insults. If you succeed in doing this, tell me how.

Keep your old love letters. Throw away your old bank statements.

Stretch.

Don’t feel guilty if you don’t know what you want to do with your life. The most interesting people I know didn’t know at 22 what they wanted to do with their lives. Some of the most interesting 40-year-olds I know still don’t.

Get plenty of calcium. Be kind to your knees. You’ll miss them when they’re gone.

Maybe you’ll marry, maybe you won’t. Maybe you’ll have children, maybe you won’t. Maybe you’ll divorce at 40, maybe you’ll dance the funky chicken on your 75th wedding anniversary. Whatever you do, don’t congratulate yourself too much, or berate yourself either. Your choices are half chance. So are everybody else’s.

Enjoy your body. Use it every way you can. Don’t be afraid of it or of what other people think of it. It’s the greatest instrument you’ll ever own.

Dance, even if you have nowhere to do it but your living room.

Read the directions, even if you don’t follow them.

Do not read beauty magazines. They will only make you feel ugly.

Get to know your parents. You never know when they’ll be gone for good. Be nice to your siblings. They’re your best link to your past and the people most likely to stick with you in the future.

Understand that friends come and go, but with a precious few you should hold on. Work hard to bridge the gaps in geography and lifestyle, because the older you get, the more you need the people who knew you when you were young.

Live in New York City once, but leave before it makes you hard. Live in Northern California once, but leave before it makes you soft. Travel.

Accept certain inalienable truths: Prices will rise. Politicians will philander. You, too, will get old. And when you do, you’ll fantasize that when you were young, prices were reasonable, politicians were noble and children respected their elders.

Respect your elders.

Don’t expect anyone else to support you. Maybe you have a trust fund. Maybe you’ll have a wealthy spouse. But you never know when either one might run out.

Don’t mess too much with your hair or by the time you’re 40 it will look 85.

Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia. Dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than it’s worth.

But trust me on the sunscreen.

RHEL 5 to CentOS 5

I used VirtualBox to install RHEL v5.4 today, as we’re going to use it to host our web application.

The install completed successfully, and then I realized that some kind of subscription plan is required to issue ‘yum’ commands.

So there I was, stuck with an outdated RHEL5 system (circa September 2009, the box tells me), and no RHN login in sight. Great.

Some Google-ing uncovered this article, which pretty much works, except I had to make a few edits here and there.

I thought to repost here instead, in case I ever have to convert RHEL to CentOS again.

It’s an excerpt of root’s commands:

# remove cached packages
yum clean all

# create /root/centos/
mkdir ~/centos
cd ~/centos

# import CentOS's GPG key
wget http://mirror.centos.org/centos/5.4/os/i386/RPM-GPG-KEY-CentOS-5
rpm --import RPM-GPG-KEY-CentOS-5

# web get base packages
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/centos-release-5-4.el5.centos.1.i386.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/centos-release-notes-5.4-4.i386.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm

# install using 'rpm'
rpm -Uvh centos*.rpm
rpm -Uvh yum*.rpm

# clear RHN stuff
rpm -e --nodeps redhat-release
rpm -e --nodeps yum-rhn-plugin

# upgrade to heart's content
yum upgrade

At this moment, the update is buzzing along quite well, thanks to NUS’s mirror.

Return top