Skip to content

Instantly share code, notes, and snippets.

@mosson
mosson / sample.html
Last active August 29, 2015 14:16
iframe内のアンケート完了後に親フレームのページを遷移させるサンプルコード: https://secure.creativesurvey.com/iframe/index.html
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
!(function($, window){
$(document).ready(function(){
$(window).on("message", receiveMessage);
function receiveMessage(event){
// アンケート完了後にメッセージが通知されます
// こちらを拾っていただくことで任意のページに移動可能です
if( event.originalEvent.data == "complete" ){
$ brew install pyenv
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
$ pyenv install 2.7.6
$ pyenv global 2.7.6
@mosson
mosson / nginx_init
Created January 29, 2015 07:03
nginxのサービス起動ファイル
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# config: /etc/sysconfig/nginx
@mosson
mosson / Gemfile
Created January 29, 2015 06:36
古version
source 'https://rubygems.org'
gem 'rails', '3.2.21'
gem 'mysql2', '0.3.11'
gem 'aws-sdk', '1.8.5'
gem 'stripe', '1.10.0'
gem 'gibbon', '1.1.3'
gem 'logan', '0.0.4'
@mosson
mosson / memoize_sample.rb
Created January 27, 2015 12:10
メモ化
class Hoge
class << self
def of(key)
@cache ||= {}
@cache[key] ||= new(key)
end
def dispose
@cache = {}
end
@mosson
mosson / google_drive_sample.rb
Created January 26, 2015 12:17
google_drive gemでrefresh_tokenを使って2回目以降の通信で入力を避ける形のサンプル
require "rubygems"
require "google/api_client"
require 'google_drive'
module CreativeSurvey
module Google
module Authorify
module ModuleMethods
def session
::GoogleDrive.login_with_oauth(refreshed_auth.access_token)
class SomeModel
def some_method
some_method2 'hello'
end
def some_method2(str)
fail TypeError, 'The argument must be String' unless str.is_a? String
true
end
alias_method :some_method3, :some_method2
@mosson
mosson / rescue_return.rb
Created January 13, 2015 09:59
begin...rescue...ensureの戻り値って知ってる?
def hoge
11
fail StandardError
rescue
ensure
33
end
def fuga
@mosson
mosson / 都道府県
Created October 29, 2014 11:10
都道府県
北海道
青森県
岩手県
宮城県
秋田県
山形県
福島県
茨城県
栃木県
群馬県
@mosson
mosson / redis-conf
Created October 22, 2014 02:49
my basic configuration on redis
aemonize yes
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile /var/log/redis.log
databases 16
save 900 1