Skip to content

Instantly share code, notes, and snippets.

View johnjohndoe's full-sized avatar

Tobias Preuss johnjohndoe

View GitHub Profile
@johnjohndoe
johnjohndoe / gist:723302
Created December 1, 2010 10:27
Colored bash prompt showing git branch (.bash_rc)
# Set git tab completion and PS1 integration
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
. /usr/local/git/contrib/completion/git-completion.bash
fi
GIT_PS1_SHOWDIRTYSTATE=true
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
@johnjohndoe
johnjohndoe / .gitignore
Created January 3, 2011 18:04
A git log alias with colors, date and owner.
# A git log alias.
# Shows the brief log describtion in one line.
# Adds colors, a relative date and the owner.
# File name: .gitconfig
[alias]
look = log --graph --pretty=format:'%Cred %h : %Creset%s %Cgreen(%cr) %C(blue)<%an>%C(yellow)%d %Creset' --date=relative
@johnjohndoe
johnjohndoe / gist:1007379
Created June 3, 2011 23:54
Java introspection for class name and function name
// Print name of the current function.
new Throwable().fillInStackTrace().getStackTrace()[0].getMethodName();
// Print simple class name.
getClass().getSimpleName();
// Print full class name.
getClass().getName();
@johnjohndoe
johnjohndoe / gist:1024839
Created June 14, 2011 13:01
Convert from NSRect to CGRect
// Convert from NSRect to CGRect.
NSRect baz = NSMakeRect(0, 0, 100, 100);
CGRect foo = *(CGRect*)&baz;
// Include this inline function in a header file.
NS_INLINE CGRect CGRectMakeFromNSRect(NSRect rect) {
return *(CGRect*)&rect;
}
// Doooooh! They already exist.. - I could not find 'em before.
@johnjohndoe
johnjohndoe / vimeo.com.ffpreset
Created December 15, 2011 01:18
FFmpeg settings for vimeo.com
// FFmpeg settings for vimeo.com
// =============================
// Trying to find the best settings for encoding videos as described here: http://vimeo.com/help/compression
//
// Input file: MTS
// Video: H264, 1920x1080, 50fps
// Audio: A52 Audio (aka AC3), Stereo, 48kHz, 256kbps
ffmpeg -i input.mts -vcodec libx264 -acodec aac -strict experimental -vpre hq -s hd720 -b 5000k -ab 320k -r 25 -g 25 -threads 0 output.mp4
@johnjohndoe
johnjohndoe / colorize-svn.sh
Created February 10, 2012 15:16
Colorize SVN
# Colorize SVN
# ------------
# Adds color to the output of commands like svn status and svn update.
# The original version of the script was posted by Ash_ on Stackoverflow
# Source: http://stackoverflow.com/questions/8786400/svn-add-colors-on-command-line-svn-with-awk-in-bash
function svn {
# Skip the color script when running an svn commit.
if [ "x$1" = "xci" ] || [ "x$1" = "xcommit" ] || [ "x$1" = "xadd" ]
then
command svn "$@";
@johnjohndoe
johnjohndoe / redmine-osx-installation.md
Created May 21, 2012 16:51
Redmine installation on MacOSX

Redmine installation on MacOSX

  • A summarized instruction tested on MacOSX 10.7.4 installing Ruby 1.9.3p194 and Rails 3.2.3.

Install brew

  • Follow the instructions on https://github.com/mxcl/homebrew
  • $ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

brew hints

@johnjohndoe
johnjohndoe / gist:3754453
Created September 20, 2012 07:36 — forked from gnunicorn/gist:3748738
Git for Beginners: Call for Coaches

The OpenTechSchool has set up and hosted a few tech workshops and meetups here in Berlin now. Aside from the monthly Beginners Meetup and hosting the Udacity Global Meetup we hosted workshops for program beginners in Python and Javascript on our own and on the premise of CampusParty.

One thing that was extraordinary popular on CampusParty was the Workshop on Git for beginners. And we decided to do it again, this time with a closer focus on version control as a major benefit in code sharing (by using git and github) for beginners - free of charge.

So if you are interested in

@johnjohndoe
johnjohndoe / Host.m
Created September 25, 2012 15:31
Objective-C: Conversion of NetService addresses into human readable IP addresses.
//
// Host.m
// Dependencies: NSString+HexValue - Source: http://forums.macrumors.com/showthread.php?t=977076
//
#import "Host.h"
#import "NSString+HexValue.h"
#pragma mark
@interface Host()
@johnjohndoe
johnjohndoe / pre-commit.sh
Created November 6, 2012 11:48
Git pre-commit hook to add a new line at the end of a file and remove trailing whitespaces
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Usage:
# Remove the .sh file extension when you put the script in your hooks folder!
#