Skip to content

Instantly share code, notes, and snippets.

View darktef's full-sized avatar
🐳
Hacking

Lin Yang darktef

🐳
Hacking
View GitHub Profile
@darktef
darktef / benchmark.rb
Created February 20, 2019 14:09
RoR - benchmark ActiveRecord Query
require 'benchmark'
n = 5 # Use any n you like
Benchmark.bmbm do |x|
x.report("find by") {
n.times { User.find_by_name("Joe").id }
}
x.report("select") {
n.times { User.find(:first, :select => :id, :conditions => ["name = ?","Joe"]).id }
}
@darktef
darktef / run_rake_tasks_console.md
Created February 21, 2019 20:51
RoR - How to run rake tasks from console
@darktef
darktef / get-all-az.bash
Created August 16, 2022 15:17
AWS - Get all AZs for the subnet
typeset -A newmap
newmap[111111111111]="IAD-Alpha"
newmap[222222222222]="IAD-Beta"
# echo ${newmap[111111111111]}
# for key ("${(@k)newmap}") printf 'key=%s value=%s\n' "$key" "$newmap[$key]"
for key ("${(@k)newmap}")