Skip to content

Instantly share code, notes, and snippets.

@pulcheri
pulcheri / git_trunc.sh
Created September 6, 2011 03:29
truncate git history
#!/bin/bash
git checkout --orphan temp $1
git commit -m "Truncated history"
git rebase --onto temp $1 master
git branch -D temp
@pulcheri
pulcheri / gist:1554972
Last active September 29, 2015 05:47
keyboard layout gb<->ru
sudo setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll gb,ru
# http://crunchbang.org/forums/viewtopic.php?id=6926
@pulcheri
pulcheri / Iphone Icon.png Bash Script
Created January 20, 2012 14:46 — forked from jessedc/iOS Icon.png bash script
A simple bash script using OSX command line tool sips to resample a 512x512px image
#!/bin/bash
f=$(pwd)
sips --resampleWidth 512 "${f}/${1}" --out "${f}/iTunesArtwork"
sips --resampleWidth 57 "${f}/${1}" --out "${f}/Icon.png"
sips --resampleWidth 114 "${f}/${1}" --out "${f}/[email protected]"
sips --resampleWidth 29 "${f}/${1}" --out "${f}/Icon-Small.png"
sips --resampleWidth 58 "${f}/${1}" --out "${f}/[email protected]"
sips --resampleWidth 50 "${f}/${1}" --out "${f}/Icon-Small-50.png"
sips --resampleWidth 72 "${f}/${1}" --out "${f}/Icon-72.png"
@pulcheri
pulcheri / gist:2498951
Last active April 9, 2024 16:22
Perl one-liner strings replace
first=$1
second=$2

# Replace
find -name *.cpp -or -name *.h | xargs grep "$first" -l  | xargs perl -pi -e "s/$first/$second/g"

a=getDefaultIncludes; b=get_include_dirs_def; find -name "*.py" -or -name "SC*" | xargs grep "$a" -l  | xargs perl -pi -e "s/$a/$b/g"

a=abc; b=def; find -name "*.cpp" -or -name "*.h" | xargs grep "$a" -l | xargs perl -pi -e "s/$a/$b/g"
@pulcheri
pulcheri / caf_to_wav.sh
Created July 12, 2012 01:55
Convert Core Audio Files to Wav on Linux
pacpl --to wav *.caf
@pulcheri
pulcheri / xmodmap-esc.sh
Last active October 12, 2015 10:27
map Esc to CAPS LOCK
# Run 'xmodmap ~/.xmodmap-esc'
clear Lock
keycode 0x42 = Escape
# .. or:
#xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
#in /etc/rc.local
# https://wiki.archlinux.org/index.php/Xmodmap

Remove ^M characters at end of lines in vi

UNIX treats the end of line differently than other operating systems. Sometimes when editing files in both Windows and UNIX environments, a CTRL-M character is visibly displayed at the end of each line as ^M in vi.

To remove the ^M characters at the end of all lines in vi, use:

:%s/^V^M//g
@pulcheri
pulcheri / gist:4559121
Last active December 11, 2015 06:28
git create/push/delete branch

How do I revert one file to the last commit in git?

git checkout -- filename You can do it without the -- (as suggested by nimrodm), but if the filename looks like a branch or tag (or other revision identifier), it may get confused, so using -- is best.

You can also check out a particular version of a file:

git checkout v1.2.3 -- filename # tag v1.2.3

git checkout stable -- filename # stable branch

#!/bin/sh
USAGE="Usage: $0 processName"
if [ $# -ne 1 ]; then
echo $USAGE
exit 1
fi
#!/bin/bash
#script extraido de: http://paulocassiano.wordpress.com/2008/08/29/deixando-o-gedit-com-a-cara-do-textmate/
#tip for better "resolution" here: http://blog.siverti.com.br/2008/05/22/fonte-monaco-no-ubuntugedit/
cd /usr/share/fonts/truetype/
#TODO: put validation if folder already exists
sudo mkdir ttf-monaco