Skip to content

Instantly share code, notes, and snippets.

Index: vendor/plugins/exception_logger/lib/exception_loggable.rb
===================================================================
--- vendor/plugins/exception_logger/lib/exception_loggable.rb (revision 2600)
+++ vendor/plugins/exception_logger/lib/exception_loggable.rb (working copy)
@@ -29,9 +29,18 @@
:exc_date => "%b %d, %Y",
:exc_time => "%l:%M %p"
})
+
+ target.class_eval do
#!/usr/bin/ruby
require 'rubygems'
require 'em-http-request'
urls = %w(
http://www.livedoor.com/
http://www.dena.jp/
http://mixi.jp/
http://www.gaiax.co.jp/
require 'tempfile'
def tempwrite
f = Tempfile.new('temp')
f.puts 'nihanihanihanihatorigairu'
f.close
return f.path
end
path = tempwrite
require 'tempfile'
def tempwrite
f = Tempfile.new('temp')
f.puts 'nihanihanihanihatorigairu'
f.close
return f
end
temp = tempwrite
# from Ruby技術者認定試験公式ガイド pp169
even_number = 101 % 2 == 0
if even_number == true
p "偶数"
elsif
p "奇数"
end
# 上のプログラムは下と同じ
even_number = 101 % 2 == 0
CFUNC_FRAME_USAGE_CHECK: start
??#core#define_method 0 262
Class#new 0 32892
??#core#define_singleton_metho 0 125
Array#each 4 41
Kernel#require 1 3
Module#private 11 0
??#require 0 2
Kernel#methods 1 0
Module#=== 1398 0
@nuna
nuna / cfunc survey02
Created October 19, 2010 00:24
using active_record/sqlite3 gem, due to the apache log analysis, LOC95
CFUNC_FRAME_USAGE_CHECK: start
??#core#define_method 0 2862
Class#new 0 129760932
??#core#define_singleton_metho 0 504
Array#each 33076237 7633579
Kernel#require 1 3
Module#private 164 0
??#require 0 2
Kernel#methods 2 0
Module#=== 50888085 0
module Rack #:nodoc:
class ForceEscapeSingleQuoteInHTMLAttribute
def initialize(app, options = {})
@app = app
end
def call(env)
status, headers, response = @app.call(env)
if headers['Content-Type'] =~ %r!text/html|application/xhtml\+xml!
body = build_response_body(response)
@nuna
nuna / insert.rb
Created December 22, 2010 01:39
insert apache log to mongodb
#!/usr/bin/ruby19
# -*- coding: utf-8 -*-
require 'apachelogregex'
require 'uri'
require 'mongo'
format = '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{Cookie}i\"'
parser = ApacheLogRegex.new(format)
@nuna
nuna / summize-traffic.rb
Created December 22, 2010 01:42
Calculate bytes of the traffic of each domain using mongodb map/reduce.
#!/usr/bin/ruby19
# -*- coding: utf-8 -*-
require 'mongo'
connection = Mongo::Connection.new
db = connection.db('apache-log')
logs = db.collection('log')
map =<<'_FUNC_'