Skip to content

Instantly share code, notes, and snippets.

#!/bin/zsh -x
# ファイルに変更があったらブラウザを自動リロードする。
# ブラウザ側に拡張などを入れる必要なし。
# 要: inotifywait, xdotool
# 参考: http://stackoverflow.com/questions/4680109/how-to-reload-refresh-a-web-page-without-leaving-my-web-development-ide/10739606#10739606
# 参考: http://unix.stackexchange.com/questions/37258/refresh-reload-active-browser-tab-from-command-line/42933#42933
RELOAD_KEYS="CTRL+R"
# RELOAD_KEYS="SHIFT+CTRL+R"
@Dubhead
Dubhead / sape.vim
Created June 5, 2012 05:58
a Vim script to insert spaces around punctuations and equals automatically
"""" Spaces Around Punctuations and Equals """"
let s:sape_no_space_before_equal = split('-!~=+*/&|<>%', '\zs')
let s:sape_followed_by_space = split(',;=', '\zs')
function s:sape(c)
if a:c == ' ' || a:c == '\t' || col(".") == 1
return a:c
endif
let prevchar = getline(".")[col(".") - 2]
@Dubhead
Dubhead / gist:2766800
Created May 22, 2012 05:19
FizzBuzz in Rust
fn main(_args: [str]) {
uint::range(1u, 21u) {|i|
let msg = alt (i % 3u, i % 5u) {
(0u, 0u) { "fizzbuzz" }
(0u, _) { "fizz" }
(_, 0u) { "buzz" }
(_, _) { #fmt("%u", i) }
};
io::println(msg);
};
@Dubhead
Dubhead / gist:2049097
Created March 16, 2012 08:21
matrix product in Pure
% pure -i
Pure 0.52 (x86_64-unknown-linux-gnu) Copyright (c) 2008-2012 by Albert Graef
(Type 'help' for help, 'help copying' for license information.)
Loaded prelude from /usr/local/lib/pure/prelude.pure.
> sum = foldl (+) 0;
> dot x::matrix y::matrix = sum $ zipwith (*) (rowvector x) (rowvector y);
> x::matrix * y::matrix = {dot u v | u = rows x; v = cols y};
> a = {1, 2, 3; 1, 2, 3; 1, 2, 3};
> b = {1, 2, 3, 4; 1, 2, 3, 4; 1, 2, 3, 4};
@Dubhead
Dubhead / goindent.vim
Created October 21, 2011 08:09
Go to the next (or previous) line with the same indentation to the current line (or less than), ignoring empty lines.
" GoUp
" include guard
"if exists("g:loaded_GoUp") && g:loaded_GoUp
" finish
"endif
"let g:loaded_GoUp = 1
" Go to the next (or previous) line with the same indentation to the
" current line (or less than), ignoring empty lines.
@Dubhead
Dubhead / stylizeline.vim
Created October 20, 2011 07:50
StylizeLine, take 2
" StylizeLine
" include guard
"if exists("g:loaded_StylizeLine") && g:loaded_StylizeLine
" finish
"endif
"let g:loaded_StylizeLine = 1
function! StylizeLine(modifyBuffer, lineOffset)
let l:line = getline(line(".") + a:lineOffset)
@Dubhead
Dubhead / stylizeline.vim
Created October 18, 2011 03:59
StylizeLine
" smartchr 的な動作は改行時にまとめてやれば済むでしょ、と思って簡単に作ってみた。
" どうも実用的にできなかったのでgistに晒して終わりにする。
function! StylizeLine(modifyBuffer)
let l:line = getline(".")
" Skip if comment line or preprocessor directive.
if (match(l:line, "^\\s*#") != -1) || (match(l:line, "^\\s*\/\/") != -1)
return l:line
endif
@Dubhead
Dubhead / echo.cc
Created September 20, 2011 07:09
echo in C++11
// echo in C++11
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
int main(int argc, char* argv[])
{
std::vector<std::string> strings(argv + 1, argv + argc);
#include <iostream>
class Foo {
public:
Foo() {}
void say() {
std::cout << data_ << std::endl;
}
@Dubhead
Dubhead / gist:1058070
Created July 1, 2011 08:01
Emacsで、C-aやC-eの連打を1行スクロールにしてみた
(global-set-key (kbd "C-a")
'(lambda ()
(interactive)
(if (= (point) (line-beginning-position))
(scroll-down 1))
(beginning-of-line)))
(global-set-key (kbd "C-e")
'(lambda ()
(interactive)