func md5hash(text []byte) string {
h := md5.New()
h.Write(text)
return fmt.Sprintf("%x", h.Sum(nil))
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ mkdir rack-test | |
| $ cd rack-test | |
| $ vi Gemfile | |
| $ vi config.ru | |
| $ vi unicorn_config.rb | |
| $ bundle install --path=.bundle | |
| $ bundle exec unicorn -c ./unicorn_config.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # apache2を再起動 | |
| sudo systemctl restart apache2 | |
| # apache2の設定を再読み込み | |
| sudo systemctl reload apache2 | |
| # apache2を止める | |
| sudo systemctl stop apache2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a = SIMD.Float32x4(1.0,2.0,3.0,4.0); | |
| var b = SIMD.Float32x4(5.0,6.0,7.0,8.0); | |
| var c = SIMD.Float32x4.add(a,b); | |
| console.log(SIMD.Float32x4.extractLane(c, 0)); | |
| console.log(SIMD.Float32x4.extractLane(c, 1)); | |
| console.log(SIMD.Float32x4.extractLane(c, 2)); | |
| console.log(SIMD.Float32x4.extractLane(c, 3)); | |
| var a = SIMD.Int32x4(1,2,3,4); | |
| var b = SIMD.Int32x4(5,6,7,8); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.ning.http.client.providers.netty.NettyResponse | |
| import org.apache.thrift.protocol.TBinaryProtocol | |
| import org.apache.thrift.transport.{TMemoryInputTransport, TMemoryBuffer, THttpClient} | |
| import org.apache.thrift.{TException, TServiceClient, TServiceClientFactory} | |
| import play.api.Play.current | |
| import play.api.libs.ws.WS | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent.Future | |
| import scala.util.control.NonFatal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data MyMaybe a = MyNothing | MyJust a deriving (Show) | |
| instance Functor MyMaybe where | |
| fmap f MyNothing = MyNothing | |
| fmap f (MyJust a) = MyJust (f a) | |
| instance Applicative MyMaybe where | |
| pure x = MyJust x | |
| MyNothing <*> _ = MyNothing | |
| _ <*> MyNothing = MyNothing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data MyList a = MyEmpty | MyCons a (MyList a) deriving (Show) | |
| instance Functor MyList where | |
| fmap f MyEmpty = MyEmpty | |
| fmap f (MyCons x xs) = MyCons (f x) (fmap f xs) | |
| instance Applicative MyList where | |
| pure x = MyCons x MyEmpty | |
| MyEmpty <*> _ = MyEmpty | |
| _ <*> MyEmpty = MyEmpty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ($m = RT::get('/works/:id' /*pathパターン*/, [':id:uint' /*pathのパラメータ*/])) { | |
| getWorks($m[':id']); | |
| } else if ($m = RT::get('/works/', ['page:uint:1' /*GETパラメータ。デフォルト1*/, 'type:string:' /*GETパラメータ。デフォルト空文字*/, 'tags:string[]' /*GETパラメータ。配列のみ受け取る。デフォルトは空配列?*/])) { | |
| getWorks($m['page'], $m['type'], $m['tags']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object ProcessEnumerator { | |
| // wraps a ProcessBuilder with Play's Enumerator | |
| // and executes the process in Future | |
| // so that the process' output can be streamed | |
| def apply(process: ProcessBuilder): Enumerator[String] = { | |
| val in = new PipedInputStream() | |
| val out = new PipedOutputStream(in) | |
| Future(process.#>(out).run()) | |
| val reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package heapq | |
| import "errors" | |
| type intMaxHeap struct { | |
| buf []int | |
| length int | |
| } | |
| func (h *intMaxHeap) Cap() int { |