Skip to content

Instantly share code, notes, and snippets.

@hakobe
hakobe / client.go
Created September 23, 2016 16:33
golang unix domain socket
package main
import (
"io"
"log"
"net"
"time"
)
func reader(r io.Reader) {
* ホスト名につかえそうなもの
- 将軍の名前
- ローマ皇帝の名前
- ガンダムのモビルスーツの名前
- 麻雀の役
- 天使の名前
- ある歌手の曲名
- 二十八宿(http://ja.wikipedia.org/wiki/%E4%BA%8C%E5%8D%81%E5%85%AB%E5%AE%BF)
- 二十四節気 (http://ja.wikipedia.org/wiki/%E4%BA%8C%E5%8D%81%E5%9B%9B%E7%AF%80%E6%B0%97)
- 東海道の駅名
@hakobe
hakobe / main.md
Last active December 20, 2018 04:44
Kyoto.js #7 何がMVCをつなげているのか

何がMVCをつなげているのか

クライアントサイドMVC

  • buzzwordっぽい
  • Backbone.js Angular.js Knockout.js Ember.js とか
  • 使ってますか?
    • はてなでも一部本番運用/社内向けツールではよくみる
  • クライアントサイドMVCフレームワークを利用するとMVCによる設計方針を簡単に使うことができるようになる
@hakobe
hakobe / generator_quiz.js
Last active October 19, 2018 13:08
oopsを表示させずにhelloのみを表示させる方法を答えよ
function* hello() {
try {
while(true) {
yield 9
yield 3
yield 2
}
} catch(e) {
console.log('oops')
} finally {

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 / external_script_document_write.html
Last active November 20, 2017 00:57
外部 script の読み込みのタイミングによってはdocument.writeが無視される場合がある
<html>
<!--
"HTML 構文解析器が HTML 文書の末尾まで来たタイミングより後で <script src> で
指定されたスクリプト経由で実行される document.write は黙って無視される" by wakabatan
see also http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter
$ plackup -p 3005 -e 'use Plack::App::Directory; Plack::App::Directory->new({root=>"."})->to_app'
のようにしておためしください
-->
<body>
use strict;
use warnings;
package Count;
sub new {
my $class = shift;
my $start = shift || 0;
bless { count => $start }, $class;

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


おすすめポイント

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


require 'fiber'
f1 = nil
f2 = nil
f1 = Fiber.new do
puts 'f1-0'
f2.resume
puts 'f1-1'
f2.resume
@hakobe
hakobe / rot13.go
Last active January 2, 2016 16:49
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader