Skip to content

Instantly share code, notes, and snippets.

View joker1007's full-sized avatar

Tomohiro Hashidate joker1007

View GitHub Profile
--- cmdline-fu 2011-01-18 12:07:51.000000000 +0900
+++ proxy/cmdline-fu 2011-01-18 12:04:02.000000000 +0900
@@ -21,6 +21,7 @@
class CommandLineFu
API_URL = 'http://www.commandlinefu.com/commands'
+ PROXY_HOST, PROXY_PORT = (ENV["HTTP_PROXY"] || '').sub(/http:\/\//, '').split(':')
# attr_reader :api_url
# wrong argument type JSON::Pure::Generator::State (expected Data)対策
class Fixnum
def to_json(options = nil)
to_s
end
end
# vi:ft=ruby
@joker1007
joker1007 / install_gitorious.sh
Created June 23, 2011 03:04 — forked from lanius/install_gitorious.sh
Gitorious Installation to Ubuntu Server 10.04
# Gitorious Installation to Ubuntu Server 10.04
# from gitorious mainline:
# commit e2e70edd42ac1c00dab518d61d566ee3fec929db
# Author: Marius Mathiesen <marius@gitorious.org>
# Date: Wed Apr 13 11:43:07 2011 +0200
: << '#COMMENT_OUT'
Ubuntu Server 10.04 に Gitorious をインストールしたときのメモ。
class MyParser
def self.parse(thing, url = nil, encoding = nil,
options = Nokogiri::XML::ParseOptions::DEFAULT_HTML, &block)
thing=NKF.nkf("-wm0E", thing).sub(/euc-jp/, "utf-8")
Nokogiri::HTML::Document.parse(thing, url, encoding, options, &block)
end
end
# vim:ft=ruby
#!/bin/zsh
rvm_path=/home/joker/.rvm
source /home/joker/.rvm/scripts/rvm
rvm use ruby-1.9.2-p290
cd /home/joker/mctiwt
/usr/bin/env ruby bot.rb
source 'http://rubygems.org'
gem "rspec"
gem "factory_girl"
gem "i18n"
gem "guard"
gem "guard-rspec"
if RUBY_PLATFORM.downcase.include?("darwin")
gem "rb-fsevent"
require "rubygems"
require "rspec"
require "factory_girl"
RSpec.configure do |config|
end
Dir.glob(File.join(File.dirname(__FILE__), "factories", "*.rb")).each do |f|
load(f)
end
check process unicorn with pidfile "/var/www/rails_apps/pasokara_player/shared/pids/unicorn.pid"
start program = "/bin/su - joker bash -c '. /home/joker/.rvm/scripts/rvm; cd /var/www/rails_apps/pasokara_player/current; bundle exec unicorn_rails -D -E production -p 8000'"
with timeout 20 seconds
stop program = "/bin/su - joker bash -c '/bin/kill -QUIT `/bin/cat /var/www/rails_apps/pasokara_player/shared/pids/unicorn.pid`'"
if totalmem > 500 MB for 2 cycles
then exec "/bin/kill -HUP `/bin/cat /var/www/rails_apps/pasokara_player/shared/pids/unicorn.pid`"
if 2 restarts within 3 cycles then timeout
if cpu usage > 95% for 3 cycles then restart
# vim:ft=monitrc
require "shellwords"
require "open3"
module FFmpegInfo
FFMPEG = `which ffmpeg`.chop
def self.getinfo(input)
video = {}
audio = {}
duration = 0