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
ary= [] | |
30.times do |i| | |
ary << {a:1,b:2,c:3,d:4,e:5,f:6,g:7,h:8} | |
end | |
Benchmark.bmbm do |x| | |
x.report("hash as key") do | |
hash = {} | |
ary.each do|a| hash[a] = 1 end |
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' | |
iterations = 100_000 | |
def a(*args) | |
args.size | |
end | |
def b(args) | |
args.size |
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
# for x264 | |
./configure --enable-static \ | |
--disable-opencl \ | |
--disable-avs \ | |
--disable-cli \ | |
--disable-ffms \ | |
--disable-gpac \ | |
--disable-lavf \ | |
--disable-swscale \ | |
--prefix=/usr/local/ |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://ogp.me/ns/fb#"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>1999</title> | |
</head> | |
<body> | |
<br><br><br> | |
text before | |
<p> |
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
<table class="calendar"><thead><tr><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th></tr></thead><tbody><tr><td class="day past current-month wday-1">09/01 | |
</td><td class="day past current-month wday-2">09/02 | |
</td><td class="day today current-month wday-3"><a href="">09/03</a> | |
</td><td class="day future current-month wday-4">09/04 | |
</td><td class="day future current-month wday-5">09/05 | |
</td><td class="day future current-month wday-6">09/06 | |
</td><td class="day future current-month wday-0">09/07 | |
</td></tr><tr><td class="day future current-month wday-1">09/08 | |
</td><td class="day future current-month wday-2">09/09 | |
</td><td class="day future current-month wday-3">09/10 |
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 'uri' | |
require 'net/http' | |
class RedirectResolver | |
def self.resolve(uri) | |
uri_input = uri | |
if uri.is_a? String | |
uri = URI.parse(uri) | |
end |
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
# in OrdersController | |
def payment_notify | |
l = PaymentNotification.new | |
l.order_id = params[:id] | |
l.payment_method_id = params[:payment_method_id] | |
l.url = request.fullpath | |
l.raw_post = request.raw_post | |
l.data = {remote_ip:request.remote_ip} |
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
module Global | |
def self.add_attribute(name) | |
value = yield.freeze | |
self.define_singleton_method(name) do | |
value | |
end | |
end | |
end | |
Global.add_attribute(:topic_api_markdown_renderer){ |
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
# insdie model | |
def write_attribute(attr_name, value) | |
super | |
# Association assignment take effect after super | |
case attr_name | |
when 'admin_editing' | |
pp "Inside write_attribute: #{self.admin_editing}" | |
end | |
end |
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
def foo(role) | |
if !teacher?(role) | |
... | |
def teacher?(role) | |
role == :teacher |