Skip to content

Instantly share code, notes, and snippets.

edvakf

Block or report user

Report or block edvakf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:a871d5606ae5a3122c84000009477681
# apache2を再起動
sudo systemctl restart apache2
# apache2の設定を再読み込み
sudo systemctl reload apache2
# apache2を止める
sudo systemctl stop apache2
View simd-test.js
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);
@edvakf
edvakf / Rpc.scala
Last active Aug 29, 2015
ThriftRpc
View Rpc.scala
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
View mymaybe.hs
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
View mylist.hs
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
@edvakf
edvakf / rt-router.php
Last active Aug 29, 2015
フレームワークではなくライブラリとして使うPHPのルーター案
View rt-router.php
<?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']);
View ProcessEnumerator.scala
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))
View go.md

golang使いまわせる処理一覧

md5

func md5hash(text []byte) string {
	h := md5.New()
	h.Write(text)
	return fmt.Sprintf("%x", h.Sum(nil))
}
View heapq.go
package heapq
import "errors"
type intMaxHeap struct {
buf []int
length int
}
func (h *intMaxHeap) Cap() int {
@edvakf
edvakf / main.go
Created Sep 26, 2014
gob serialize
View main.go
package main
import (
"bytes"
"database/sql"
"encoding/gob"
"log"
Radix "github.com/fzzy/radix/extra/pool"
)
You can’t perform that action at this time.