Skip to content

Instantly share code, notes, and snippets.

View kakkun61's full-sized avatar
🚂
Choo-choo

Kazuki Okamoto kakkun61

🚂
Choo-choo
View GitHub Profile
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 14:46
Java Advent Calendar 2011 code 5
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 15:07
Java Advent Calendar 2011 code 6
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 16:23
Java Advent Calendar 2011 code 7
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / Parser.jj
Created December 22, 2011 18:26
Java Advent Calendar 2011 code 8
PARSER_BEGIN (Parser)
public class Parser {
}
PARSER_END (Parser)
SKIP: {
" "
}
TOKEN: {
<INTEGER: (["0"-"9"])+>
@kakkun61
kakkun61 / gist:2400393
Created April 16, 2012 18:05
The Little Schemer (ver. Haskell), Scheme 手習い (Haskell 版)
-- Scheme 手習い 5章 p.83
-- The Little Schemer Section 5
rember_star :: (Eq a, Eq b) => a -> [b] -> [b]
rember_star _ [] = []
rember_star e (x:xs) =
case x of
ys@(_:_) -> (rember_star e ys) : (rember_star e xs)
z | e == z -> rember_star e xs
_ -> x : rember_star e xs
@kakkun61
kakkun61 / gist:2577299
Created May 2, 2012 15:07
AtCoder Regular Contest #2 Task A
main = do
cs <- getContents
putStrLn $ leapYear $ read cs
where
leapYear :: Int -> String
leapYear year | year `mod` 400 == 0 = "YES"
| year `mod` 100 == 0 = "NO"
| year `mod` 4 == 0 = "YES"
| otherwise = "NO"
@kakkun61
kakkun61 / gist:2577440
Created May 2, 2012 15:24
AtCoder Regular Contest #2 Task B (Improved)
main = readLn >>= putStrLn . leapYear
where
leapYear :: Int -> String
leapYear year | year `mod` 400 == 0 = "YES"
| year `mod` 100 == 0 = "NO"
| year `mod` 4 == 0 = "YES"
| otherwise = "NO"
@kakkun61
kakkun61 / .Xmodmap
Created May 27, 2012 17:24
無変換→Shift_L 変換→Shift_R とする xmodmap 用設定ファイル
! ~/.Xmodmap
keysym Muhenkan = Shift_L
add shift = Shift_L
keysym Henkan = Shift_R
add shift = Shift_R
@kakkun61
kakkun61 / functioncomposion.cpp
Created June 26, 2012 05:31
[solved] Why is std::tr1::bad_function_call thrown?
#include<iostream>
#include<functional>
#include<cmath>
using namespace std;
using namespace std::tr1;
template<typename Param, typename Middle, typename Result>
function<Result(Param)> compose(const function<Result(Middle)>& f, const function<Middle(Param)>& g) {
return [f, g](Param x){return f(g(x));};
@kakkun61
kakkun61 / gist:3009518
Created June 28, 2012 06:35
git merge master and ...
#! /bin/sh
b=`git branch | grep '*' | awk '{print $2}'`
git checkout master && git merge $b && git checkout $b