Skip to content

Instantly share code, notes, and snippets.

@hakobe
hakobe / generator_quiz.js
Last active Oct 19, 2018
oopsを表示させずにhelloのみを表示させる方法を答えよ
View generator_quiz.js
function* hello() {
try {
while(true) {
yield 9
yield 3
yield 2
}
} catch(e) {
console.log('oops')
} finally {
View .explain.md

First, generate .flow file.

$ yarn run flow gen-flow-files --out-dir . greeting.js

Genereted file is almost the same as greeting.js.flow.

Next, run flow and get an error like below.

@hakobe
hakobe / client.go
Created Sep 23, 2016
golang unix domain socket
View client.go
package main
import (
"io"
"log"
"net"
"time"
)
func reader(r io.Reader) {
@hakobe
hakobe / gist:cf0de437dd7f5d1f7025
Last active Aug 29, 2015
なんかコンパイル通らない様子です
View gist:cf0de437dd7f5d1f7025
[error] (x$1: java.nio.file.Path,x$2: Iterable[_ <: CharSequence],x$3: java.nio.charset.Charset,x$4: java.nio.file.OpenOption*)java.nio.file.Path <and>
[error] (x$1: java.nio.file.Path,x$2: Array[Byte],x$3: java.nio.file.OpenOption*)java.nio.file.Path
[error] cannot be applied to (java.nio.file.Path, List[String], java.nio.charset.Charset)
[error] java.nio.file.Files.write(path, List("hoge"), StandardCharsets.UTF_8)
View scalaosusume.md

Scala おすすめポイントご紹介


おすすめポイント

普段Scalaを使っていて、この機能は便利、よくできていると感じているところをご紹介します。


@hakobe
hakobe / key_value_slice.pl
Created Aug 14, 2014
"Perl5.20のKey/Value Hash Slice" + "リストをスカラコンテキストで評価するとリストの最後の値になる" が組み合わさった様子
View key_value_slice.pl
use strict;
use warnings;
use utf8;
use v5.20.0;
my $h = {
hoge => 'hoo',
fuga => 'foo',
};
View grammer.jison
%lex
%%
\s+ /* skip whitespace */
"fun" return 'FUN'
[0-9]+ return 'INT'
"=>" return '=>'
<<EOF>> return 'EOF'
. return 'INVALID'
View gist:860fd1dd9c56c1d33a33
|- let twice = fun f -> fun x -> f (f x) in twice twice (fun x -> x * x) 2 evalto 65536 by E-Let {
|- fun f -> fun x -> f (f x) evalto ()[fun f -> fun x -> f (f x)] by E-Fun {};
twice = ()[fun f -> fun x -> f (f x)] |- twice twice (fun x -> x * x) 2 evalto 65536 by E-App {
twice = ()[fun f -> fun x -> f (f x)]
|- twice twice (fun x -> x * x) evalto (f = (f = (twice = ()[fun f -> fun x -> f (f x)])[fun x -> x * x])[fun x -> f (f x)])[fun x -> f (f x)] by E-App {
twice = ()[fun f -> fun x -> f (f x)]
|- twice twice evalto (f = ()[fun f -> fun x -> f (f x)])[fun x -> f (f x)] by E-App {
twice = ()[fun f -> fun x -> f (f x)] |- twice evalto ()[fun f -> fun x -> f (f x)] by E-Var1 {};
twice = ()[fun f -> fun x -> f (f x)] |- twice evalto ()[fun f -> fun x -> f (f x)] by E-Var1 {};
f = ()[fun f -> fun x -> f (f x)] |- fun x -> f (f x) evalto (f = ()[fun f -> fun x -> f (f x)])[fun
@hakobe
hakobe / Build.scala
Created Apr 2, 2014
run sub process while runnning play
View Build.scala
import sbt._
import Process._
import Keys._
import play.PlayRunHook
object SubProcess {
def apply(command: String): PlayRunHook = {
object SubProcessHook extends PlayRunHook {
View rot13.go
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader