This isn’t just for virt-manager, but any X-Windows app you’d want to tightly integrate into your daily routine. Instead of firing up X11, then SSH’ing to your VM box and typing out virt-manager (insane!) you can script X11 to do everything with 1 mouse click. I have it in my Dock, and Launchbar also recognizes it as an app.
tell application "Finder"
launch application "X11"
end tell
set results to do shell script “ssh -X haddad-vmserver ‘virt-manager’”
Many command line utils have a . file that people rarely use. Ack is one of them.
For a project I’m working on, there’s a var folder (ignored in git) where all the logs go. When I perform an ack search, I have no interest in ack looking through the var folder every single time.
By default, ack only checks your ~/.ackrc file for it’s default switches. You can have per directory ack settings if you add this to your .bash_profile:
I tend to open up several terminals when working on a project, so I usually want them to start in the same directory I’ve been working with. Stick this in your ~/.bash_profile to have your new terminal windows automatically cd to the directory you last used.
export PROMPT_COMMAND='echo `pwd` > ~/.lastpwd'
cd `cat ~/.lastpwd ``
I’m finding this useful as I work with snipmate and have defined custom snippets for solr config files. I still want to use the XML filetype, but I have no real use for the solr fields outside of editing the schema.xml file.
Excellent question on superuser.com with a fantastic answer. If anyone needs to jump through multiple servers via ssh (or any other protocol) take a look at this answer.
iWatch is a perl script that uses inotify to monitor files directories. It’s similar to the watch tool, which can do all sorts of stuff if the files or directories it’s watching are modified or affected in pretty much any way at all.
Install iWatch
apt-get install iwatch
I’ve got this 1 liner in a file to quickly watch my directory and execute a PHP unit test .
I run this with a my argument (a unit test) and then sit there and code away. When I save, it detects the change and automatically runs my test. It’s pretty awesome.
To get a quick idea of what ports you have open on your local box, you can use nmap.
~ jhaddad$ nmap localhost
Starting Nmap 5.00 ( http://nmap.org ) at 2010-01-05 11:06 PST
Interesting ports on localhost (127.0.0.1):
Not shown: 499 closed ports, 492 filtered ports
PORT STATE SERVICE
80/tcp open http
88/tcp open kerberos-sec
548/tcp open afp
631/tcp open ipp
3306/tcp open mysql
3325/tcp open unknown
5900/tcp open vnc
9000/tcp open cslistener
10000/tcp open snet-sensor-mgmt
I bought a MacBook Air in June this year, refurbished. I didn’t really use it a lot for day to day work, and when I didn’t use it I was charging it. It was very convenient - it weighs practically nothing and has almost no impact on me while traveling. When I cut back on using it, I noticed a few things.
When I’d leave it unplugged for a few days, the battery would be dead. After a bit of testing I noticed I was losing roughly 25% of my battery life overnight if it wasn’t unplugged.
Really interesting read about how to examine what’s stored in memcached.
Peep uses ptrace to freeze a running memcached server, dump the internal key metadata, and return the server to a running state. If you have a good host ejection mechanism in your client, such as in the Twitter libmemcached builds, you won’t even have to change the production server pool. The instance is not restarted, and no data is lost.
I ran into an issue just now compiling libjpeg on 64 bit CentOS. I found this very helpful post that gives a workaround using a config.guess file from libtool. For some reason, I didn’t have the folder he suggested, but I did have the alternative (automake).
I get a kick out of stuff like this. Add this to your .bash_profile to be greeted with the remaining space on your disk.
df -h | awk ‘NR==2 {print “Space available " $4}’
This will actually change depending on which version of df you’re using (i think). I get different output on my Mac than I do on a CentOS machine - df seems to auto wrap lines on long drive names, so when I check the space on the CentOS server I need to change the line number (NR goes to 3) and the column to print (down to 3).
I just bought a 1TB Western Digital drive. I am stoked.
However, I tried to format the drive on my Mac (Leopard) and got the error “File system formatter failed” when I tried to format the disk as MacOS Extended (Journaled). Not cool.
I found this forum thread which suggested using multiple partitions to solve the problem. When I was trying this, I went into options and changed the partition scheme from Master Boot Record to GUID partition table. It formatted fine.
I ran into an issue trying to get Imagemagick (convert) working on OSX last night. I had compiled libjpeg and installed it, but when I would compile convert, it would not have jpeg support.
I found this post on dzone, which I followed and was able to use libjpeg just fine.
tar zxvf jpegsrc.v6b.tar.gz cd jpeg-6b cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . ./configure --enable-shared --enable-static make sudo make install sudo ranlib /usr/local/lib/libjpeg.a
I installed CentOS 5 on my VMWare a few days ago. I installed gcc via yum, compiled and installed libxml2. I then tried to install PHP 5.2.3 and received this error:
configure: error: installation or configuration problem: C++ compiler cannot create executables.
It took me forever to figure this out, but I had to install the g++ library, then it compiled fine.
I didn’t find any simple ways to determine how hard our mysql database was working, so I whipped this up. It uses a 10 second delay to figure out the queries per second average.
I use SVN from the command line a lot. I also hate typing things over and over. I wrote this script to add all files to a repository that are not already in there.
When you set up public key authentication, make sure your authorized_keys2 file has the permissions set to 600. If you don’t, it’s likely that you will still be prompted for your password.
I’ve always wanted to know how to do this, and for some reason I always had a hard time finding out how. I needed to rollback a change I had committed to my SVN repository.
The way you rollback to an earlier version of your repository is to do a reverse merge.
Here’s the example off the SVN site. It will do a reverse merge, and roll back the commit you made in version 303.
I saw a post on digg.com about how it’s nice to have “pretty urls” that are easy to tell people. While i’m not sure anyone would remember rustyrazorblade.com slash some ridiculous post name, it’s nice to have for search engines. Unfortunately, it didn’t really go into detail about how to accomplish the urls. A lot of people suggested mod_rewrite. Yes, it’s something you can use, but kind of a pain to set up.
Maybe not breaking news, but I think it’s interesting enough of a point, and I didn’t really find anything about the topic when I googled it. If you do any addition, subtraction, multiplication, or division (and probably a lot more mathematical functions for that matter) and NULL is one of your values, the entire expression will evaluate to NULL.
I noticed after installing PHP 5.1.4 on my brand new MacBook Pro that my scripts weren’t executing. After about 3 hours of messing around, I realized that short_open_tag was turned off in php.ini.
Location: /usr/local/php5/lib/php.ini
Should be: short_open_tag = On
Not sure if this is a common issue, or if the PHP defaults have been changed. I installed the package distributed by Marc Liyanage, found at his homepage.
_Edit: According to the php web site, this should be on by default. _