Sep 21

Strange, but I couldn’t empty the trash of a mounted SD card. Importing photos is no problem, because iPhoto offer to delete the photos after import. Importing videos with iMovie is different. When I copy the raw data only I have no option to empty the SD card.

Terminal to the rescue

chflags -R nouchg .Trashes/
rm -rf .Trashes/*

Caution: The first line clear recursively the user immutable flag

Tagged with:
Sep 17

The preferences of the Terminal.app doesn’t offer to define a keyboard shortcut. Using Spotlight to open apps is sufficient in most cases. If you use an app like the Terminal more often you might be looking for a simple keyboard shortcut. Install Quicksilver and add a custom trigger:

Now pressing Option-T opens the Terminal or gives it focus.

Tagged with:
Sep 15

Do you use Drools, a very popular rule engine? Do you use IntelliJ IDEA? Then this post might be interesting for you!

update: Since IDEA 12 there is built-in Drools support

Peter Gromov showed me the power of custom file types. Another secret I discovered in the world’s greatest Java IDE.

I followed his advice and created a custom file type for DRL files.

Nice, isn’t it? Besides the coloring you get:

  • basic code completion (all configured keywords)
  • support braces, brackets, parens, string escapes
  • 4 different keyword sets (4 different colorings)
  • Comment/Uncomment lines (Mac: Command-/)
  • Block-Comment/Uncomment (Mac: Control-?)

You can easily import this IDEA drl file type with File > Import Settings... I didn’t tried to import them, so back up your settings please.

You want more? Go and vote for IDEA-24348.

Tagged with:
Sep 08

Two days ago I have had the problem, that our customer wanted an already deleted calculation back. I knew the name of that class, so first I had to find out when it was deleted. This can be done in two ways

List all deleted files

git log --diff-filter=D --summary

Find sha-1 key of your missing file

git rev-list -n 1 HEAD -- ./path/to/file/MissingFile.java

Now, we can checkout the previous revision (revisionNumber^).

Recover a single file from a commit

git checkout revisionNumber^ -- ./path/to/file/MissingFile.java

We’re done! The file is recovered.

This solution was found at stackoverflow. Charles Bailey’s solution helped me the most.

Tagged with:
Sep 06

Are you using Google Analytics to see what your readers like? Do you want to display your top posts as a widget like this:

You need the Google Analytics plugin. Next, you need to edit your sidebar.php. E.g. through Apperance > Editor > Sidebar
The following code will do the trick.

<!--sidebox start -->
<div id="top-posts" class="dbx-box">
  <h3 class="dbx-handle">Top Posts</h3>
  <div class="dbx-content">
<?php
$start = date('Y-m-d', (time() - (60 * 60 * 24 * 365)));
$end = date('Y-m-d');
$showpages = 10;
$thispage = 1;

$login = new GADWidgetData();
$ga = new GALib($login->auth_type, $login->auth_token, $login->oauth_token, $login->oauth_secret, $login->account_id, 60);
$pages = $ga->pages_for_date_period($start, $end, 10);

echo "<ul>";
$excludes = array("(not set)", "my-to-excluded-post-title");
foreach($pages as $page) {
  $url = $page['value'];
  $title = $page['children']['value'];
  if ( !(in_array($title, $excludes)) && (strpos($url, '?p=') == false) ) {
    echo '<li><a href="' . $url . '">' . $title . '</a></li>';
    $thispage++;
  }
  if($thispage > $showpages) break;
}
echo "</ul>";
?>
  </div>
</div>
<!--sidebox end -->

Line by Line

Line 06 defines the number of days to consider (365)
Line 08 defines the number of posts you want to display (10)
Line 13 defines the minimum number of hits a post must have in order to be considered (10)
Line 16 defines an array with a list of excluded titles
Line 20 checks if the title is part of the excludes or if the title starts with ?p= which is in my case the prefix of a post preview

This post is inspired by Rob’s post. I just added some filtering. My first php lines of code:)

Update:

Changed line $ga = new GALib($login->auth_token, $login->account_id, 60);
to $ga = new GALib($login->auth_type, $login->auth_token, $login->oauth_token, $login->oauth_secret, $login->account_id, 60);

Tagged with:
Aug 29

This one is a must have! If you use IDEs like IntelliJ IDEA you are used to press magic keys. Here is how you add some magic to the usage of git from your bash terminal. You need the git bash completion. If you use Homebrew and installed git you can start immediately with modifying your bashrc. In my case I change /etc/bashrc.

Git Completion

# add git completion
source /usr/local/etc/bash_completion.d/git-completion.bash

That’s it! Now enjoy the power of the tab-key: Complete git commands, sub-commands, branch names, remotes, …

Git Prompt

The above defines a git prompt as well. You need to add $(__git_ps1 ” %s”) to your prompt.

PS1='\[\e[0;32m\][\w]$(__git_ps1 " %s")\n\u@\h$\[\e[m\] '

Everything between the double-quotes will be displayed in your prompt. The %s will be replaced with the current branch name. Some more information can be
added with flags (see comments in git-completion.bash). I like these:

GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUPSTREAM="auto"

GIT_PS1_SHOWDIRTYSTATE displays unstaged changes “*” or staged changes “+” next to the branch name. GIT_PS1_SHOWUPSTREAM=”auto” indicates if you are behind “<", ahead ">” or diverged “<>“.

Sample

KYPSTA-2902-hdnCode-for-SecurityProvider is the branch name, I have untracked files and I’m ahead. Cool.

To do a good job we should finish with coloring our terminal.

Tagged with:
Aug 29

Terminal Coloring
Here is what is necessary to achieve the above layout and coloring. I want these changes for all my accounts on my laptop, so I edit the /etc/bashrc.

# terminal coloring
export CLICOLOR=1
export LSCOLORS=dxfxxxxxbxegedbxbxdxdx

CLICOLOR=1 enables the coloring. LSCOLORS defines the coloring. There are 11 attributes that can be colored. Each attribute has a foreground and a background color. A color is represented by a single character, now we have our 22 character string: dxfxxxxxbxegedbxbxdxdx. See the manual of ls and search for LSCOLORS for details.

Prompt
I like to have the prompt always at the same spot and want to see the full path of the working directory. Therefore I change the default prompt:

# two line prompt with full path
PS1='\[\e[0;32m\][\w]\n\u@\h$\[\e[m\] '

Explained:

  '\[\e[0;32m\]     change font to green
  [\w]\n            current working directory + newline
  \u@\h$            user@host$
  \[\e[m\] '        stop the green coloring and add a trailing space

What else is possible? See enhance the system prompt.

Tagged with:
Jun 25

Visor is an extension of the Mac Terminal.app that allows you to define a hot-key for quickly toggle a terminal window. The terminal has focus and is always at the same place. You can define where this place should be. All settings of a standard terminal like fonts, colors, opacity are applicable. You can use tabs but window groups don’t work. The installation is straight forward. Give it a try!

Tagged with:
Jun 19

A couple of days ago I bought a MacBookPro and so I switched from Ubuntu to MacOS. Unfortunately Apple did not ship their unix-version with a package-manager. After a google search I found two alternatives. MacPorts and Homebrew. The press for MacPorts seems not as good as for Homebrew, so I gave Homebrew a try.

For both you need Xcode to be installed:(
UPDATE: At least for Homebrew this is no longer true – see Homebrew without Xcode – save 1.5 GB

sudo curl -L http://github.com/mxcl/homebrew/tarball/master | sudo tar xz --strip 1 -C /usr/local

Done! This commands will download homebrew and extract it into /usr/local. Some advise you to change the owner of /usr/local. I don’t and add a sudo when I install something. Time to demonstrate it:

sudo brew install maven

Maven is installed. Try mvn --version. If you want to know what is extracted and installed use the verbose mode:

sudo brew -v install maven

The most common things you will need are available: maven, gradle, git, groovy, all there. If s.th. is missing the support reacts quiet fast. Check the so called formulas if your required package is available.

Next, I tried to uninstall a package. Works as it should.

So far I’m happy and recommend it.

Tagged with:
Jun 11

Spent to much time but finally Inkscape works! You need to set the python version to 2.5:

defaults write /Library/Preferences/com.apple.versioner.python Version 2.5

See Inkscape forum for the complete thread.

Tagged with:
preload preload preload