Skip to content

Instantly share code, notes, and snippets.

@ishiduca
ishiduca / server.js
Created January 12, 2017 03:19
server side yo-yo yo-yo.js
const yo = require('yo-yo')
const url = require('url')
const http = require('http')
const app = http.createServer((req, res) => {
const q = url.parse(req.url, true).query
res.setHeader('content-type', 'text/html; charset=utf-8')
res.end(String(yo `<body><main><h1>${q.test}</h1></main></body>`))
})
@ishiduca
ishiduca / app.js
Last active January 10, 2017 12:51
rate-star-on-yo-yo-bind example yo-yo.js yo-yo-bind
const xtend = require('xtend')
const d = require('global/document')
const domcss = require('dom-css')
const app = require('yo-yo-bind')
const WHITESTAR = 'fa fa-star-o'
const BLACKSTAR = 'fa fa-star'
const reduce = (state, action, type) => {
if (type === 'CLEAR') {
@ishiduca
ishiduca / examle-count.js
Last active January 9, 2017 14:17
yo-yo.js example
var xtend = require('xtend')
var yo = require('yo-yo')
var d = require('global/document')
var app = require('./index')
var create = (state, dispatcher) => yo `
<main>
<button onclick=${ev => dispatcher('UPDATE', +1)}>inc</button>
<button onclick=${ev => dispatcher('UPDATE', -1)}>dec</button>
<p>${state.count}</p>
@ishiduca
ishiduca / app.js
Created October 22, 2016 09:34
JSON-RPC2.0 library(blue-frog) on Websocket(websocket-stream)
'use strict'
var http = require('http')
var path = require('path')
var ecstatic = require('ecstatic')(path.join(__dirname, 'static'))
var websocket = require('websocket-stream')
var response = require('blue-frog-core/response')
var router = require('../index')()
router.add('echo', (params, result, done) => {
process.nextTick(() => {
@ishiduca
ishiduca / browser.js
Last active September 19, 2016 23:17
blue-frog-b - create a JSON-RPC 2.0 server/client that corresponds to the batch processing
var hyperquest = require('hyperquest')
var through = require('through2')
var frog = require('blue-frog-b')
var rpc = require('blue-frog-stream')
window.onload = function () {
var hyp = hyperquest.post('http://0.0.0.0:9999/rpc')
var stream = frog()
hyp.on('error', onError)

寝坊ブレスト

最近生活リズム崩れて困る

何故遅刻するのか

  • 寝坊
  • 用事してたら意外と時間経ってた
    • 早起きすれば解決
    • 正当な理由なら裁量
@ishiduca
ishiduca / shin-nippon-no-wagei.md
Created July 23, 2016 07:31
新ニッポンの話芸 2017.07.20

新ニッポンの話芸

北沢タウンホール改修に合わせて落語会の存続が危うい。と聞いて、一泊二日足代も馬鹿にならないけど行ってきた。お初。 お三方の工夫が見られた落語会でした。

@ishiduca
ishiduca / observer.js
Last active April 13, 2016 12:14
Reactに寄せた Flux/Store のプロトタイプ
module.exports = Observer
function Observer () {
this.subs = []
}
Observer.prototype.publish = function () {
var args = [].slice.apply(arguments)
for (var i = 0; i < this.subs.length; i++) {
this.subs[i].apply(null, args)
@ishiduca
ishiduca / client.js
Created January 15, 2016 03:11
Re: Javascriptでデザインパターン (その7: Chain of Responsibility) ref: http://qiita.com/ishiduca/items/592afefb0eb721961f82
function Client () {
this.validators = [].slice.apply(arguments).filter(flt)
}
function flt (validator) {
return 'function' === typeof (validator || {}).request
}
Client.prototype.request = function (input) {
for (var i = 0; i < this.validators.length; i++) {
this.validators[i].request(input)
@ishiduca
ishiduca / lazy.js
Last active January 8, 2016 12:43
非同期の待ち合わせストリーム
var stream = require('readable-stream')
var inherits = require('inherits')
var eos = require('end-of-stream')
function Lazy () {
if (!(this instanceof Lazy)) return new Lazy
stream.Readable.call(this)
this.onWorks = []
this.count = 0
}