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 / gitp2svnp.rb
Last active December 23, 2016 10:37
Simple script converting git patch file into tortoise merge compatible format. Usage: gitp2svnp.rb <git_patch_file>
#!/usr/bin/ruby
if ARGV.length != 1
puts "usage: git2svn <file_name>"
puts " file_name - git patch file name"
exit
end
separator = "\n===================================================================\n"
new_file = false
@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 / 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'''
@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 / 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 / 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 / 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)'