Aug 242012

I’m usually using mysql, today for a test i had to use Postgres. I’m fairly happy how smooth everything went, as it was mainly verifying a database creation and setup. Here the little things I needed to do.

  • download and install I won’t use postgres regularly and I don’t want to have it autostarting or deeply integrated in my system. 
  • add postgress path to ~/.profile, all you need is export PATH=/Applications/$PATH. Otherwise an older, macos-native postgres client will be used.
  • open postgres console from terminal using psql -h localhost
  • create user create user <usr> WITH password ‘<pwd>’ CREATEDB;
  • make user super user alter user <usr> with superuser;
  • list existing databases \list
  • drop a database drop database <db>;
    • in case of error: “ERROR:  database “<db>” is being accessed by other users”
    • run select procpid from pg_stat_activity where datname=’<db>‘; to get a list of process ids that are accessing the database.
    • in terminal run kill <pid> for all processes out of the list provided by the statement above
  • exit postgres console with \q.

This is all I need for my test environment.


Popularity: 10% [?]

Tags: , , , ,
Aug 162012

Following up my previous post I also want to see the contents of any text file in preview without opening an editor.

I found this page with lots of quicklook plugins: One of the plugins there is QLStephen. Download it, mount it, then open Terminal and run:


sudo cp -R /Volumes/QLStephen_1/QLStephen.qlgenerator /Library/QuickLook/

qlmanage -r


Result: Manifest.MF is now previewed in Finder and I don’t need to open a text editor anymore.

Popularity: 11% [?]

Tags: , , , , ,
Aug 162012

It happens quite regularly that I need to extract a JAR or WAR file for a brief inspection. Of course I can do it on command line however, when operating in Finder I wanted to get something that just unarchives a selected file by mouse click. 

To achieve this I used for the very first time Automator, a tool I didn’t really think would be providing a solution to any of my needs. What I did do:

  • Open Automator
  • New > Service
  • In the drop down menus choose in Service receives selected files or folders in
  • In Actions search for Run Shell Script and double click on it
    • enter this as command line unzip -n “$1″ -d “$1″.zip
    • select for Pass input as arguments
  • Click on Save and give a name, e.g. Extract Archive

To verify:

  • Open Finder
  • Right click any archive
  • In the context menu select Services > Extract Archive

Note: As a filetype cannot be selected the menu is available for all files and folders. If you select something that is not a extractable with unzip you’ll see an error message.

Popularity: 4% [?]

Tags: , , , ,
Jun 282012

A small, handy way to find stuff easily via commandline in a set fo files:

grep -inHR “search term” –include=’*.xml’ *

  • i ignore-case
  • n line number
  • H Print the filename for each match
  • R  –include=<Pattern> Recurse in directories only searching file matching <Pattern>
  • * The preceding item will be matched zero or more times.

in all sub folders in a given folder all files that end with xml and contain search term are listed in the output with name and the matching line including the line number.

I used to use file search in ultraedit, however my license expired and ultraedit on mac is not quite as powerful as its Windows equivalent so I didn’t bother to renew. Grep is my new best friend. 

Update: sweet example:

grep -inRH “4.7.0″ –include=’*pom.xml’ * -B2

is looking in pom files that contain the given string and prints out 2 lines before.

Popularity: 4% [?]

Tags: , , ,
Apr 272011

I was not happy about to realize that one of the last Apple updates updated maven to version 3. Maven in it’s new version does brake quite a few concepts which were in version 2, and maven does not go for downwards compatibility.

I had no issues with simple builds, but when I had a multi-module project which requires jars to be installed in the repository maven 3 just started throwing exceptions at me. As my clients still are on maven 2.0+ I was looking for a solution how to downgrade it.

It actually is fairly simple as the update adds a new maven version and modifies the default executable but it doesn’t uninstall previous versions. These steps will give you back what was yours before:

$ cd /usr/share/java
$ ls -q1 | grep maven
#check if your desired maven version is there

$ cd .. #go up
$ ls -l | grep maven
#check what current version is
maven -> java/maven-3.0.2
$ sudo rm maven #remove unwanted symlink
$ sudo ln -s java/maven-2.2.1 maven #set it to maven 2.2.1

That’s it. To test out if it runs or not just reopen Terminal and enter mvn -version and it will be now version 2.2.1 :)

Popularity: 57% [?]

Tags: , , , ,