Skip to content

Instantly share code, notes, and snippets.

@uasi
uasi / file0.txt
Last active August 29, 2015 14:19
ブランチの最終更新日時を一覧にする git branch-activity 書いた ref: http://qiita.com/uasi/items/430f9403ac9b437c0499
usage: git branch-activity [-r | -a] [-R] [--no-color]
@uasi
uasi / macro_expansion_steps.exs
Last active August 29, 2015 14:22
Elixir で Plug.Builder 相当の DSL を再実装してマクロの展開順を追ってみた
### start from here ###
defmodule MyApp do
use MyPlugBuilder
plug :hello
plug :world, good: :morning
end
### expand `use MyPluginBuilder` macro ↓ ###
import urllib2
# Add basic authentication handler to urllib2
mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
mgr.add_password(None, 'example.com', 'username', 'password')
auth_handler = urllib2.HTTPBasicAuthHandler(mgr)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
#import <Cocoa/Cocoa.h>
int main() {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURLProtectionSpace *space = [[NSURLProtectionSpace alloc]
initWithHost:@"www.tumblr.com"
port:0
protocol:@"http"
realm:nil
grammar MyInteger {
token TOP {
| 0b(<[01]>+) {*} #= binary
| \d+ {*} #= decimal
}
}
class Twice {
multi method TOP($/, $tag) {
my $text = ~$/;
class A {
has ($.foo, $.bar, $.baz, $.qux, $.blahblahblah);
# Is there a way to define a constructor that takes positional arguments
# and initializes attributes of the same name
# (I assume the definition looks like this)
#
method NEW ($!foo, $!bar, $!baz, $!qux, $!blahblahblah) { }
# ... instead of repeating variables to bless?
use v6;
multi sub grep ($cond, @array, :@between where { .elems == 2 }) {
my $level = 0;
gather for @array {
$level-- if $level && $_ ~~ @between[1];
take $_ if $level && $_ ~~ $cond;
$level++ if $_ ~~ @between[0];
}
}
" A .vimrc snippet that allows you to move around windows beyond tabs
nnoremap <Tab> :call NextWindowOrTab()<CR>:echo<CR>
nnoremap <S-Tab> :call PreviousWindowOrTab()<CR>:echo<CR>
function! NextWindowOrTab()
if winnr() < winnr("$")
execute "normal \<C-W>\<C-W>"
else
tabnext
@uasi
uasi / gist:376530
Created April 23, 2010 13:25 — forked from tyru/gist:376501
もしあなたが新しいプログラム、例えばテキストエディタを作るとしたら、どの言語で作る?
Suppose you want to write a new program, something like a text editor. What language would you write it in?
* できるだけ速く。なのでインタプリタ言語はダメ。
* It has to be as fast as possible, so interpreted languages are out.
* メモリ管理なんてしたくない。だからCはダメ。
* You don't want to micro manage memory, so C is out.
* プログラマに知識((FIXME))を求めたくない。だからC++はダメ。
* You don't want to require programmers to have a degree, so C++ is out.
* できるだけ起動を速く、ランタイムには依存させたくない。だからJavaはダメ。
@uasi
uasi / fastpack.sh
Created April 30, 2010 19:42
fastpack - a simple App::FatPacker helper
#!/bin/sh
#
# fastpack - a simple App::FatPacker helper
#
if [ -z "$1" ]; then
echo "usage: fastpack script.pl > script.packed.pl"
exit 0
fi