Delete .svn folders recursively from command line

Here is a simple command that will get the job done. It will remove all directories called .svn and their contents.

find . -name ".svn" -exec rm -rf {} \;

This command works on Linux and on Mac OS X

Advertisements

Connecting to EC2 servers from Mac using shortnames

If you have to connect to a number of EC2 machines, typing a long command that looks like the following each time can be painful.

ssh -i  /somepath/somefile.pem   someuser@someserver.compute-1.amazonaws.com

A way to make this command much shorter is by using SSH config file.

Edit (or create) file ~/.ssh/config

vi ~/.ssh/config

Now for each EC2 server that you connect to, add a section that looks like this…

Host test1
HostName 100.100.100.100
User ec2-user
IdentityFile /User/name/ec2pems/test1.pem

Now you can connect to the instance by typing a command that looks like this…

ssh test1

Installing memcached on Mac OS X

Easiest way to install memcached on Mac OS X is using MacPorts (port) http://www.macports.org/

According to the MacPorts website…

The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system. To that end we provide the command-line driven MacPorts software package under a BSD License, and through it easy access to thousands of ports that greatly simplify the task of compiling and installing open-source software on your Mac.

The easiest way to install MacPorts on a Mac OS X system is by downloading the dmg for Lion, Snow Leopard or Leopard and running the system’s Installer by double-clicking on the pkg contained therein, following the on-screen instructions until completion. http://www.macports.org/install.php

Now, to install memcached, type the following command

sudo port install memcached

Memcached Server can be started by running the following command

memcached -vv

To run memcached as a daemon

memcached -d

These instructions have been tested on Mac OS X 10.6.8 (Snow Leopard)

Installing JDK, Tomcat on EC2 Fedora Core 8 instance

  • Download JDK to say /mnt/downloads/

wget -O jdk1.6.bin http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u16-linux-i586.bin?BundledLineItemUUID=uyNIBe.lLxwAAAEjdGQlL7Q3&OrderID=FE1IBe.lTu8AAAEjZGQlL7Q3&ProductID=Dx1IBe.prBgAAAEirRcTvuC_&FileName=/jdk-6u16-linux-i586.bin

  • cd /usr/local/
  • sh /mnt/downloads/jdk1.6.bin
  • mv jdk1.6.0_16/ jdk1.6
  • vi /etc/profile

export JAVA_HOME=/usr/local/jdk1.6
export PATH=$PATH:$JAVA_HOME/bin

  •  Download Tomcat to say /mnt/downloads

wget http://www.gtlib.gatech.edu/pub/apache/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz

  • tar -zxvf apache-tomcat-6.0.20.tar.gz
  • mv apache-tomcat-6.0.20 /usr/local/tomcat6
  • useradd -d /home/tomcat -s /bin/bash -m tomcat
  • chown -R tomcat:tomcat /usr/local/tomcat6/
  • test using commans: su – tomcat -c /usr/local/tomcat6/bin/startup.sh
  • shutdown:  su – tomcat -c /usr/local/tomcat6/bin/shutdown.shconfigure the startup script

or use startup script:

#vi /etc/init.d/tomcat

use the following script:

http://www.linuxzone.org/scripts/tomcat.txt

Add it to chkconfig and turn it on:

# chkconfig --add tomcat
# chkconfig tomcat on

Using Memcached with Java on Windows

Windows Memcached software is available on this page: http://code.jellycan.com/memcached/

Download the Win32 binary zip file. Unzip the file (memcached.exe) in a directory of choice and then do the following to install memcached as a service.

c:/bin/memcached.exe  -d install

At this point the service is installed, it can started or stopped using the following commands

c:/bin/memcached.exe -d  start
c:/bin/memcached.exe -d  stop

By default, the memcached service has a limit of 64MB. If that is not enough, you can increase by tweaking the Windows Registry. Open the following entry.

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/memcached Server

Locate the entry called ImagePath. To increase the limit to 128MB set the value to…

“c:/bin/memcached.exe” -d runservice -m 512

A good Java client for memcached is spymemcached. Download the jar file from here: http://code.google.com/p/spymemcached/

// Get a memcached client connected to the local server
MemcachedClient c = new MemcachedClient(AddrUtil.getAddresses("127.0.0.1:11211"));
// Store a value (async) for one hour
c.set("someKey", 3600, someObject);
// Retrieve a value (synchronously).
Object myObject= c.get("someKey");