Skip to content

Instantly share code, notes, and snippets.


HARUYAMA Seigo haruyama

View GitHub Profile
haruyama / create_macaddress2md5_table.rb
Created Aug 22, 2011
this creates a table of macaddress, whose prefix(vendor id) is specified, to md5
View create_macaddress2md5_table.rb
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require 'digest/md5'
prefix =
haruyama / gist:1441337
Created Dec 7, 2011
lucene-gosen くよ bug
View gist:1441337
import org.apache.lucene.analysis.ja.JapaneseTokenizer;
public class LuceneGosenKuyoBug {
public static void main(String[] args) {
String s = "";
int count = Integer.parseInt(args[1]);
for (int i = 0; i < count; ++i) {
haruyama / gist:1702727
Created Jan 30, 2012
A sample of Clojure and lucene-gosen
View gist:1702727
(ns lucene_gosen_test.core (:gen-class))
(import java.util.Collections)
(defn -main [& args]
(println (first args))
(with-open [reader (new (first args))]
(let [
analyzer (new org.apache.lucene.analysis.ja.JapaneseAnalyzer org.apache.lucene.util.Version/LUCENE_35 Collections/EMPTY_SET Collections/EMPTY_SET Collections/EMPTY_SET "/home/haruyama/work/solr/dic/solr/conf/dic")
ts (.tokenStream analyzer "dummy" reader)
termAtt (.getAttribute ts org.apache.lucene.analysis.tokenattributes.CharTermAttribute)
posAtt (.getAttribute ts org.apache.lucene.analysis.ja.tokenAttributes.PartOfSpeechAttribute)
haruyama / LDclipXML2DeliciosHTML.rb
Created Aug 9, 2012
convert livedoor clip xml to delicious html.
View LDclipXML2DeliciosHTML.rb
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require 'rexml/document'
require 'cgi'
require 'time'
<DT><A HREF="%s" ADD_DATE="%d" PRIVATE="0" TAGS="%s">%s</A>
haruyama / grep.hs
Last active Dec 11, 2015
grep using Haskell.
View grep.hs
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
View gist:4583517
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 / gist:5494097
Created May 1, 2013
clojure autotest using vim-fireplace
View gist:5494097
function! s:run_tests(filename)
let template = '(require '' (require ''clojure.test) (let [namespaces ( ( "%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)
autocmd! BufWritePost *.clj call s:run_tests(expand("<afile>"))
haruyama / gist:5791152
Last active Dec 18, 2015
check clojure syntaxes and execute tests. it requires syntastic, lein, lein-nrepl, vim-fireplace and
View gist:5791152
if exists("g:loaded_syntastic_clojure_nrepl_checker")
let g:loaded_syntastic_clojure_nrepl_checker=1
function! SyntaxCheckers_clojure_nrepl_IsAvailable()
return executable('lein') && filereadable('project.clj')
function! SyntaxCheckers_clojure_nrepl_GetLocList()
haruyama / gist:5820163
Last active Dec 18, 2015
View gist:5820163
if exists('b:did_after_ftplugin_clojure')
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')
View gist:6209777
(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 '()))