Skip to content

Instantly share code, notes, and snippets.

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",

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
import com.android.volley.toolbox.HurlStack;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* An {@link com.android.volley.toolbox.HttpStack HttpStack} implementation which
* uses OkHttp as its transport.
*/
@y-yagi
y-yagi / gist:cec784b99b56a226e60d
Created November 9, 2014 06:40
TracePoint study
require 'minitest'
require "minitest/autorun"
require 'power_p'
require 'ripper'
trace = TracePoint.new(:raise) do |tp|
if tp.raised_exception.class == Minitest::Assertion
file, lineno = tp.raised_exception.location.split(':')
line = open(file).each_line.drop(lineno.to_i - 1).first
idents = Ripper.sexp(line)
# todos_controller.rb
class TodosController < ApplicationController
respond_to :html, :json, :xml
end
# application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
rescue_from ActionView::MissingTemplate, with: :check_respond_error
@y-yagi
y-yagi / gist:6962c53da74355226e7c
Last active August 29, 2015 14:10
warnメッセージを出力している箇所を調べる
trace = TracePoint.new(:c_call) do |tp|
if tp.method_id == :warn
print tp.binding.eval('caller_locations').join("\n")
end
end
trace.enable