Skip to content

Instantly share code, notes, and snippets.

View shouichi's full-sized avatar

Shouichi Kamiya shouichi

  • Tokyo
  • 10:28 (UTC +09:00)
View GitHub Profile
null
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
#!/usr/bin/env ruby
require 'securerandom'
# Example
# class User
# include GenerateTokenFor[:confirmation_token]
# end
#
# @user = User.new
@shouichi
shouichi / s3.rb
Last active December 15, 2015 16:39
module Utils
module S3
# Example
# Utils::S3::Bucket.all_objects_in('images')
module Bucket
class << self
def all_objects_in(bucket_name)
all_objects_from_marker(bucket_name, nil)
end
class PagesController < ApplicationController
def async
EM.defer do
env['async.callback'].call [200, {}, ['Hello from callback.']]
end
throw :async
end
end
/.bundle
/db/*.sqlite3
/doc
/log
/public/assets
/tmp
/vendor/assets/components
-- MySQL port of "Sharding & IDs at Instagram"
-- http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram
CREATE TABLE account_id_seq (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
stub CHAR(1) NOT NULL,
UNIQUE KEY stub (stub)
);
INSERT INTO account_id_seq (stub) VALUES ('a');
/docs
/target
/lib
/classes
/checkouts
pom.xml
*.jar
*.class
.lein-deps-sum
.lein-failures

EduBaseCloudまとめ

自動ssh

60秒毎にpingする。更にsshしてたら/tmpにファイルを作る。

# ~/.ssh/config
ServerAliveInterval 60
ControlMaster auto

ControlPath /tmp/%r@%h:%p

class CreateBookmarks < ActiveRecord::Migration
def up
execute <<-SQL
CREATE SEQUENCE bookmarks_id_seq;
CREATE FUNCTION next_bookmark_id(OUT result bigint) AS $$
DECLARE
epoch bigint := 1420070400000;
seq_id bigint;
now bigint;