Skip to content

Instantly share code, notes, and snippets.

@y-yagi
y-yagi / gist:9067998
Created February 18, 2014 10:09
Gemfile2
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'mysql2'
gem 'active_hash'
gem 'jquery-rails'
gem 'unicorn'
gem 'bcrypt-ruby', '~> 3.0.0', require: 'bcrypt'
gem 'moji'
gem 'kaminari'
@y-yagi
y-yagi / gist:11356420
Last active August 29, 2015 14:00
rails commit log 確認用
#!/usr/bin/env ruby
require 'git'
require 'time'
WORKING_DIR = '/home/yaginuma/program/rails/rails'
BLOG_DIR = '/home/yaginuma/Dropbox/blog/rails-commit-log/'
HEADER = <<EOS
rails commit log流し読み(%s)
#!/bin/bash
LANG=ja_JP.utf8
pid=$$
date=`date '+%Y-%m-%d-%H_%M'`
playerurl=http://radiko.jp/player/swf/player_3.0.0.01.swf
playerfile="/tmp/player.swf"
keyfile="/tmp/authkey.png"
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.deb
sudo dpkg -i elasticsearch-1.1.1.deb
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
jsdom = require 'jsdom'
module.exports = (robot) ->
robot.respond /天気 (.*)$/i, (msg) ->
api_url = 'http://weather.livedoor.com/forecast/rss/warn/'
[area] = [msg.match[1]]
areas = {
北海道 : '01'
青森 : '02', 岩手 : '03', 宮城 : '04', 秋田 : '05', 山形 : '06', 福島 : '07'
@y-yagi
y-yagi / deploy.rb
Created August 11, 2014 06:04 — forked from reu/deploy.rb
# Bundler Integration
require "bundler/capistrano"
# Application Settings
set :application, "yourapplicationname"
set :user, "serveruser"
set :deploy_to, "/home/#{user}/rails-applications/#{application}"
set :rails_env, "production"
set :use_sudo, false
set :keep_releases, 3
desc "Pings PING_URL to keep a dyno alive"
task :dyno_ping do
require "net/http"
if ENV['PING_URL']
uri = URI(ENV['PING_URL'])
Net::HTTP.get_response(uri)
end
end

Testing behavior of a CollectionProxy based on :dependent option, delete method used and assocation type (:has_many vs :has_many :through)

:has_many association

class Category < ActiveRecord::Base
	has_many :contacts, through: :categorizations
	has_many :categorizations, dependent: DEPENDENT
end
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
SANITIZE_ENV_KEYS = [
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225
"HTTP_REFERER",
"PATH_INFO",