Skip to content

Instantly share code, notes, and snippets.

View tetsuharuohzeki's full-sized avatar

Tetsuharu Ohzeki tetsuharuohzeki

  • Tokyo, Japan
  • 08:49 (UTC +09:00)
View GitHub Profile
@tetsuharuohzeki
tetsuharuohzeki / init_labels.js
Created March 6, 2019 08:35
Setup GitHub labels
'use strict';
const Octokit = require('@octokit/rest')
const clientWithAuth = new Octokit({
auth: 'token <blahblahblah>'
});
class LabelDef {
constructor(name, color, description) {
this.name = name;
@tetsuharuohzeki
tetsuharuohzeki / result.md
Last active September 21, 2016 10:25
Results of WebKit's /PerformanceTests/ES6SampleBench/index.html Sept. 21th, 2016
@tetsuharuohzeki
tetsuharuohzeki / ExIterable.ts
Last active June 25, 2016 08:19
Extentions for ECMA262 6th iterator
/**
* This provides extensions for ECMA262 2015's iterator.
*
* This adds `map()`, `forEach()`, `filter()`, `flatMap()`, or others
* to `Iterable<T>`. This enables features looks like "lazy evaluation".
* The design refers RxJS v5's one.
*
* See example:
* ```
*
@tetsuharuohzeki
tetsuharuohzeki / filter_map.ts
Last active November 13, 2015 08:55
filter map function for Rx.Observable.
import {Option} from 'option-t';
import {Observable} from 'rx';
type FilterMapFn<T, U> = (v: T) => Option<U>;
function filterMapForObservable<T, U>(source: Observable<T>, op: FilterMapFn<T, U>): Observable<U> {
const filtered = source.flatMap(function(v: T): Observable<U> {
const mapped: Option<U> = op(v);
const result: Observable<U> =
mapped.mapOrElse(function def(): Observable<U> {
@tetsuharuohzeki
tetsuharuohzeki / Result.ts
Last active March 7, 2016 05:44
Result<T, E> in TypeScript
/**
* This type is based on https://doc.rust-lang.org/std/result/enum.Result.html
*/
import {Option, Some, None} from 'option-t';
type mapFn<T, U> = (v: T) => U;
type flatmapOkFn<T, U, E> = (v: T) => Result<U, E>;
type flatmapErrFn<T, E, F> = (e: E) => Result<T, F>;
type recoveryFn<E, T> = (e: E) => T;
@tetsuharuohzeki
tetsuharuohzeki / rx_for_js_matomme.md
Last active August 4, 2018 06:46
RxJSのいろいろ雑感(2015年8月末編)

RxJSのいろいろ雑感(2015年8月末編)

  • Rx for JavaScriptについて、色々触った結論としてはこんな感じ
    • あくまでも現時点の感想なんで、そのうち認識が変わるかも
  • JavaScriptでRxを使う人ターゲットなんで、他の言語portにも効く話かはわからない

総論

気をつけること

@tetsuharuohzeki
tetsuharuohzeki / dive_into_rx.md
Last active August 29, 2015 14:17
「RxJSのObservableのHotとColdの実装を眺めた」. version controlled souce for http://saneyukis.hatenablog.com/entry/2015/03/28/142422

RxJSのObservableのHotとColdの実装を眺めた

RxJSの実装が長らく気になっていた。動機としては、来月の歌舞伎座.tech#7「Reactive Extensions」の予習の意味合いもあるが、個人的な興味が一番。コードベースはRxJS 2.4.6@089dca5。ロジックとしては結構ややこしいので、この記事も間違いがあるかもしれない点に注意。

コード雑感

本当にただの感想。

@tetsuharuohzeki
tetsuharuohzeki / ContextStack.ts
Last active August 29, 2015 14:16
inspired by Android Activity's Lifecycle
export interface Context {
onActivate(mountpoint: Element): void;
onDestroy(mountpoint: Element): void;
onSuspend(mountpoint: Element): void;
onResume(mountpoint: Element): void;
}
export class ContextStack {
private _mountPoint: Element;
private _stack: Array<Context>;
@tetsuharuohzeki
tetsuharuohzeki / option.ts
Last active August 29, 2015 14:12
Rustのcore::options::Option<T>のAPIをTypeScriptで再現
module option {
// This interface is based on Rust's `core::option::Option<T>`/
class Option<T> {
private _val: T;
private _is_some: boolean;
constructor(val?: T) {
this._val = val;
this._is_some = (val !== undefined);
@tetsuharuohzeki
tetsuharuohzeki / router.js
Created November 26, 2014 04:45
Fluxパターンでルーターを作る
var crossroads = require("crossroads");
var Dispatcher = require("flux").Dispatcher;
var EventEmitter = require("events").EventEmitter;
var hasher = require("hasher");
var RoutingActionCreator = {
/**
* @param {string} path
*/