Skip to content

Instantly share code, notes, and snippets.

package controllers
import play.api._
import play.api.mvc._
import org.squeryl.PrimitiveTypeMode._
import models.{Database, FrontPageUpdate}
import com.codahale.jerkson.Json
object Application extends Controller {
# Give it two procs to compare
def bm(o, n)
reload!
puts "Running 10 times"
Benchmark.bmbm(10) do |x|
x.report('Old Query:') { @olr = o.call }
x.report('New Query:') { @nr = n.call }
end
reload!
# Scenario:
# We run a youtube production company and we make videos for paying members.
# Paying members can likewise access paid for premium content, and guests can access free content.
# Pretty straight forward.
#
# Next Scenario:
# We decide, one day, to open source all of our content. All videos, text posts, tutorials, etc
# are now available to *all* users.
#
# What's the most optimal way to be able to ship such a feature, with all tests passing.
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
@dhoss
dhoss / dhoss.md
Created September 7, 2017 21:52 — forked from perigrin/dhoss.md
@dhoss
dhoss / tweet_dumper.py
Last active June 13, 2019 00:49 — forked from yanofsky/LICENSE
A script to download all of a user's tweets into a csv
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
import sys
#Twitter API credentials
consumer_key = ""
consumer_secret = ""