Skip to content

Instantly share code, notes, and snippets.

View tyano's full-sized avatar

Tsutomu YANO tyano

View GitHub Profile
(defmacro defdelegation
[protocol-name options & body]
(let [{:keys [prefix] :or {prefix "-"}} (if (map? options) options {})
body (if (map? options) body (cons options body))
protocol-body (mapv (fn [definition]
(let [fn-sym (first definition)
fn-body (rest definition)]
(apply list (symbol (str prefix (name fn-sym))) fn-body)))
body)
fn-defs (mapv (fn [definition]
@tyano
tyano / gist:8913662
Last active May 29, 2019 21:29
MD5ハッシュ突き合わせ(Java版) - Clojure版と同じように修正し、Core i5/2.4GHzで550ms程度までパフォーマンスアップ。
package example.mdsample.java;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.xml.bind.DatatypeConverter;
import org.apache.commons.lang.StringUtils;
public class App {
@tyano
tyano / install_certs_to_jdk.sh
Created December 3, 2018 10:06
sdkmanでインストールしたjdkに証明書をインストールするスクリプト
#!/usr/bin/env bash
function check_error() {
ret=$?
msg=$1
code=$2
if [[ $RET -ne 0 ]]
then
echo "error: $1" >&2
exit $code
@tyano
tyano / install_certs_to_jdk.sh
Created September 26, 2018 10:08
MacでOpenJDKにAmazonとGlobalSignのRoot証明書をインストールする
#!/usr/bin/env bash
function check_error() {
ret=$?
msg=$1
code=$2
if [[ $RET -ne 0 ]]
then
echo "error: $1" >&2
exit $code
(fact "user-ageはユーザの年齢を返す"
(user-age ..name..) => ..age..
(provided
(fetch-user-data ..name..) => {:age ..age.., :name ..name..}))
@tyano
tyano / build.xml
Created February 4, 2013 11:12
apache riverのインストールスクリプト
<target name="install-artifacts" depends="jars">
<macrodef name="install">
<attribute name="file" />
<attribute name="pom" />
<sequential>
<artifact:install file="@{file}" >
<pom refid="@{pom}"/>
</artifact:install>
</sequential>
</macrodef>
@tyano
tyano / gist:2497774
Created April 26, 2012 08:51
errors on easy_install subvertpy
Searching for subvertpy
Reading http://pypi.python.org/simple/subvertpy/
Reading http://samba.org/~jelmer/subvertpy
Reading http://launchpad.net/subvertpy
Best match: subvertpy 0.8.10
Downloading http://samba.org/~jelmer/subvertpy/subvertpy-0.8.10.tar.gz
Processing subvertpy-0.8.10.tar.gz
Running subvertpy-0.8.10/setup.py -q bdist_egg --dist-dir /tmp/easy_install-NDoICr/subvertpy-0.8.10/egg-dist-tmp-GLfV9D
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 10, in <module>
@tyano
tyano / gist:1429218
Created December 4, 2011 04:54
List(1, 2, 3, 1) を Map(1 -> 2, 2 -> 1, 3 -> 1) No.2
List(1,2,3,1).foldLeft(Map[Int,Int]()) { (x, y) => x.get(y) match { case Some(v) => x + Pair(y, (v + 1)) case None => x + Pair(y, 1) }}
@tyano
tyano / gist:1429205
Created December 4, 2011 04:48
List(1, 2, 3, 1) を Map(1 -> 2, 2 -> 1, 3 -> 1)
List(1,2,3,1).zip(List(1,1,1,1)).foldLeft(Map[Int,Int]()) { (x, y) => x.get(y._1) match { case Some(v) => x + Pair(y._1, (v + y._2)) case None => x + y }}
var fs = require('fs');
var sys = require('sys');
var stream = fs.createReadStream('./sample.txt', { 'flags': 'r',
'encoding': 'UTF-8',
'bufferSize': 4 * 1024});
var stream2 = fs.createReadStream('./sample2.txt', { 'flags': 'r',
'encoding': 'UTF-8',
'bufferSize': 4 * 1024});