This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package web | |
import com.sun.net.httpserver._ | |
import java.net.InetSocketAddress | |
import java.net.Inet4Address | |
case class Answer(code: Int, body: String) | |
class MyServer(port: Int) { | |
type Handler = String => Answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "active_support/time" | |
# in 3 days | |
Time.fluent("+3d") | |
# Tomorrow at 10 am | |
Time.fluent("+1d @10h") | |
class Time | |
def self.fluent(at) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThreadLocal | |
def [](key) | |
Thread.current[key] | |
end | |
def []=(key, value) | |
Thread.current[key] = value | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! PrettyJSON() | |
silent %!python -mjson.tool | sed -e 's/\s*$//' | |
endfunction | |
command! Fjson call PrettyJSON() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/printf %0.f%%\\n $(echo $(cat /proc/loadavg | cut -d" " -f1) / $(grep -c processor /proc/cpuinfo) "* 100" | bc -l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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=$* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Display extends JPanel { | |
public Display(BufferedImage[] images) { | |
super(new GridLayout(0, 3)); | |
for (BufferedImage im : images) { | |
add(new Drawer(im)); | |
} | |
} | |
} |