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 / 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"
@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 / 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: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: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: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 / solve_pbxproj_merge_conflict.sh
Created May 5, 2011 09:00
Solving pbxproj files git merge conflicts when two users add files at the same time.
#!/bin/sh
projectfile=`find -d . -name 'project.pbxproj'`
projectdir=`echo *.xcodeproj`
projectfile="${projectdir}/project.pbxproj"
tempfile="${projectdir}/project.pbxproj.out"
savefile="${projectdir}/project.pbxproj.mergesave"
cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile
cp $projectfile $savefile
@zbyhoo
zbyhoo / count_gcc_warnings.sh
Created April 27, 2011 12:09
Sorts and counts all warnings from gcc compilation output
#!/bin/bash
if [ "$#" != "1" ]
then
echo wrong number of arguments
echo Usage: $0 \<filename\>
echo filename - file with build output
exit 1
else
cat $1 | grep "warning:" | sort | uniq -c | sort -nr | awk '{print $0}{total+=1}END{print "Total number of warnings:\n"total}'
@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:805695
Created February 1, 2011 10:45
vim function to execute shell command and show output in vim window
function! s:ExecuteInShell(command)
let command = join(map(split(a:command), 'expand(v:val)'))
let winnr = bufwinnr('^' . command . '$')
silent! execute winnr < 0 ? 'botright new ' . fnameescape(command) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap number
echo 'Execute ' . command . '...'
silent! execute 'silent %!'. command
silent! execute 'resize ' . line('$')
silent! redraw
silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''