Skip to content

Instantly share code, notes, and snippets.

Avatar
💩
俺ら生きてて良いすかお偉いさ〜ん?

Shouichi Kamiya shouichi

💩
俺ら生きてて良いすかお偉いさ〜ん?
View GitHub Profile
View Locales.yml
# 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"
View generate_token_for.rb
#!/usr/bin/env ruby
require 'securerandom'
# Example
# class User
# include GenerateTokenFor[:confirmation_token]
# end
#
# @user = User.new
View s3.rb
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
View async_request_with_rails_and_thin.rb
class PagesController < ApplicationController
def async
EM.defer do
env['async.callback'].call [200, {}, ['Hello from callback.']]
end
throw :async
end
end
View .gitignore
/.bundle
/db/*.sqlite3
/doc
/log
/public/assets
/tmp
/vendor/assets/components
View create_accounts.sql
-- 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');
View .gitignore
/docs
/target
/lib
/classes
/checkouts
pom.xml
*.jar
*.class
.lein-deps-sum
.lein-failures
View README.md

EduBaseCloudまとめ

自動ssh

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

# ~/.ssh/config
ServerAliveInterval 60
ControlMaster auto
ControlPath /tmp/%r@%h:%p
View 20151007094937_create_bookmarks.rb
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;