Skip to content

Instantly share code, notes, and snippets.

@fxghqc
fxghqc / command_line_modeler.md
Last active December 17, 2015 02:39
MRO建模用Excel文件整理工具
每个类生成一个csv文件,生成空格分割文件更好
csv的“,”转为“Tap”

sed -i "s/,/\t/g" *.generator

合并csv文件到一个新文件

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
//
@fxghqc
fxghqc / typescript_angular.adoc
Last active September 10, 2015 09:52 — forked from esfand/typescript_angular.adoc
AngularJS with TypeScript
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);
@fxghqc
fxghqc / use flow.js in exist react projects
Last active October 26, 2016 12:28
use flow.js in react projects
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 ~/`
)