August 2009

Search http logs for unique IP addresses

I recently neeeded to whitelist some IP’s from my apache server.

What I wanted to do is grep my access log (/etc/httpd/logs) for a list of IP addresses that are accessing my application.

I cam up with:

grep "" .log | cut -c 1-10 | uniq

So this was possible because i wanted to find only people who were actually accessing my URI’s so i picked something to grep for that was in the base URI of my app.

Share

code
httpd

Comments Off

Permalink

Java UTC Date formatting

I was trying to fix a test that is expecting a date to come back in UTC format.

It was using the XStream ISO8601DateConverter.

It worked fine if you were in the UK timezone, but not in a different timezone.

It hurt my head, so I wrote a test to demonstrate how to make it work.

Which is DateFormattingTest.java here.

Share

code
java

Comments Off

Permalink

iTerm – Upgrade your Terminal

Spending a lot of time in various ssh sessions?

A bit tired of trying to remember which tab is on which server with the default os x terminal ?

So was I. Hunting around, I saw various hacks (e.g. a bash script, or applescript) to achieve this but also an app called iTerm.

Its free and within 30mins I was pretty much back to my previous terminal existence but with the names of my servers and my username in the tabs titles.

Awesome.

Some things I learned:

1) Some of the preferences I had to hunt for:

Not everything is available from iTerm–>Preferences. There are a couple of menu options of interest (this is iTerm 0.9.6).

View–>Show Session Info …

This lets you change the colors and fonts, etc for your terminal window and also update the default.

Bookmarks –> Manage Profiles …

This is where you can set a lot more options about your session, including making the cursor blink (Something for some reason I found essential:)

The reason they are here is because they are associated with bookmarks, a powerful feature that for example allows you to bookmark an ssh session, and have a whole set of preferences associated with that session.

I would like to see them all aggregated under the “Preferences” option though, because as a os x user, thats where I expect to find everything that I can configure (Posted as an feature request.

2) I wanted the title to change whenever I change directory. Simple, just need the following in my ~/.bash_profile (see here for differences between ~/.bashrc:

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"'

3) This one is not probably very “good form”, but I really like the icon for the os x terminal window. So simply “Show Package Contents” on the iTerm.app and swap out /Contents/Resources/iTerm.icns with the equivalent in the Terminal application Terminal.icns

4) I also wanted a “close x” icon on each tab, and discovered that this is under Preferences –> Tab –> Use compact tab labels. You want to UN check this.

I now have exactly the same user experience as before with some great bonuses, for example, a cool feature is the “blur” of the transparency behind the window.

Share

linux commands
os x
thoughtblog

Comments Off

Permalink

Login message on unix

I just learned how to put up a messages when you log in to a server…

sudo vi /etc/motd

its not a script so dont need to put “echo” just type what you want.

For a cool ascii text generator, see http://asciiset.com/figletserver.html, I like banner3 as a font.

Share

hosting
linux commands

Comments Off

Permalink

IntelliJ Crashes on OS X

I have been running v.8 of IntelliJ on os x for a while now, and noticed the odd crash, particularly after waking up the computer.

Thanks to my colleague Tom Czarniecki I have found a solution that appears to be working.

Some googling turned up very little, but mostly points to the JVM being the problem. I had tried updating the Java installed on os x and setting the JDK to be 1.5 which did seem to improve stability but still crashed.

Tom pointed out that Intellij also has a configuration for the JDK version in its config which I updated to be 1.6+ and then switched my JDK back to 1.6 64bit. That was a week ago and not only have I had no crashes, of course the whole experience is smoother under 1.6! woo hoo!

The trick lies in the file

/Applications/IntelliJ IDEA 8.1.3.app/Contents/Info.plist
<key>JVMVersion</key>
<string>1.6*</string>

To Switch JDKs:

/Applications/Utilities/Java/Java Preferences.app

Some other references I found along the way:

http://www.jetbrains.net/devnet/thread/282406

JDK Update:

http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105update4.html

To See IntelliJ Log output:

~/Library/Caches/IntelliJIDEA8x/log/

UPDATE:

For Intellij9:

/Users/jim/Library/Logs/IntelliJIdea90/idea.log

(I found this using the activity monitor and then “inspect process” and you can see a list of open files and ports)

IntelliJ stores its plugins here (Thanks to these guys) :

~/Library/Application Support/IntelliJIDEA80

Share

code
ides
jdk
os x

Comments (4)

Permalink