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
@masahirompp
masahirompp / Author.ts
Last active Oct 18, 2018
typescript + mongoose
View Author.ts
/// <reference path="../typings/tsd.d.ts" />
import db = require('../db/db');
import IAuthorDocument = require('../db/IAuthorDocument');
class Author {
private _author:IAuthorDocument;
constructor(author:IAuthorDocument) {
this._author = author;
@masahirompp
masahirompp / User.ts
Last active Feb 15, 2019
mongoose + typescript
View User.ts
/// <reference path="../tsd/tsd.d.ts" />
import mongoose = require('mongoose');
import passport = require('passport');
interface IUser extends mongoose.Document {
provider: string;
id: string;
authorId: string;
displayName: string;
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 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 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'));
}
View sample.html
<div class="select">
<select>
<option value="a">AAA</option>
<option value="b">BBB</option>
<option value="c">CCC</option>
</select>
</div>
@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) {
You can’t perform that action at this time.