Skip to content

Instantly share code, notes, and snippets.

@sndyuk
sndyuk / FluentLogbackAppender.java
Created January 14, 2012 19:34
Logback appender with fluent-logger-java
package com.example;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.fluentd.logger.FluentLogger;
@sndyuk
sndyuk / Simple_Unit_test_DSL_on_Scala.scala
Created June 26, 2012 02:58
Scalaでタスク管理DSL
package trampoline
import java.text.SimpleDateFormat
import java.util.Date
/**
* Simple Unit test DSL.
*/
class UnitTestContext(val limit: Date)
@sndyuk
sndyuk / VirtualExtensionMethod.java
Created July 25, 2012 14:37
Java8 virtual extension method 色々
class VirtualExtensionMethod {
public static void main(String[] args) {
F fa = new FA();
fa.f1("fa");
F fb = new FB();
fb.f2("fb");
}
@sndyuk
sndyuk / runtime mock of structual subtyping.scala
Created November 4, 2012 11:45 — forked from xeno-by/gist:4008389
構造的部分型を引数に持つ関数に対して、実行時に引数を動的に作成して渡す
import scala.language.reflectiveCalls
// for the story behind this snippet of code see:
// http://stackoverflow.com/questions/13185405/structural-subtyping-reflection
// requires Scala 2.10.0-RC1 or higher
// you also need to have scala-reflect.jar and scala-compiler.jar on your classpath
import scala.reflect.runtime.universe._
object Test extends App {
@sndyuk
sndyuk / Bean.java
Created November 5, 2012 18:59
logic to determine Dao calls based on logged in user and servlet called
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Bean {
}
@sndyuk
sndyuk / contravariantPosInType.md
Created December 16, 2012 03:24
error: covariant type T occurs in contravariant position in type ... について Scala

error: covariant type T occurs in contravariant position in type について

このクラスは定義できない:

scala> class B[+T] {
     | def f(arg: T): T = arg
     | }
<console>:9: error: covariant type T occurs in contravariant position in type T of value arg
       def f(arg: T): T = arg
(function($) {
$.fn.noClickDelay = function() {
var $wrapper = this;
var $target = this;
var moved = false;
$wrapper
.bind(
'touchstart mousedown',
function(e) {
e
#!/bin/bash
echo -ne "\033[K1!\r"
sleep 1
echo -ne "\033[K2!\r"
sleep 1
echo -ne "\033[K3!\r"
@sndyuk
sndyuk / List_add_functioins.scala
Created March 20, 2013 08:29
ListとListBufferの要素を後ろに追加する処理の速度を測ってみた Scala 2.10
import java.io.PrintWriter
import scala.collection.mutable.ListBuffer
import scala.util.{ Try, Success, Failure }
object List_add_functioins extends App {
//val out = new PrintWriter("score.csv", "utf-8")
//out.println("""symbol,size,elapsed""") -> For D3js
def time[R](symbol: String, size: Int, block: => R): R = {
public class User {
@NotNull @Email
public String getEmail() { return email; }
public void setEmail(String email) {
this.email = email;
}
private String email;
}
public class UserService {