Skip to content

Instantly share code, notes, and snippets.

View kenmori's full-sized avatar
🏠
Working from home

KenjiMorita kenmori

🏠
Working from home
View GitHub Profile
@kenmori
kenmori / Point3D_extends_Point__addComment.js
Last active March 19, 2017 10:56
【TypeScript】__extendsやnew __()は何をやっているか説明
//http://kenjimorita.jp/typescript__extends_new__
//ここの説明
var __extends = (this && this.__extends) || function (d, b) {//d = Point3D, b = _super(Point)
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];//1
function __() { this.constructor = d; }
d.prototype = b === null
? Object.create(b)// nullなら{}を返す
function Animal() { }
Animal.prototype.walk = function () { console.log('walk') };
function Bird() { }
Bird.prototype.__proto__ = Animal.prototype;//ここの部分
Bird.prototype.fly = function () { console.log('fly') };
var bird = new Bird();
bird.walk();
bird.fly();
@kenmori
kenmori / 3line.js
Created March 19, 2017 14:09
【TypeScript】__extendsやnew __()は何をやっているか。理解しなくてはいけない3行
//1
function __() { this.constructor = d; }
//2
__.prototype = b.prototype;
//3
d.prototype = new __();
@kenmori
kenmori / __proto__vs_prototype.md
Last active June 5, 2022 00:42
__proto__とprototypeの違い

__proto__とprototypeの違い

prototype

・基底クラスが持つ

    Array.prototype
    Function.prototype
@kenmori
kenmori / normal_mode-vs-loose_mode.js
Last active March 23, 2017 14:26
babel-preset-es2015 loose mode vs normal mode
//Example code
//これがnormalとlooseでどこが変わるのか・・
///////////////////////////
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
toString() {
return `(${this.x}, ${this.y})`;
@kenmori
kenmori / canvas_p5_center.js
Created March 26, 2017 00:22
【Canvas/p5.js】解決。canvas要素を可変(window幅やwindowの50%,中央寄せ)などに動的にする方法
function setup(){
createCanvas(windowWidth, windowHeight);
rectMode(CENTER);
}
function draw (){
background(150);
strokeWeight(2);
stroke(255);
fill(0, 0);
rect(windowWidth/2, windowHeight/2, windowWidth/4, windowHeight/8); //@param startX, startY, rectWidth, rectHight
@kenmori
kenmori / performance.md
Last active February 11, 2024 03:29
パフォーマンス改善まとめ

ブラウザの仕事

→HTML、CSS、JSファイルを取り込み画面上にピクセルをレンダリングさせること

パフォーマンスの最適化とは

→各ファイルのバイトの受信からこれらをピクセルとしてレンダリングするために必要な処理までの中間段階(クリティカルレンダリングパス)を最適化すること

https://t32k.me/mol/log/style-class-conference/

@kenmori
kenmori / history_sample.js
Last active April 8, 2017 00:09
historyの使い方sample
//html
//<div id="ran">0</div>
//<button id="button">click</button>
//
if(window.history || window.history.pushState){
var button = document.getElementById("button");
var ran = document.getElementById("ran");
button.onclick = function(){
var random = Math.floor(Math.random() * 11);
@kenmori
kenmori / localstorage_private_ios_safari.md
Last active April 9, 2017 00:13
【朗報】iOSのsafariのプライベートモードでlocalStorageを使う方法/使い方(how to use localStorage in private mode of iOS:safari)

npm i -D store (not Store , store.js)

import store from 'store'; in your js file

store.set('user', true ); set localStorage

store.get('user'); get value

demo visit on iOS safari private mode

@kenmori
kenmori / react-router@3.x_vs_4.x.js
Created April 9, 2017 05:52
【react-router@3.x→4.x】updateした際に出会ったエラーまとめ(how to update react-router3.x vs 4.x)
//やること1
npm i -D react-router-dom@4.0.0
//react-routerで使っていたモジュールはreact-router-domから呼びます
//やること2
//v3.x
import {browserHistory, IndexRoute, Redirect, Router, Route, NotFoundRoute, DefaultRoute, Link, RouteHandler} from 'react-router';