Skip to content

Instantly share code, notes, and snippets.

#define FOR(i, b, e) for (typeof(e) i = (b); i < (e); ++i)
// for arrays
#define arrsz(a) ( sizeof(a) / sizeof(a[0]) )
#define darr(a) if (opt_debug) { copy( (a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ") ); cerr << endl; }
#define darr2(a) if (opt_debug) { FOR(__i, 0, (arrsz(a))){ darr( (a)[__i] ); } }
// for vectors
#define ALL(a) (a).begin(), (a).end()
#define dvec(v) if (opt_debug) { copy( ALL(v), ostream_iterator<int>(cerr, " ") ); cerr << endl; }
@Genki-S
Genki-S / main.rb
Last active August 29, 2015 14:08
coderunner 2014 qualification A
require 'open-uri'
TOKEN = "CDC4L3EA1BEVS662EP0MALI7UVC8L357"
class GA
GENES_LIMIT = 100
SELECTION_COUNT = 50
CROSSOVER_COUNT = 45
RANDOM_COUNT = 5
MUTATION_PERCENTAGE = 30
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 (right|left)"
exit 1
fi
current_win=$(tmux display-message -p '#I')
total_win_count=$(tmux display-message -p '#{session_windows}')
# if not in tmux session
if [ -z $TMUX ]; then
# jump into new session
tmux new-session
# exit when coming back from the tmux session
exit
fi
inoremap <expr> = smartchr#loop(' = ', ' == ', ' => ')
inoremap <silent> <buffer> <Leader><C-l> <Space>>><Space>
inoremap <silent> <buffer> <Leader><C-h> <Space><<<Space>
inoremap <silent> <buffer> <Leader><C-l> <Space>=><Space>
#!/bin/bash
set -e
function run_test {
targets=$(git diff --cached --name-only)
orig_files=()
for file in $targets; do
if [ $(echo $file | grep '.*\.orig$') ]; then
orig_files=("${orig_files[@]}" "$file")
autocmd BufNew * NeoSnippetSource /path/to/snippet/file
snippet r;
abbr Repository
options word
Repository
snippet r_;
abbr repository
options word
repository
snippet r:b;
abbr Repository::Bazaar