Skip to content

Instantly share code, notes, and snippets.

@mosson
mosson / middleware.js
Created January 24, 2017 01:55
middleware pattern practice.
function requestIDMiddleware(next, params) {
var requestID = 'hogehoge';
if(next) next({
requestID: requestID
});
}
function sessionMiddleware(next, params) {
var session = {
@mosson
mosson / example_app.rb
Created April 5, 2016 09:23
example oauth2
# encoding: utf-8
require 'rubygems'
require 'bundler/setup'
require 'oauth2'
require 'sinatra'
require 'faraday'
OAuth2::Response.register_parser(:text, 'text/plain') do |body|
'use strict';
import request from 'superagent';
import _ from 'lodash';
import URL from 'url';
import Promise from 'bluebird';
const global = Function("return this")();
'use strict';
import Subject from 'models/BaseModel';
import assert from 'assert';
import sinon from 'sinon';
import _ from 'lodash';
'use strict';
import _ from 'lodash';
import Request from 'superagent';
import Promise from 'bluebird';
class I18n {
load(path) {
return new Promise((f, r) => {
Request
'use strict';
import _ from 'lodash';
import is from 'is_js';
import { parseIntOrNull } from 'services/NumberUtils';
class BaseModel {
static hasMany(name, targetClass, defaultID) {
/* eslint complexity: [0, 6] */
if (!this.prototype[`_get_${name}`]) {
@mosson
mosson / 0_reuse_code.js
Created October 27, 2015 09:51 — forked from kenjiokabe/0_reuse_code.js
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
ssh [host]
cd ~
mkdir -p ws
cd ws
wget --no-check-certificate --page-requisites --convert-links [host][path][page].html # .htmlでredirectをさける
cd [host][path]
mv [page].html [documentRoot][path]/
cd [documentRoot][path]
# ここでブラウザで確認
# -*- coding: utf-8 -*-
require 'fluent-logger'
require 'active_support/core_ext'
module CreativeSurvey
class FluentLogger < ::Logger
attr_reader :config_file
def initialize(config_file = Rails.root.join('config', 'fluent-logger.yml.erb'), device = nil)
@config_file = config_file
@mosson
mosson / my_fluent_logger.rb
Last active August 29, 2015 14:17
こんな感じかな
# -*- coding: utf-8 -*-
require 'fluent-logger'
require 'active_support/core_ext'
require 'forwardable'
module Mosson
module FluentLogger
module ModuleMethods
def new(file = Rails.root.join("config", "fluent-logger.yml.erb"))
ActiveSupport::TaggedLogging.new(logger(file))