Skip to content

Instantly share code, notes, and snippets.

@sebk
sebk / nginx
Created August 10, 2011 17:09
nginx init script
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
@sebk
sebk / gist:1393183
Created November 25, 2011 10:03
change TTY resoulution for grub 2
Source: http://seraphyn.teiko.org/archives/996-Debian-Squeeze-TTY-Aufloesung-Schriftgroesse.html
available settings:
hwinfo --framebuffer
edit /etc/default/grub
set GRUB_GFXMODE
e.g. GRUB_GFXMODE=1024x768
edit /etc/grub.d/00_header from
@sebk
sebk / vimrc
Created November 25, 2011 10:05
vimrc
filetype on "autodetect filetype
syntax on
filetype plugin indent on
set title
set nocompatible
set tabstop=2
set backspace=2
set ai
set si
@sebk
sebk / git
Created February 6, 2012 10:15
git
git config --global color.diff always
git log --pretty=format:'%h : "%s" by %an, %ar' --date-order --graph --stat
@sebk
sebk / panGesture.m
Created May 4, 2012 07:14
Move component with UIPanGestureRecognizer
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"BUTTON" forState:UIControlStateNormal];
[button setFrame:CGRectMake(50, 50, 150, 150)];
[self.view addSubview:button];
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(invokePanGesture:)];
@sebk
sebk / gist:3691003
Created September 10, 2012 13:43
UIPanGestureRecognizer - determine direction
CGPoint velocity = [gestureRecognizer velocityInView:currentView];
if (velocity.x * lastGestureVelocity.x + velocity.y * lastGestureVelocity.y > 0) {
//NSLog(@"gesture went in same direction");
}
else {
NSLog(@"gesture went in opposite direction");
}
lastGestureVelocity = velocity;
@sebk
sebk / bashprombt
Created September 28, 2012 11:31
better bash prompt with git branch
#source: http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
@sebk
sebk / NSString+Zeros
Created November 6, 2012 20:46
NSString removeLeadingZeros
@interface NSString (Zeros)
-(NSString*)removeLeadingZeros;
-(NSString*)addLeadingZerosTillLength:(int)length;
@end
@sebk
sebk / stringIsNumeric
Created March 4, 2013 19:08
Check if NSString is numeric
-(BOOL)isNumeric:(NSString*)string {
NSLocale *l_de = [[NSLocale alloc] initWithLocaleIdentifier: @"de_DE"];
NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
[f setLocale: l_de];
[f setAllowsFloats: YES];
if ([f numberFromString:string]) {
return YES;
}
return NO;
@sebk
sebk / NSError+LocalizedError
Last active December 19, 2015 02:38
NSError category to create a localized NSError instance. Created by Jan Rose.
#import <Foundation/Foundation.h>
@interface NSError(LocalizedError)
/**
Utility method to create a localized NSError with the given error-domain, error-code and description text.
*/
+ (NSError*)localizedErrorWithDomain:(NSString*)domain code:(NSInteger)code andDescription:(NSString*)description;