This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>fxxk_it_alert</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/usr/bin/osascript</string> | |
| <string>/Users/ozaki/bin/fxxk_it_alert.scpt</string> |
This file contains hidden or 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
| curl -s http://www.ietf.org/rfc/rfc2616.txt | grep -E '^\s+\|?\s+"[0-9]{3}"\s+;' | sed -r 's/^\s+\|?\s+"([0-9]+)"\s+;.+:(.*)$/\1 : \2/g' |
This file contains hidden or 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
| {- GHC 7.4 -} | |
| import System.Environment | |
| import Data.List | |
| main = do args <- getArgs | |
| mapM_ (putStrLn . show) (filterStatus args) | |
| data HttpStatus = HttpStatus { | |
| status::String, message::String} |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| # Usage : | |
| # summarize_sql_log.rb <log_file_name> | |
| # | |
| # Output example: | |
| # | |
| # User Load Count:1408 775.2000 ms | |
| # Blog Load Count:654 434.3000 ms | |
| # Comment Load Count:454 341.0000 ms |
This file contains hidden or 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
| import qualified Data.Map as M | |
| import Data.List.Split | |
| type Field = (String,String) | |
| type Fields = M.Map String String | |
| main = do cs <- getContents | |
| mapM_ showTree' $ parse cs | |
| showTree' :: Fields -> IO() |
This file contains hidden or 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
| class Array | |
| def sliding(n) | |
| self.inject([]){|xs,e| xs.last.tap{|r| r.nil? ? xs << [e] : if r.length < n then r << e else xs << r.dup.tap{|_| _.shift ; _ << e } end }; xs} | |
| end | |
| end | |
| [42] pry(main)> arr = (1..10).to_a | |
| [43] pry(main)> arr.sliding(3) | |
| [ |
This file contains hidden or 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
| # AttrInquirable | |
| # wraps value of attribute in ActiveSupport::StringInquirer. | |
| # | |
| # Usage: | |
| # | |
| # class Person < ActiveRecord::Base | |
| # attr_inquireable :status | |
| # end | |
| # | |
| # person = Person.new(:status => :pending) |
This file contains hidden or 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
| 100000.times do raise 'unmatch' unless {'a' => 1, 'b' => 2, 'c' => 3}.to_json == {'a' => 1, 'b' => 2, 'c' => 3}.to_json end |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| # rails r tools/json_bench.rb | |
| require 'rbench' | |
| ar_objects1 = # 適当なActiveRecordオブジェクト一個 | |
| json_str1 = ar_objects1.to_json | |
| ar_objects2 = # 3個ほど子テーブルをincludeさせたActiveRecordオブジェクトを70個くらいの配列に | |
| json_str2 = ar_objects2.to_json |
This file contains hidden or 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
| module ActiveRecord | |
| module ConnectionAdapters | |
| class PostgreSQLAdapter < AbstractAdapter | |
| def explain(arel, binds = []) | |
| sql = "EXPLAIN ANALYZE #{to_sql(arel, binds)}" | |
| ExplainPrettyPrinter.new.pp(exec_query(sql, 'EXPLAIN', binds)) | |
| end | |
| end | |
| end | |
| end |