Skip to content

Instantly share code, notes, and snippets.

masahirompp masahirompp

Block or report user

Report or block masahirompp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View fun.js
'use strict';
var _ = window._;
/**
*
* @param thing
*/
function fail(thing) {
throw new Error(thing);
View funjs.ts
/// <reference path="../../../tsd/underscore/underscore.d.ts" />
/**
*
* @param thing
*/
function fail(thing) {
throw new Error(thing);
}
@masahirompp
masahirompp / module1.js
Last active Aug 29, 2015
AMD/namespace template
View module1.js
(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';
// ここに処理を書く
}));
View Makefile
BIN = ./node_modules/.bin
build: install typings
$(BIN)/webpack
watch: install typings
$(BIN)/webpack --watch
install:
@npm install
View menu.jsx
// menu.jsx
var m = require('mithril');
function view(ctrl) {
function redirect(e) {
e.preventDefault();
m.route(e.target.getAttribute('href'));
}
@masahirompp
masahirompp / radios.ts
Created Feb 13, 2016
mithril(msx) radio button sample.
View radios.ts
/**
* ラジオボタンを生成する
* @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 / Cookie.ts
Created Feb 13, 2016
simple cookie util.
View Cookie.ts
@masahirompp
masahirompp / jwt.js
Created Feb 13, 2016
json web token encode / decode sample.
View jwt.js
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
View controller.js
(function(todo) {
'use strict';
// viewの追加イベントを監視。TodoListに新規Todoを追加する。
todo.View.on('add', function(description) {
todo.TodoList.add(new todo.Todo(todo.TodoList.length, description));
todo.View.clearInput();
});
// viewの変更イベントを監視。モデルの状態を更新を命令。
View sample.html
<div class="select">
<select>
<option value="a">AAA</option>
<option value="b">BBB</option>
<option value="c">CCC</option>
</select>
</div>
You can’t perform that action at this time.