Skip to content

Instantly share code, notes, and snippets.

{
"git.autofetch": true,
"window.zoomLevel": 1,
"explorer.confirmDragAndDrop": false,
"editor.codeLens": false,
"editor.find.seedSearchStringFromSelection": false,
"editor.lightbulb.enabled": false,
"editor.suggestOnTriggerCharacters": false,
"editor.wordBasedSuggestions": false,
"sublimeTextKeymap.promptV3Features": true,
@kawasako
kawasako / ss.js
Created September 13, 2017 03:57
nightmare cwa capture
const Nightmare = require('nightmare');
const path = require('path');
const USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1';
const VIEWPORT_WIDTH = 375;
const VIEWPORT_HEIGHT = 3000;
function run() {
let nightmare = Nightmare({
show: true,
npm run test
> string2object@0.0.1 test /Users/username/Develop/string2object.js
> npm run build && npm run test-build && node test/build/index.js
> string2object@0.0.1 build /Users/username/Develop/string2object.js
> babel src --out-dir lib
src/string2object.js -> lib/string2object.js
import s2o from '../../lib/string2object';
function test(name, truth) {
try {
if (truth) {
console.info(`Success test: ${name}`);
} else {
throw new Error(`Failed test: ${name}`);
}
} catch(err) {
const stringsRegExp = /("[^"]*?"|'[^']*?')/gm;
const numbersRegExp = /\d/gm;
const keysRegExp = /([{,])[\w\d]*?(\:)/gm;
const validTestRegExp = /^[\{\}\[\]\,]*$/;
const removeWhiteSpaces = function(str) {
return (str + '').replace(/\s*/gm, '');
};
const trim = function(str) {
import $ from 'jquery';
class HogeWidget {
constructor(el) {
this.$el = $(el);
}
bind() {
this.$el.on('click', () => { ... });
}
init() {
export default class HogeWidget {
constructor(el, resolver) {
this.el = el;
this.resolver = resolver;
}
bind() {
this.el.addEventListener('click', () => { ... });
}
init() {
this.bind();
import _ from 'underscore';
import { Promise } from 'es6-promise';
import HogeWidget from 'widgets/hogeWidget';
const widgets = {
hoge: HogeWidget
};
const widgetsInstances = [];
export default class HogeWidget {
constructor(el) {
this.el = el;
}
bind() {
this.el.addEventListener('click', () => { ... });
}
init() {
this.bind();
}
@kawasako
kawasako / pooledClass.js
Created May 30, 2016 08:13
PooledClassの実装
export default class PooledClass {
constructor(clazz) {
this.clazz = clazz;
this.pool = [];
}
alloc(...args) {
let instance = this.pool.pop();
if (!instance) {
instance = new this.clazz();
}