Skip to content

Instantly share code, notes, and snippets.

# BufferedLogger format patch.
# Install into config/initializer/buffered_logger_format.rb
#
# - https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1307-bufferedlogger-should-support-message-formatting
# - http://saikyoline.jp/weblog/2008/07/01/013418.html
# - http://github.com/moro/logger_exception_format/tree/master
module ActiveSupport
class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
@koseki
koseki / gist:136631
Created June 26, 2009 18:04
WordPress Client using WWW::Mechanize
require "rubygems"
require "www/mechanize"
# WordPress Client using WWW::Mechanize.
class WpClient
attr_accessor :m
def initialize(baseurl)
@base = baseurl
@base = @base[0..-2] if @base[-1] == ?/
@koseki
koseki / lscron
Created July 17, 2009 08:44
list all cron jobs.
#! /bin/sh
cat /var/spool/cron/* /etc/crontab | grep '^\(\*\|[0-9]\)' | sort -nk2 -nk1
@koseki
koseki / wp_client.rb
Created July 20, 2009 17:50
super easy wordpress client.
require "rubygems"
require "www/mechanize"
class WpClient
attr_accessor :m
def initialize(baseurl, opts = {})
@base = baseurl
@base = @base[0..-2] if @base[-1] == ?/
@opts = opts
#! /usr/bin/env ruby
require "open-uri"
# o080701 NG
# w070615 OK
# w081105 OK
# ruby/ruby
appk = "T-PmFVHrGFvAVN1ipcVEMS2srfoMHuiOWKgW-JV3wqg4.4XU2lHAW8.P67Q.GE70F1Cmix44tSDfrswTh-XQiIa4vKoo6J0r2QRxNK8LMXrnAE158hxE1Yf6LUN10.blID2dNEtfRGmDeTKMWW04Gfx90H.HA3lf.d30Ch56w0g3SKZVN0BpYz.deQVWaKKqefBo5k6nMn6kOpPVX.LGO6BUHDFCHa2Fr1qTD3Gs86DlfflgG.fY7aIciOgH.dJMFVY0ijb9fAe0u78YqcRCNfLxW.Pq7xp5Ifk49TG1CRmw6zOfI2B8bbP-fnI3rpXTrhM.5o9L7GQaj46aTf1R6Q__,cnVieQ__,cnVieQ__"
@koseki
koseki / http_request.rb
Created September 3, 2009 08:31
Simple HTTP request
require 'net/http'
require 'uri'
# Simple HTTP request
#
# See also:
# http://addressable.rubyforge.org/
# http://dev.ctor.org/http-access2
#
def http_request(method, uri, query_hash = {}, user = nil, pass = nil)
@koseki
koseki / 000-start.sh
Created September 14, 2009 12:37
Apache Module Test Env Setup Script (for EC2 ami-e048af89)
#! /bin/sh
# ----------------------------------------------------------------
# Amazon EC2 ami-e048af89 (debian 6.0 squeeze)
# ----------------------------------------------------------------
# install git and rake.
apt-get update
apt-get -y install libidn11-dev
apt-get -y install git-core
#! /usr/bin/ruby
require 'benchmark'
require 'yaml'
open("data1.txt", "w") do |io|
5000.times do |i|
io << "abcdefghijklmnopqrstuvwxyz\t#{i}\n"
end
end
@koseki
koseki / red_cloth_helper.rb
Created November 13, 2009 12:41
SmallCage textile sample.
module SmallCage
module RedClothHelper
require "redcloth"
def render_textile(str)
RedCloth.new(str).to_html
end
end
end
@koseki
koseki / default.rhtml
Created November 13, 2009 12:57
SmallCage menu activate sample 1
<html>
<head>
<style type="text/css">
.selected { font-weight: bold; color: red; background-color: yellow; }
</style>
</head>
<body>
<%= menu %>
<%= body %>