This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ls -l $1 | awk '{print $5,$10}'| | |
while read n f | |
do | |
if [ "$f" != "" ]; then | |
xxd -p "$2/$f" | fold -w2 | head -n $n | diff -u "$3/$f" - | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//usage: node main.js "14 + 34 * 22 + (3 + 4) * 5" | |
var util = require('util'); var calc = calc || {}; | |
calc.Parser = function() { | |
this.tokens = []; this.parens = []; this.pos = 0; | |
}; | |
calc.Parser.prototype.next = function() { | |
var offset = this.parens[this.parens.length - 1]; | |
if(offset + this.pos < this.tokens.length) return this.tokens[offset + this.pos++]; | |
else return null; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#usage: ruby main.rb | |
class Parser | |
def initialize | |
@stack = [] | |
end | |
def parse(line) | |
scanner = Scanner.new(line) | |
while (token = scanner.next) do | |
add_token(token) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Guardのマッチング規則を定義 | |
guard :minitest, spring: "bin/rails test", all_on_start: false do | |
watch(%r{^test/(.*)/?(.*)_test\.rb$}) | |
watch('test/test_helper.rb') { 'test' } | |
watch('config/routes.rb') { integration_tests } | |
watch(%r{^app/models/(.*?)\.rb$}) do |matches| | |
"test/models/#{matches[1]}_test.rb" | |
end | |
watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches| | |
resource_tests(matches[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Matrix = [[Int]] | |
dropAt :: Int -> [a] -> [a] | |
dropAt i xs = [x| (x, j) <- zip xs [0..], i /= j] | |
cofactor :: Int -> Int -> Matrix -> Matrix | |
cofactor i j m = [dropAt j v| (v, k) <- zip m [0..], i /= k] | |
det :: Matrix -> Int | |
type Matrix = [[Int]] | |
dropAt :: Int -> [a] -> [a] | |
dropAt i xs = as ++ bs where (as, _ :bs) = splitAt i xs | |
cofactor :: Int -> Int -> Matrix -> Matrix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> import Data.Char | |
> instance Functor Parser where | |
> -- map f p = MkP g | |
> fmap f p = MkP g | |
> where g s = [(f x, s') | (x,s') <- papply p s] | |
> alphanum :: Parser Char | |
> -- alphanum = sat isAlphaum | |
> alphanum = sat isAlphaNum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> module MyParseLib | |
> (Parser, mplus, orelse, item, many, some, manywith, somewith, | |
> sat, char, string, digit, lower, upper, letter, alphanum, | |
> ident, space, token, symbol, applyParser) where | |
> import Data.Char | |
> import Control.Monad | |
> newtype Parser a = MkP (String -> [(a,String)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> import System.Console.ANSI | |
> | |
> cls :: IO () | |
> -- cls = putStr "\ESC[2J" | |
> cls = clearScreen | |
> | |
> type Pos = (Int,Int) | |
> | |
> goto :: Pos -> IO () | |
> --goto (x,y) = putStr ("\ESC[" ++ show y ++ ";" ++ show x ++ "H") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval :: String -> Int | |
eval xs = case (parse expr xs) of | |
Just (n, "") -> n | |
Just (_, out) -> error ("unused input " ++ out) | |
failure -> error "invalid input" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test/fixtures/bodies.yml | |
one: | |
id: 1 | |
file_entry_id: 1 | |
description: desc1 | |
two: | |
id: 2 | |
file_entry_id: 3 | |
description: description2 |
NewerOlder