Skip to content

Instantly share code, notes, and snippets.

Avatar

Tetsuharu Ohzeki tetsuharuohzeki

View GitHub Profile
View init_labels.js
'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 Sep 21, 2016
Results of WebKit's /PerformanceTests/ES6SampleBench/index.html Sept. 21th, 2016
View result.md
@tetsuharuohzeki
tetsuharuohzeki / ExIterable.ts
Last active Jun 25, 2016
Extentions for ECMA262 6th iterator
View ExIterable.ts
/**
* 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 Nov 13, 2015
filter map function for Rx.Observable.
View filter_map.ts
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 Mar 7, 2016
Result<T, E> in TypeScript
View Result.ts
/**
* 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 Aug 4, 2018
RxJSのいろいろ雑感(2015年8月末編)
View rx_for_js_matomme.md

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

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

総論

気をつけること

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

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

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

コード雑感

本当にただの感想。

@tetsuharuohzeki
tetsuharuohzeki / ContextStack.ts
Last active Aug 29, 2015
inspired by Android Activity's Lifecycle
View ContextStack.ts
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 Aug 29, 2015
Rustのcore::options::Option<T>のAPIをTypeScriptで再現
View option.ts
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 Nov 26, 2014
Fluxパターンでルーターを作る
View router.js
var crossroads = require("crossroads");
var Dispatcher = require("flux").Dispatcher;
var EventEmitter = require("events").EventEmitter;
var hasher = require("hasher");
var RoutingActionCreator = {
/**
* @param {string} path
*/