sed -i "s/,/\t/g" *.generator
touch variables tail -n +2 *.generator > variables ==> sed '1d' *.generator > variables sed -i '/^$/d' variables sed -i '/==>/d' variables
| App.Adapter = DS.RESTAdapter.extend | |
| serializer: DS.RESTSerializer.extend | |
| extract: (loader, json, type, record) -> | |
| root = @rootForType(type) | |
| // Embed JSON data in a new object with root element | |
| newJSON = {} | |
| newJSON[root] = json | |
| json = newJSON | |
| // |
| class Hero { | |
| HeroState state; | |
| public Hero() { | |
| this.state = new FullBloodState(); | |
| } | |
| attack() { | |
| this.state.attack(); | |
| } | |
| backCity() { | |
| this.state.backCity(); |
| // First lets create our drawing surface out of existing SVG element | |
| // If you want to create new surface just provide dimensions | |
| // like s = Snap(800, 600); | |
| var s = Snap("#svg"); | |
| // Lets create big circle in the middle: | |
| var bigCircle = s.circle(150, 150, 100); | |
| // By default its black, lets change its attributes | |
| bigCircle.attr({ | |
| fill: "#bada55", | |
| stroke: "#000", |
| var a = { name: 'k2', age: 2}; | |
| var b = Object.create(a); | |
| b.age = 5; | |
| console.log(a.age); | |
| console.log(b.age); | |
| delete b.age; | |
| console.log(b.age); |
| project use webpack, babel & ... | |
| add // @flow to the top of source files | |
| ```bash | |
| touch .flowconfig | |
| npm install -D flow-bin babel-plugin-transform-flow-strip-types eslint-plugin-flowtype | |
| ## add this plugin in .babelrc or webpack config file | |
| echo '{"plugins": ["transform-flow-strip-types"]}' > .babelrc | |
| ``` |
| const Koa = require('koa') | |
| const koaBody = require('koa-body')() | |
| const Router = require('koa-router') | |
| const session = require('koa-session') | |
| const rp = require('request-promise') | |
| const redis = require('redis') | |
| const bluebird = require('bluebird') | |
| const app = new Koa() | |
| const router = new Router() |
| const util = require('util') | |
| const exec = util.promisify(require('child_process').exec) | |
| async function random() { | |
| const { stdout, stderr } = await exec( | |
| `/bin/sh -c "tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 128 | head -n 1"` | |
| // 'head -n 80 /dev/urandom | tr -dc A-Za-z0-9 | head -c 168' | |
| // `tr -dc a-zA-Z0-9 < /dev/urandom | fold -w 128 | head -n 1` | |
| // `ls ~/` | |
| ) |