Skip to content

Instantly share code, notes, and snippets.

View ptitfred's full-sized avatar

Frédéric Menou ptitfred

View GitHub Profile
@ptitfred
ptitfred / gist:1241877
Created September 26, 2011 08:46
Clean whitespace problems in eclipse
Clean whitespace "problems" :
Find: [\t ]+$
Replace with: (nothing)
with Regex mode
@ptitfred
ptitfred / find-cvs-files.sh
Created October 18, 2011 15:08
Find CVS files
#!/bin/bash
find . -path "*/CVS/Entries*"
@ptitfred
ptitfred / gist:1396436
Created November 26, 2011 22:48
Git current-branch
git rev-parse --symbolic-full-name --abbrev-ref HEAD
@ptitfred
ptitfred / Display.java
Created February 21, 2012 15:23
Draw some BufferedImage in a 'GridLayout'ed JPanel
public class Display extends JPanel {
public Display(BufferedImage[] images) {
super(new GridLayout(0, 3));
for (BufferedImage im : images) {
add(new Drawer(im));
}
}
}
@ptitfred
ptitfred / git-incr-build.sh
Created March 23, 2012 10:48
Incremental Maven Build for Modules based Maven project
#!/bin/bash -e
# NB: the file is named git-incr-build.sh to let Gist colorize, but you should name it git-incr-build
# Put this script in your PATH and call it this way:
# git incr-build clean install
# Can be combined with git pull --rebase and git push to make an "fast & safe push" script
function branchName {
git rev-parse --symbolic-full-name --abbrev-ref $1
}
@ptitfred
ptitfred / git-rm-others.sh
Created April 12, 2012 15:05
Remove new files, preserve ignored files
#!/bin/bash
# This can be used this way : git rm-others <rm-options>
# It will remove files with the status "?" and preserve files ignored.
# It won't remove empty directories unlike git clean -fdx
# This file should be renamed to git-rm-others and appended to the PATH
# The file is named git-rm-others.sh to enable gist syntax colorization
RM_OPTIONS=$*
@ptitfred
ptitfred / relative-load.sh
Created May 22, 2012 12:23
Expresses the load relative to processors count (in percents)
/usr/bin/printf %0.f%%\\n $(echo $(cat /proc/loadavg | cut -d" " -f1) / $(grep -c processor /proc/cpuinfo) "* 100" | bc -l)
@ptitfred
ptitfred / .vimrc
Created August 20, 2012 11:40
Ruby VIM configuration
" F9 key will trigger syntax validation
autocmd FileType ruby map <F9> :w<CR>:!ruby -c %<CR>
" Edition configuration (tabs=2spaces & autoindent)
fun! SetupRuby()
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
endfun
@ptitfred
ptitfred / .vimrc
Created August 29, 2012 07:56
Pretty format your JSON in VIM
function! PrettyJSON()
silent %!python -mjson.tool | sed -e 's/\s*$//'
endfunction
command! Fjson call PrettyJSON()
@ptitfred
ptitfred / thread_local.rb
Created November 23, 2012 12:29
ThreadLocal en Ruby
class ThreadLocal
def [](key)
Thread.current[key]
end
def []=(key, value)
Thread.current[key] = value
end
end