Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Tuesday, April 26, 2011

Programmer tips for Mac OSX

Some tips for programmers on the Mac.

emacs: the best place to get emacs for Mac seems to be here http://emacsformacosx.com/ which is also the most no nonsense website design ever

Not really a Mac tip, but I stick my .emacs configuration file in a Dropbox folder, along with any emacs libraries and emacs lisp code I write. Then where-ever I install emacs I make a simple .emacs that points to the one in the Dropbox folder. This also forces me to make sure any platform specific emacs stuff is properly handled.

Clipboard: copy and paste between the terminal and other apps can be done with pbcopy and pbpaste. For example a long complicated command line you want to email to yourself, just do:

echo "long complicated bash command line you don't want to retype" | pbcopy

And then you can Command-V that into your email window. Going the other way is just as simple; Command-C the text you want and pop it into the terminal window with pbpaste.

Open: If you want open an application from the command line you can do it like this:

open -a SomeApp /Users/yourname/SomeFile.hai

You can open a folder in finder

open /Folder/

or

open /Folder/SomeFile.hai

to open that file with it's default application.

Check out the help 'man open', to see other stuff like how you pipe stdout into an application.

Finally check out this guys OpenTerminalHere script. This pops an icon in finder that lets you open a terminal window in the highlighted folder.








Tuesday, June 8, 2010

Adjusting server logging level at runtime

log4j is an awesome logging library for Java. One thing I found out today is that you can change the logging level (debug, warn, info) at runtime, with a few lines of code.

static
{
// This monitors the log4j for changes over a specified period of milliseconds
PropertyConfigurator.configureAndWatch("./resources/log4j.properties", 60000);
}

What this function does is to tell log4j to check the configuration file every minute (60000 ms) for changes. So you can deploy a production server with only warn and error logging, but if something goes wrong you can enable debug and info logging (for example) simply by editing the configuration file and waiting a minute.

(source code formatted by this handy website http://formatmysourcecode.blogspot.com)

Wednesday, September 23, 2009

Windows command window title

Did you know you could change the title in the window of a command prompt using the title command? Example:

title Poop ha ha

Now that's only really useful for making windows with rude words in their title bars right? Well actually, I've found a great use for it. If you have a bunch of command prompt windows open then you have no idea which one is which on the Windows taskbar, once they are stacked. So naming them is a really useful habit since once named you can see which window is which.