usermod -a -G sudo USERNAME
or
usermod -a -G admin USERNAME
ActiveRecord::Base.logger.level = Logger::INFO | |
# from http://lexsheehan.blogspot.tw/2013/04/temporarily-disable-executed-sql.html |
## with_indifferent_access | |
1.9.2p290 :018 > h = {:a=>1, "b"=>2, :c=>3} | |
# => {:a=>1, "b"=>2, :c=>3} | |
1.9.2p290 :019 > h = h.with_indifferent_access | |
# => {"a"=>1, "b"=>2, "c"=>3} | |
1.9.2p290 :020 > h["b"] | |
# => 2 | |
1.9.2p290 :021 > h[:b] | |
# => 2 |
# ruby Fixnum# year/month/day | |
class Fixnum | |
def minutes | |
self*60 | |
end | |
def hours | |
self*60*60 | |
end | |
def days |
usermod -a -G sudo USERNAME
or
usermod -a -G admin USERNAME
str.gsub(/<\/?[^>]*>/, "") |
config.time_zone = 'Taipei' # For ActiveRecord (Still UTC in database) | |
ENV['TZ'] = 'Asia/Taipei' # For ruby |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta content="" name="description"> | |
<meta content="" name="keywords"> | |
<meta content="" property="og:image"> | |
<meta content="" property="og:url"> | |
<meta content="" property="og:site_name"> | |
<meta content="" property="og:title"> | |
<meta content="" property="og:type"> |
I posted this gist a few years ago as a quick memo for myself. I never expect this little gist to rank up in top 3 search result and getting so many helpful feedbacks. Since it gets viewed quite often, I decided to revise this post so that it may be a little more helpful. Thank you again for the feedback!
require "json"
class MyJSON
# Ruby build-in | |
require 'benchmark' | |
puts Benchmark.measure { "a"*1_000_000 } # and Benchmark.bm, Benchmark.bmbm | |
# handcrafted | |
def performance | |
t1 = Time.now.to_f | |
yield | |
t2 = Time.now.to_f | |
return t2 - t1 |