Skip to content

Instantly share code, notes, and snippets.

View hrysd's full-sized avatar
🤔
hoi

Hiroshi Yoshida hrysd

🤔
hoi
View GitHub Profile
@hrysd
hrysd / 255.sh
Created April 23, 2012 15:32
Terminalで255色をだす。
for i in {0..255} ; do
printf "¥x1b[38;5;${i}mcolour${i}\n"
done
@hrysd
hrysd / fav.rb
Created April 26, 2012 16:54
RubyでFavoriteしましょう!!
#coding: utf-8
require 'twitter'
Twitter.configure do |config|
config.consumer_key = 'CONSUMER_KEY'
config.consumer_secret = 'CONSUMER_SECRET'
config.oauth_token = 'OAUTH_TOKEN'
config.oauth_token_secret = 'OAUTH_TOKEN_SECRET'
end
@hrysd
hrysd / varidation.rb
Created August 1, 2012 14:32
どっちがいいのかな。
validates_presence_of :name
validates :name, :presence => true
@hrysd
hrysd / iptables
Created August 11, 2012 05:02
debianのiptables設定。
*filter
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allows all outbound traffic
@hrysd
hrysd / unicorn.rb
Created August 19, 2012 09:09
unicorn
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
@hrysd
hrysd / deploy.rb
Created August 21, 2012 05:53
deploy時にLingrに通知をおくる。
require 'open-uri'
require 'digest/sha1'
ROOM = '部屋の id'
ID = 'bot の id'
SECRET = 'bot の secret'
VERIFIER = Digest::SHA1.hexdigest(ID + SECRET)
TEXT = "deployしました"
namespace :notification do
@hrysd
hrysd / entry.erb
Created August 23, 2012 01:56
lokka の entry.erb
<% if @entry.prev %>
<a href="<%= url(@entry.prev.link) %>">prev</a>
<% end %>
<% if @entry.next %>
<a href="<%= url(@entry.next.link) %>">next</a>
<% end %>
#質問した年月日をつかってTimeクラスのインスタンスを作る。
myTime = Time.new(year, month, day)
# 今日の日付を作る
now = Time.new
#今日と聞いた日付の年の差を求める。
age = now.year - myTime.year
@hrysd
hrysd / pull_request.md
Created September 1, 2012 17:46
pull request

pull request しましょう。

基本的な流れ

Github 上で fork する

# git clone repo
# cd repo

作業用のbranch を作り、切り替える(基本的にmasterはいじらない)

# git checkout -b new_feature

なにかをする。

#/Users/hrysd/Sites/project/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~hrysd/project
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>