Skip to content

Instantly share code, notes, and snippets.

View haruyama's full-sized avatar
🌴
On vacation

HARUYAMA Seigo haruyama

🌴
On vacation
View GitHub Profile
@haruyama
haruyama / gist:3b429ef86d3a74ece040
Created June 6, 2014 09:10
Unixuser\Slim\CsrfGuard
<?php
// Copyright (c) HARUYAMA Seigo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is furnished
// to do so, subject to the following conditions:
//
(find-assertions (query-syntax-process '(job ?x (computer programmer)))
(singleton-stream '()))
@haruyama
haruyama / gist:7869684
Created December 9, 2013 09:33
file dumper
import ceylon.file { File, Path, parsePath }
import ceylon.io { OpenFile, newOpenFile }
import ceylon.io.charset { utf8, Decoder }
import ceylon.io.buffer { ByteBuffer }
import java.util { ArrayList }
shared void cat(String filename) {
Path path = parsePath(filename);
OpenFile file = newOpenFile(path.resource);
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
L2_COEFF = 1
RATE = 10
TAGIDS = Hash.new { |hash, key| hash[key] = hash.size }
TAGIDS['<S>'] = 0
def dot(x, y)
(define (fringe x)
(define (loop x acc)
(cond ((null? x) acc)
((not (pair? x)) (cons x acc))
(else (loop (car x) (loop (cdr x) acc)))))
(loop x '()))
@haruyama
haruyama / gist:5820163
Last active December 18, 2015 17:39
$HOME/.vim/after/ftplugin/clojure.vim
if exists('b:did_after_ftplugin_clojure')
finish
endif
let b:did_after_ftplugin_clojure = 1
let s:save_cpo = &cpo
set cpo&vim
setl tabstop=2 expandtab shiftwidth=2 softtabstop=2 smarttab
if executable('lein') && filereadable('project.clj')
@haruyama
haruyama / gist:5791152
Last active December 18, 2015 13:39
check clojure syntaxes and execute tests. it requires syntastic, lein, lein-nrepl, vim-fireplace and clojure.tools.namespace.
if exists("g:loaded_syntastic_clojure_nrepl_checker")
finish
endif
let g:loaded_syntastic_clojure_nrepl_checker=1
function! SyntaxCheckers_clojure_nrepl_IsAvailable()
return executable('lein') && filereadable('project.clj')
endfunction
function! SyntaxCheckers_clojure_nrepl_GetLocList()
@haruyama
haruyama / gist:5494097
Created May 1, 2013 07:01
clojure autotest using vim-fireplace
function! s:run_tests(filename)
let template = '(require ''clojure.tools.namespace) (require ''clojure.test) (let [namespaces (clojure.tools.namespace/find-namespaces-in-dir (java.io.File. "%s"))] (doseq [ns namespaces] (prn ns) (require ns :reload) (if (re-find #"-test\z" (name ns)) (clojure.test/run-tests ns) (try (let [test-ns (symbol (str (name ns) "-test"))] (prn test-ns) (require test-ns :reload) (clojure.test/run-tests test-ns)) (catch Exception e (.getMessage e))))))'
let exp = printf(template, escape(a:filename, '"\'))
call fireplace#session_eval(exp)
endfunction
autocmd! BufWritePost *.clj call s:run_tests(expand("<afile>"))
import System.Environment
import System.IO
import System.Exit
import Control.Monad (filterM)
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.ICU.Regex as TIR
import qualified Data.Text.Lazy.IO as TILO
main :: IO ()
@haruyama
haruyama / grep.hs
Last active December 11, 2015 06:58
grep using Haskell.
import qualified System.Environment as SE
import qualified System.IO as SIO
import qualified Data.Text as T
import qualified Data.Text.ICU.Regex as TIR
import qualified Data.Text.IO as TIO
import Control.Monad (unless, when)
main :: IO ()
main = do
args <- SE.getArgs