Skip to content

Instantly share code, notes, and snippets.

View mattn's full-sized avatar
🍛
I love curry 🍛

mattn mattn

🍛
I love curry 🍛
View GitHub Profile
@gnue
gnue / Dockerfile
Last active August 29, 2015 13:56
goreman を使って docker で複数プロセスを起動する
# sshd+nginx
#
# VERSION 0.0.1
FROM ubuntu
RUN apt-get update
# sshd
RUN apt-get install -y openssh-server
"loadavg5",
"memory.total",
"memory.free",
"memory.buffers",
"memory.cached",
"memory.swap_cached",
"memory.active",
"memory.inactive",
"memory.swap_total",
"memory.swap_free",
#!/usr/bin/env perl
# crontab -l | ./cron2cal > ~/tmp/cron.csv
use utf8;
use strict;
use warnings;
use Encode;
use DateTime;
#!/bin/sh
PATH=$HOME/homebrew/bin:$PATH
if [ -n "$TMUX" ]; then
echo "already in tmux session!!"
exit
fi
HELPER_RUNNING=$(ps aux | grep "[u]im-tmux-helper" 2>/dev/null)
@hail2u
hail2u / escape-url.patch
Created June 19, 2014 01:37
Escape `$url` before processing `head.flavour`
diff --git blosxom.cgi blosxom.cgi
index 8ffe7ae..0fb7041 100755
--- blosxom.cgi
+++ blosxom.cgi
@@ -764,6 +764,30 @@ sub generate {
}
}
+ # Save unescaped versions and allow them to be used in flavour
+ # templates.
anonymous
anonymous / gist:19bbb1eadf4f1c6bd761
Created June 26, 2014 07:52
pecoで履歴からマッチするキーワードをその場に補完
function in_place_history_keyword_completion() {
pos=CURSOR # 現在のカーソル位置を取得
selected=$(history -10000 | cut -d' ' -f3- | tr '|' ' ' | tr ' ' '\n' | sort -u | peco) # 選択した結果
BUFFER="${BUFFER[1,$pos]}${selected}${BUFFER[$pos,-1]}"
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N in_place_history_keyword_completion
bindkey '^R' in_place_history_keyword_completion
@kazuho
kazuho / gist:1f64c62e5f059954ead2
Created October 2, 2014 01:06
converting an IPv4 address to string would become x7.6 faster if the format string of sprintf was parsed at compile-time
$ cat ipv4addr.c
#include <stdio.h>
struct ct_printf_t {
char *str;
size_t off;
};
struct ct_printf_t ct_printf_init(char *str)
{
@mattn
mattn / perlvalidate.vim
Created March 30, 2010 08:37
perlvalidate.vim
function! s:package_name()
let mx = '^\s*package\s\+\([^ ;]\+\)'
for line in getline(1, 5)
if line =~ mx
return substitute(matchstr(line, mx), mx, '\1', '')
endif
endfor
return ""
endfunction
package MyFinger;
use Filter::Simple;
FILTER_ONLY
code => sub {
s/(\$[a-zA-Z][a-zA-Z0-9]*\s*)☞/\1->/msxg;
s/([a-zA-Z][a-zA-Z0-9]*\s*)☛/\1=>/msxg;
};
1;
@mattn
mattn / closure-counter.c
Created May 13, 2010 05:02
countup closure in C
// gcc -o closure-counter closure-counter.c -lffi
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ffi.h>
int
main(int argc, char **argv) {
ffi_cif cif;