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 / 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 / EventHandler.java
Last active August 29, 2015 14:15
EventHandlerアノテーション定義
/*
* Copyright 2011 Tsutomu YANO.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tyano
tyano / AnnotationEventDispatcher.java
Last active August 29, 2015 14:15
アノテーションによってイベントハンドラを定義できるWicketのIEventDispatcher実装
/*
* Copyright 2011 Tsutomu YANO.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package jp.javelindev.snippets;
public class Java8Sample {
public static void main(String[] args) {
Laco laco = new Laco();
SampleClass sample = new SampleClass();
sample.func(laco); //ClassCastException SomeClassはLacoにキャストできません
}
@tyano
tyano / killcoreaudio.sh
Created May 1, 2014 10:36
killcoreaudio.sh
#!/bin/bash
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
@tyano
tyano / core.clj
Created February 11, 2014 18:20
MD5ハッシュ突き合わせ(Clojure) - 単体でパフォーマンスチューニングしたものを、core.asyncを使って並列化。引数の末尾に :map をつけると、map/filterを使ったバージョンでもテスト可能。primitiveのloopのほうがちょっとだけ速い。並列化はcore数程度で頭打ち。100とかにしても遅くなるだけ。
(ns mdsample.core
(:require [clojure.core.reducers :as r]
[clojure.core.async :refer [chan >! <!! go close! alts!!]])
(:import [java.security MessageDigest]
[javax.xml.bind DatatypeConverter]
[java.util Arrays]
[java.util Queue]
[java.util.concurrent ConcurrentLinkedQueue]))
(defn- hexdigest
@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 {