Skip to content

Instantly share code, notes, and snippets.

View gakuzzzz's full-sized avatar

Manabu Nakamura gakuzzzz

View GitHub Profile
@gakuzzzz
gakuzzzz / log.md
Created September 24, 2012 09:59

1回目

[error] {file:/C:/home/nakamura/workspace/hoge/}hoge/compile:sources: java.lang.ExceptionInInitializerError
[error] application -

! Internal server error, for request [GET /] ->

play.api.UnexpectedException: Unexpected exception [ExceptionInInitializerError: null]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:233) ~[na:na]
@gakuzzzz
gakuzzzz / essential.scala
Created September 30, 2012 07:07
ThreadSafe jetty server
package com.yuroyoro.websocket
import javax.servlet.http._
import org.eclipse.jetty.websocket._
import org.eclipse.jetty.websocket.WebSocket.Outbound
import java.util.concurrent.atomic._
class ChatServlet extends WebSocketServlet {
val clients = new AtomicReference[Set[ChatWebSocket]](Set())
@gakuzzzz
gakuzzzz / 1.scala
Created October 1, 2012 02:18
Ruby の rescue retry 的な何か
import scala.annotation.tailrec
import scala.util.control.Exception._
@tailrec
def hoge: A = {
allCatch opt {
なんか失敗するかもな処理
} match {
case Some(a) => a
case None => hoge
@gakuzzzz
gakuzzzz / 1.scala
Created October 3, 2012 00:38
汎用CASループ
implicit def cas[A](reference: AtomicReference[A]) = new {
def compareAndSet(f: A => A): Unit = {
val current = reference.get
if (reference.compareAndSet(current, f(current))) ()
else compareAndSet(f)
}
}
@gakuzzzz
gakuzzzz / gist:3824646
Created October 3, 2012 02:45 — forked from mariussoutier/gist:3237595
repeat helper with index
package views.html.helper
import play.api.templates.Html
import play.api.data.Field
object repeatWithIndex {
def apply(field: Field, min: Int = 1)(f: (Field, Int) => Html) = {
val idSeq = if (field.indexes.size >= min) {
field.indexes
@gakuzzzz
gakuzzzz / 1.scala
Created October 10, 2012 07:40
Scalaで文字列を1つずつずらす
scala> def add(i: Int)(words: String) = words.map({x: Char => x + i - 'a'} andThen Stream.continually(Range.inclusive('a', 'z')).flatten andThen {_.toChar})
add: (i: Int)(words: String)String
scala> add(2)("abcdz")
res16: String = cdefb
@gakuzzzz
gakuzzzz / 1.scala
Created October 15, 2012 03:08
final な override ?
class A {
final def foo(x: Int, y: Int): Int = x + y
def useFoo = {
println(foo(100, 200))
}
}

!SLIDE

Deprecating the Observer Pattern

 

2012/10/21 ScalaBase in 名古屋

!SLIDE

@gakuzzzz
gakuzzzz / ehcache.xml
Created November 26, 2012 05:01
ehcache.xml example
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<diskStore path="{your storage path}"/>
<defaultCache
diskPersistent="true"
maxEntriesLocalHeap="1000"
/>
</ehcache>
@gakuzzzz
gakuzzzz / girlslove_ac_2013_3rd.md
Created December 3, 2012 13:24
百合・ガールズラブ Advent Calendar 2012 3日目

天槍の下のバシレイスが面白いよのこと

これは百合・ガールズラブ Advent Calendar 2012の3日目の記事です。

天槍の下のバシレイス〈1〉 〈2〉 伊都工平/瑚澄遊智(電撃文庫) の紹介です。

最初に

この作品を百合・ガールズラブでカテゴライズすると怒る人もいるかもしれません。なぜなら同性を愛することに対する葛藤だとか、恋愛感情による心の機微とかは一切無いからです。なのでそういったものを求めてる場合にはお勧めしません。