Skip to content

Instantly share code, notes, and snippets.

Frédéric Menou ptitfred

  • FretLink
  • Paris, France
Block or report user

Report or block ptitfred

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ptitfred
ptitfred / .vimrc
Created Aug 29, 2012
Pretty format your JSON in VIM
View .vimrc
function! PrettyJSON()
silent %!python -mjson.tool | sed -e 's/\s*$//'
endfunction
command! Fjson call PrettyJSON()
@ptitfred
ptitfred / .vimrc
Created Aug 20, 2012
Ruby VIM configuration
View .vimrc
" 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 Aug 20, 2012
Pretty format your XML in VIM
View .vimrc
function! PrettyXML()
silent %!xmllint --format --encode UTF-8 --recover - 2>/dev/null
endfunction
command! Fxml call PrettyXML()
"-- format xml when trigger Ctrl-Shift-F (only if filetype=xml)
autocmd FileType xml map <C-S-F> :Fxml<CR>
@ptitfred
ptitfred / relative-load.sh
Created May 22, 2012
Expresses the load relative to processors count (in percents)
View relative-load.sh
/usr/bin/printf %0.f%%\\n $(echo $(cat /proc/loadavg | cut -d" " -f1) / $(grep -c processor /proc/cpuinfo) "* 100" | bc -l)
@ptitfred
ptitfred / git-rm-others.sh
Created Apr 12, 2012
Remove new files, preserve ignored files
View git-rm-others.sh
#!/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 / git-incr-build.sh
Created Mar 23, 2012
Incremental Maven Build for Modules based Maven project
View git-incr-build.sh
#!/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 / Display.java
Created Feb 21, 2012
Draw some BufferedImage in a 'GridLayout'ed JPanel
View Display.java
public class Display extends JPanel {
public Display(BufferedImage[] images) {
super(new GridLayout(0, 3));
for (BufferedImage im : images) {
add(new Drawer(im));
}
}
}
@ptitfred
ptitfred / wait-tcp.sh
Created Feb 9, 2012
Wait for a TCP port to be open
View wait-tcp.sh
#!/bin/bash
function help {
echo "Usage: wait-for port [timeout]"
echo " port is a TCP port number, or the service name (for instance http, ssh)"
echo " timeout is expressed in seconds"
echo " optional (defaulted to 30)"
echo " if <= 0, no timeout"
exit 1
}
@ptitfred
ptitfred / gist:1396436
Created Nov 26, 2011
Git current-branch
View gist:1396436
git rev-parse --symbolic-full-name --abbrev-ref HEAD
View find-cvs-files.sh
#!/bin/bash
find . -path "*/CVS/Entries*"
You can’t perform that action at this time.