Skip to content

Instantly share code, notes, and snippets.

View stelcheck's full-sized avatar

Marc Trudel stelcheck

View GitHub Profile
@stelcheck
stelcheck / Post.ts
Created May 24, 2017 00:56
class-validator example
import {validate, Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, Min, Max} from "class-validator";
export class Post {
@Length(10, 20)
title: string;
@Contains("hello")
text: string;
@stelcheck
stelcheck / compile.ts
Last active May 24, 2017 00:07
TypeScript Compiler API
import * as path from 'path'
import * as ts from 'typescript'
const glob = require('glob')
const globPattern = path.join(this.projectPath, 'lib/modules/**/usercommands/*.ts')
const userCommandFiles = glob.sync(globPattern)
// Build a program using the set of root file names in fileNames
const program = ts.createProgram(this.userCommandFiles, {
@stelcheck
stelcheck / package.json
Created April 22, 2017 11:01
An alternative way to document package.json scripts
{
"name": "my-game",
"description": "Super duper",
"version": "0.0.1",
"repository": "...",
"author": "Marc Trudel <mtrudel@...jp>",
"license": "See LICENSE%",
"scripts": {
"help": " echo 'Display help information (this screen)' && npm run",
"mage": " echo 'Run the mage binary' && mage",
@stelcheck
stelcheck / bootstrap.sh
Created April 22, 2017 10:44
MAGE Bootstrap command, final form
npm install mage --bootstrap --prefix my-project
cd my-project
@stelcheck
stelcheck / bootstrap.sh
Created April 22, 2017 10:29
New MAGE Bootstrap command
mkdir my-project
cd my project
npm install mage --bootstrap
@stelcheck
stelcheck / install.sh
Created April 22, 2017 10:14
MAGE Bootstrap command, version 1
npm install mage -- --bootstrap
@stelcheck
stelcheck / bootstrap.js
Last active April 22, 2017 09:59
Extracting NPM command arguments from within an NPM script
var npmArgs = JSON.parse(process.env.npm_config_argv);
if (npmArgs.original.indexOf('--bootstrap') === -1) {
process.exit(0);
}
@stelcheck
stelcheck / nix.sh
Created April 22, 2017 09:51
Previous MAGE Bootstrap command
mkdir my-project
cd my-project
BOOTSTRAP=true npm install mage
@stelcheck
stelcheck / benchmark.js
Last active April 13, 2017 05:38
es-promisify benchmark
const num = process.argv[2]
const promisify = require('es6-promisify');
function someFunction(callback) {
process.nextTick(callback.bind(null, null, new Date()));
}
async function loop(call) {
for (let i = 0; i < num; i+= 1) {
await call()
---
# This file will be used by the different build scripts and tools
# to define outputs and destination
### GitHub repository
# The GitHub repository information will be used when building the
# documentation and pushing releases
###
github:
# User or organization name