Skip to content

Instantly share code, notes, and snippets.

@masahirompp
masahirompp / jwt.js
Created February 13, 2016 17:05
json web token encode / decode sample.
import * as _ from 'underscore';
import * as moment from 'moment';
import * as jwt from 'jwt-simple';
import * as config from 'config';
import * as Log from './Log';
/**
* エンコードする
* 有効期限を付与する
* @param data
@masahirompp
masahirompp / Cookie.ts
Created February 13, 2016 17:00
simple cookie util.
@masahirompp
masahirompp / radios.ts
Created February 13, 2016 16:55
mithril(msx) radio button sample.
/**
* ラジオボタンを生成する
* @param {[type]} args: {value: string; label: string }[] [description]
* @param {[type]} name: string [description]
* @param {[type]} currentValue: string [description]
* @param {[type]} callback: (value:string)=>void [description]
* @return {[type]} [description]
*/
export function radios(args: { value: string; label: string }[], name: string, currentValue: string, callback: (value: string) => void) {
if (args.length === 0) {
@masahirompp
masahirompp / menu.jsx
Created August 1, 2015 10:45
menu.jsx
// menu.jsx
var m = require('mithril');
function view(ctrl) {
function redirect(e) {
e.preventDefault();
m.route(e.target.getAttribute('href'));
}
@masahirompp
masahirompp / Makefile
Last active August 29, 2015 14:17
makefile
BIN = ./node_modules/.bin
build: install typings
$(BIN)/webpack
watch: install typings
$(BIN)/webpack --watch
install:
@npm install
@masahirompp
masahirompp / module1.js
Last active August 29, 2015 14:15
AMD/namespace template
(function(factory){
if(typeof define === 'function' && define.amd){
define(['underscore', 'other1'], factory.bind(this));
}else{
this.module1 = factory.call(this, this._, this.other1);
}
}.call(this, function(_, other1){
'use strict';
// ここに処理を書く
}));
/// <reference path="../../../tsd/underscore/underscore.d.ts" />
/**
*
* @param thing
*/
function fail(thing) {
throw new Error(thing);
}
@masahirompp
masahirompp / fun.js
Created February 4, 2015 15:27
utils
'use strict';
var _ = window._;
/**
*
* @param thing
*/
function fail(thing) {
throw new Error(thing);