View twitter_get_lists.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'twitter' | |
require 'oauth' | |
require 'time' | |
# Twitter UserName | |
USER_NAME = "foo" | |
# Consumer key, Secretの設定 | |
CONSUMER_KEY = "XXXXXXXXXXXXXXXXXXXX" | |
CONSUMER_SECRET = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
View twitter_get_list_members.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'twitter' | |
require 'oauth' | |
require 'time' | |
# Twitter UserName | |
USER_NAME = "foo" | |
# Consumer key, Secret の設定 | |
CONSUMER_KEY = "XXXXXXXXXXXXXXXXXXXX" | |
CONSUMER_SECRET = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
View test_mecab.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
require 'MeCab' | |
sentence = "太郎はこの本を二郎を見た女性に渡した。" | |
begin | |
c = MeCab::Tagger.new | |
n = c.parseToNode(sentence) | |
while n do | |
print n.surface, "\t", n.feature, "\t", n.cost, "\n" | |
n = n.next |
View unicorn.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ワーカーの数 | |
worker_processes 2 | |
# RAILS_ROOT を指定 | |
working_directory "/var/www/rails/rails_app/" | |
# ソケット | |
listen "/var/www/rails/rails_app/tmp/sockets/unicorn.sock" | |
# PID |
View unicorn_rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME="Unicorn" | |
ENV=production | |
ROOT_DIR="/var/www/rails/rails_app" | |
PID="${ROOT_DIR}/tmp/pids/unicorn.pid" | |
CONF="${ROOT_DIR}/config/unicorn.rb" | |
OPTIONS="--path /rails_app" |
View nanoc_helper_pager.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Previous(Older) article | |
def prev_link | |
prv = sorted_articles.index(@item) + 1 | |
unless articles.size - 1 < prv | |
link_to( | |
'«[Older] ' + sorted_articles[prv][:title], | |
sorted_articles[prv].reps[0], | |
:class => "prev" | |
) | |
end |
View archive_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# | |
# Jekyll monthly arvchive page generator. | |
module Jekyll | |
class ArchiveIndex < Page | |
def initialize(site, base, dir, period, posts) | |
@site = site | |
@base = base | |
@dir = dir | |
@name = 'index.html' |
View month_list.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# | |
# Month List for Octopress | |
module Jekyll | |
class MonthList < Liquid::Tag | |
def initialize(tag_name, markup, tokens) | |
@opts = {} | |
if markup.strip =~ /\s*counter:(\w+)/i | |
@opts['counter'] = ($1 == 'true') | |
markup = markup.strip.sub(/counter:\w+/i,'') |
View benchmark.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
# 階乗を普通に計算 | |
def fact_1(n) | |
f = 1 | |
n == 0 ? f : (1..n).each {|i| f = f * i} | |
end | |
# 階乗を再帰的に計算 | |
def fact_2(n) |
OlderNewer