Skip to content

Instantly share code, notes, and snippets.

LogNameAndCall = function(f){
console.log(f.name)
f()
}
x = function(){console.log(1)}
logNameAndCall(f);
// console shows
function* noNextArgNoSelfArg(){
var localVar = 'a';
var FirstYieldRetval = yield localVar;
localVar = 'b';
var SecondYieldRetval = yield localVar;
console.log('noNextArgNoSelfArg', {localVar})
}
function* noNextArgSelfArg(selfArg){
class ObjectInspector {
constructor(target) {
this.target = target;
this["[[Class]]"] = Object.prototype.toString.call(this.target),
this.constructorName = this.target.constructor ? this.target.constructor.name : undefined,
this.props = Object.getOwnPropertyNames(this.target)
}
}
class ObjectChainInspector {
class ObjectInspector {
constructor(target) {
this.target = target;
this.valueOf = {
"[[Class]]": Object.prototype.toString.call(this.target),
constructorName: this.target.constructor ? this.target.constructor.name : undefined,
props: Object.getOwnPropertyNames(this.target)
}
}
}
function showHoge () {
var hoge;
setTimeout(function delayedFunc() {
hoge = 2
console.log('setTimeout', hoge);
});
hoge = 1
console.log('outer', hoge);
}
showHoge();
@onionmk2
onionmk2 / TsAndBabelSetup.sh
Last active December 27, 2016 02:50
typescript-> (ts-loader)-> es6 -> (babel-loader)-> es5
#!/usr/bin/env bash
mkdir src
mkdir dist
npm init -y
npm install --save-dev typescript
npm install --save-dev webpack # 1 系を想定している。
npm install --save-dev ts-loader
npm install --save-dev babel-core
@onionmk2
onionmk2 / typescript_dev.sh
Last active December 25, 2016 11:54
typescript dev
#!/usr/bin/env bash
mkdir src
mkdir dist
npm init -y
npm install --save-dev typescript
npm install --save-dev webpack
npm install --save-dev ts-loader
@onionmk2
onionmk2 / recursive.js
Last active January 4, 2017 14:36
recursive function call
const arr =
[
[
[1, 2, 3],
[4, 5, 6],
],
[
[7, 8, 9],
[10, 11, 12],
]
@onionmk2
onionmk2 / F7N4-4.cs
Last active February 4, 2017 18:06
singleton vs singleton CQS
using System;
public class Singleton {
private static Singleton mInstance;
private Singleton () { // Private Constructor
}
public static Singleton Instance {
get {
@onionmk2
onionmk2 / Singletons.md
Created February 5, 2017 10:34 — forked from Ashwinning/Singletons.md
A copy of the post on Singletons in Unity/C# as it appeared on UnityPatterns.com

Singletons

Original post by David Laskey on UnityPatterns

As you develop in Unity, you’ll often find that it’s handy to have just single instances of certain objects. For example, let’s say we have a single GameObject, “MusicManager”, that’s in charge of our music. It might look like this:

using UnityEngine;