Skip to content

Instantly share code, notes, and snippets.

OKUNOKENTARO okunokentaro

View GitHub Profile
View retina-canvas.js
const prepareRetina = (el, dpr) => {
el.width *= dpr;
el.height *= dpr;
el.style.width = `${el.width / dpr}px`;
el.style.height = `${el.height / dpr}px`;
};
const render = () => {
const canvasEl = document.querySelector('canvas');
const dpr = window.devicePixelRatio;
View kuker-component.ts
import { kk } from './emitter';
/**
* AoT のために export function での宣言が必須。
*/
/* tslint:disable:only-arrow-functions */
export function KukerComponent() {
return cls => {
const componentRole = cls.__proto__.name.includes('DecisionMaker')
? 'DecisionMaker'
View parser.rs
#[derive(Debug)]
struct Parser {
cursor: Cursor,
tokens: Vec<String>,
}
impl Parser {
pub fn new(cursor: Cursor) -> Parser {
Parser { cursor, tokens: Vec::new()}
}
View parser.js
const _statements = [
`class_implements 'Foo' and includes 'Bar' then error`,
`class_extends 'BaseMediator' and import 'component' then error`,
`method_returns 'Observable' and not name_matches '\\$$' then warn`,
`class_implements 'Foo' and includes 'Bar' then error`,
];
// noprotect
const f = statements => {
console.log('===============================');
View enforceDollarWhenObservableRule.ts
import * as ts from 'typescript';
import * as Lint from 'tslint';
import { EnforceNamingWalker } from './enforceNamingBase';
export class Rule extends Lint.Rules.AbstractRule {
static FAILURE_STRING = `It is a method that returns Observable, use '*$' suffix`;
apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
@okunokentaro
okunokentaro / recipe.js
Last active Jun 27, 2017
Rxチャーハン
View recipe.js
import {Observable, Subject} from 'rxjs'
// # 材料
// ## ご飯
class ご飯 {
freeze() {
this.温度 = -10
return this
}
View 失恋ソングアプリ見本
import { Component } from '@angular/core';
class Hero {
id: number;
name: string;
}
@Component({
selector: 'my-app',
template: `
@okunokentaro
okunokentaro / itunes-replace-song-name.scpt
Last active Jun 28, 2016
日本語のファイルを読み込んで1行ごとにJSのstringとして出力するJXA
View itunes-replace-song-name.scpt
ObjC.import('Foundation');
var app = Application.currentApplication();
app.includeStandardAdditions = true;
var path = app.chooseFile();
var pipe = $.NSPipe.pipe;
var file = pipe.fileHandleForReading; // NSFileHandle
var task = $.NSTask.alloc.init;
@okunokentaro
okunokentaro / dexie.js
Last active Apr 30, 2016
ng-kyoto Angular Meetup #4 資料
View dexie.js
import Dexie from 'dexie';
const dbName = 'dexie-suburi';
const dbVer = 2;
window.indexedDB.deleteDatabase(dbName);
const dexieDb = new Dexie(dbName);
dexieDb.version(dbVer).stores({
user: '++id,name',
View index.html
<!DOCTYPE html>
<html>
<head>
<base href="/">
<title>ng-kyoto is very cool</title>
</head>
<body>
<my-app></my-app>
<script src="./bundle.js"></script>
You can’t perform that action at this time.