- Read every row in the table
- No reading of index. Reading from indexes is also expensive.
-- Order by one indexed column (FAST) | |
newsdesk_production=# explain analyze select * from pressreleases order by published_at DESC limit 100; | |
QUERY PLAN | |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Limit (cost=0.00..249.91 rows=100 width=1207) (actual time=26.070..716.453 rows=100 loops=1) | |
-> Index Scan Backward using pressreleases_published_at_index on pressreleases (cost=0.00..964766.62 rows=386042 width=1207) (actual time=26.067..716.343 rows=100 loops=1) | |
Total runtime: 716.709 ms | |
(3 rows) | |
- Order by two separately indexed columns (SLOW) |
class Article < ActiveRecord::Base | |
validates :title, :body, :presence => true | |
# Note that ActiveRecord ARel from() doesn't appear to accommodate "?" | |
# param placeholder, hence the need for manual parameter sanitization | |
def self.tsearch_query(search_terms, limit = query_limit) | |
words = sanitize(search_terms.scan(/\w+/) * "|") | |
Article.from("articles, to_tsquery('pg_catalog.english', #{words}) as q"). | |
where("tsv @@ q").order("ts_rank_cd(tsv, q) DESC").limit(limit) |
class SessionsController < Devise::SessionsController | |
def create | |
resource = warden.authenticate!(:scope => resource_name, :recall => :failure) | |
return sign_in_and_redirect(resource_name, resource) | |
end | |
def sign_in_and_redirect(resource_or_scope, resource=nil) | |
scope = Devise::Mapping.find_scope!(resource_or_scope) | |
resource ||= resource_or_scope |
I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.
I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real
# ... | |
gem 'carrierwave' | |
gem 'fog', '~> 1.0.0' # Need to specify version, as carrierwave references older (0.9.0) which doesn't allow configuration of Rackspace UK Auth URL |
YARD CHEATSHEET http://yardoc.org
May 2020 - updated fork: https://gist.github.com/phansch/db18a595d2f5f1ef16646af72fe1fb0e
cribbed from http://pastebin.com/xgzeAmBn
Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.
brew update | |
brew versions FORMULA | |
cd `brew --prefix` | |
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions" | |
brew install FORMULA | |
brew switch FORMULA VERSION | |
git checkout -- Library/Formula/FORMULA.rb # reset formula | |
## Example: Using Subversion 1.6.17 | |
# |
As configured in my dotfiles.
start new:
tmux
start new with session name:
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs