Skip to content

Instantly share code, notes, and snippets.

View zbyhoo's full-sized avatar

zbyhoo zbyhoo

  • Gamesture
  • Poland, Katowice
View GitHub Profile
@zbyhoo
zbyhoo / ps1_for_git.sh
Created January 4, 2011 09:08
PS1 containing information about current git branch.
PS1='\[\e[32m\]\w `git branch 2>/dev/null | grep -e '\''^*'\'' | sed -E '\''s/^\* (.+)$/(\1) /'\''`\n\$\[\e[0m\] '
@zbyhoo
zbyhoo / gcc2msvc.rb
Created January 10, 2011 16:08
Ruby script converting gcc output to msvc compatible one (go to line when error appears).
result = 0
while (line = gets)
index = line.index(/\.[ch]pp\:[0-9]/)
if (index == nil)
puts line
else
path_end = line.index(":", index)
linenr_end = line.index(":", path_end + 1)
@zbyhoo
zbyhoo / userdu.sh
Created January 26, 2011 10:56
Calculates total file space usage for each user in specified directory and subdirectories.
#!/bin/bash
function usage()
{
echo "Usage: `basename $0` [dir]"
echo " dir - directory to check (default is current directory)"
}
if [ "$1" == "-h" ]
then
@zbyhoo
zbyhoo / gcc2xml.pl
Created February 3, 2011 11:04
Script converting gcc output (warning and errors) to "some kind" of xml format.
#!/usr/bin/perl -w
use strict;
my $tag_main = "gcc_issues";
my $tag_total = "total";
my $tag_issue = "issue";
my $tag_count = "count";
my $tag_file = "file";
my $tag_line = "line";
@zbyhoo
zbyhoo / gist:1077733
Created July 12, 2011 10:17
XCode "Run Script" phase for printing TODOs and FIXMEs as warnings
KEYWORDS="TODO.*:|FIXME.*:|\?\?\?.*:|\!\!\!.*:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.mm" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
@zbyhoo
zbyhoo / gist:1188407
Created September 2, 2011 11:24
git: printing pretty one-line commits info with colors
git log --pretty=format:'%C(yellow)%h%Cred%d%Creset - %C(cyan)%an %Creset: %s %Cgreen(%cr)'
@zbyhoo
zbyhoo / gist:1266907
Created October 6, 2011 09:06
Pretty nice way to find UIViewController of UIView using category
@interface UIView (FindUIViewController)
- (UIViewController *) firstAvailableUIViewController;
- (id) traverseResponderChainForUIViewController;
@end
@implementation UIView (FindUIViewController)
- (UIViewController *) firstAvailableUIViewController
@zbyhoo
zbyhoo / gist:1372918
Created November 17, 2011 11:06
Removing all files that will not be source controlled from Library dir of Unity3D project
rm $(ls * | grep -v 'EditorBuildSettings.asset\|InputManager.asset\|ProjectSettings.asset\|QualitySettings.asset\|TagManager.asset\|TimeManager.asset\|AudioManager.asset\|DynamicsManager.asset\|NetworkManager.asset')
@zbyhoo
zbyhoo / gist:1450703
Created December 9, 2011 08:11
print sorted by size list of all files/folders in current directory in human readable form
du -s * | sort -nr | cut -f2- | xargs -I {} du -hs {}
@zbyhoo
zbyhoo / build_tesseract.sh
Created March 19, 2012 20:50
Downloads and compiles Tesseract OCR library for iOS
#!/bin/sh
# build.sh
GLOBAL_OUTDIR="`pwd`/dependencies"
LOCAL_OUTDIR="./outdir"
LEPTON_LIB="`pwd`/leptonica-1.68"
TESSERACT_LIB="`pwd`/tesseract-3.01"
IOS_BASE_SDK="5.1"
IOS_DEPLOY_TGT="4.3"