Skip to content

Instantly share code, notes, and snippets.

View chsh's full-sized avatar
👍
Love your code.

CHIKURA Shinsaku chsh

👍
Love your code.
View GitHub Profile
@chsh
chsh / unicorn-nginx.conf
Created September 24, 2012 14:20
nginx conf for unicorn.
upstream hogehoge_backend {
server unix:/tmp/unicorn-hogehoge.sock;
}
server {
listen 80;
server_name hogehoge.com;
location / {
server_name_in_redirect off;
@chsh
chsh / foo.rb
Created September 27, 2012 11:17
validates polymorphic fields example...
class Foo < ActiveRecord::Base
belongs_to :target, polymorphic: true
# This validation will fail...
# validates :target, uniqueness: true
validates :target_type,
presence: {if: :target_id_present? }
validates :target_id,
presence: {if: :target_type_present? },
@chsh
chsh / Gemfile
Created October 18, 2012 15:37
Gemfile for リブライズ
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
@chsh
chsh / copyright_years.rb
Created December 1, 2012 16:10
Build copyright years

ターミナル実行

ssh-keygen と打ち込む

Generating public/private rsa key pair. Enter file in which to save the key (/Users/chsh/.ssh/id_rsa):

とでてくるのでリターン。

@chsh
chsh / gist:5377201
Created April 13, 2013 05:56
Embed google docs form example.
{% google_form 123... Thanks for your message! %>
@chsh
chsh / run-target.sh
Created April 13, 2013 16:00
Run rails app on server.
#!/bin/bash
export APPT=$1
source /etc/unicorn/$APPT.conf
echo App Target: $APPT
export RUBY_VERSION=ruby-$RUBY_VER
export GEM_HOME=/bundles/$RUBY_VER/ruby/1.9.1
@chsh
chsh / Gemfile
Last active December 16, 2015 04:48
Example to create Podio app item using ruby api.
source "https://rubygems.org"
gem 'podio'
gem 'nokogiri'
@chsh
chsh / crawlquote.rb
Created April 14, 2013 03:22
Embed URL and content like blockquote.
# A Liquid tag for Jekyll sites that allows embedding URL.
#
# Usage: {% crawlquote http://www.google.co.jp/ %}
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
require 'open-uri'
require 'nokogiri'
@chsh
chsh / prex.rb
Created April 16, 2013 08:30
prex('ab_cd') generates %w(ab_cd ab_c abc a_cd a_c ac). It's useful for prefix match without regular expression. :-)
# usage: prex('ab_cd') generates %w(ab_cd ab_c abc a_cd a_c ac).
# It's useful for prefix match without regular expression. :-)
def xpand(array)
first, *others = array
return first if others == []
first.map do |it|
xpand(others).map do |jt|
[it + '_' + jt, it + jt]
end.flatten