Skip to content

Instantly share code, notes, and snippets.

@maxy
maxy / gist:9edb5f84df47abc998a4c1ab404645f4
Created October 21, 2020 23:45 — forked from isseium/gist:5822504
rspec の include で hash 構造をチェックするテスト
describe "Rspec include test" do
it "include" do
hash = {:a => 'A', :b => 'B', :c => { :ca => 'CA' }}
expect(hash).to include(:c => {:ca => 'CA'}); #
expect(hash).to include(:a => 'A', :c => {:ca => 'CA'}); # ならべてもいいっぽい
expect(hash).to_not include(:ca => 'CA'); # ちゃんと構造みてくれる
expect(hash).to include(:a); # キーだけでもOK
expect(hash).to_not include(:d); # キーだけでもOK
end
end
@maxy
maxy / golang_job_queue.md
Created February 22, 2018 14:37 — forked from harlow/golang_job_queue.md
Job queues in Golang
@maxy
maxy / install.sh
Last active August 29, 2015 14:14
Installing RaspbianOS of Raspberry-Pi to SD card
## Confirmation of the SD card mount state
diskutil list
#/dev/disk0
#
# SSD INFORMATION --
#
#/dev/disk2
# #: TYPE NAME SIZE IDENTIFIER
# 0: FDisk_partition_scheme *31.7 GB disk2
# 1: Windows_FAT_32 NO NAME 31.7 GB disk2s1
@maxy
maxy / database.yml
Created September 19, 2014 02:29
database.ymlをERBでテンプレート解析後、設定ファイルを読み込む
development:
adapter: postgres
database: DATABASE_NAME
pool: 5
timeout: 5000
username: <%= ENV['PG_USER'] || 'postgres' %>
password: <%= ENV['PG_PASSWORD'] || '' %>
host: <%= ENV['PG_HOST'] || 'localhost' %>
port: <%= ENV['PG_PORT'] || 5432 %>
encoding: utf8
@maxy
maxy / engine.rb
Last active August 29, 2015 14:06
Rails Engine モジュールのマイグレーションをRailsアプリケーションに統合する
module EngineModule # Engineモジュール名を設定
class Engine < ::Rails::Engine
isolate_namespace EngineModule # Engineモジュール名を設定
initializer :append_migrations do |app|
unless app.root.to_s.match root.to_s
config.paths['db/migrate'].expanded.each do |expanded_path|
app.config.paths['db/migrate'] << expanded_path
end
end
@maxy
maxy / http_server.rb
Last active August 29, 2015 14:05
Simple HTTP Server.
#!/usr/bin/env ruby
require 'webrick'
server = WEBrick::HTTPServer.new Port: 8888, DocumentRoot: Dir::pwd
trap(:INT){server.shutdown}
server.start
@maxy
maxy / result.rb
Last active August 29, 2015 14:05
とある問題の解答
[1,2,3,4,5,6,7,8,9,10,11,12,13].select{|i|i>=5}.map{|i|i.to_s.split ''}.flatten.each{|i| puts i }
@maxy
maxy / Gemfile
Last active August 29, 2015 14:05
Gemfile template.
source 'https://rubygems.org'
gem 'rails'
gem 'sqlite3'
gem 'sidekiq'
gem 'act-fluent-logger-rails'
gem 'sass-rails'
gem 'uglifier'
@maxy
maxy / connection_adapters.rb
Created July 14, 2014 06:07
Set PG::PQERRORS_VERBOSE on pg connection instance for ActiveRecord
module ActiveRecord
module ConnectionAdapters
alias_method :base_configure_connection, :configure_connection
def configure_connection
valiables = base_configure_connection
@connection.set_error_verbosity(PG::PQERRORS_VERBOSE)
valiables
end
end
end
@maxy
maxy / 0_reuse_code.js
Created March 20, 2014 07:59
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