Skip to content

Instantly share code, notes, and snippets.

@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 = ""
@dhoss
dhoss / dhoss.md
Created September 7, 2017 21:52 — forked from perigrin/dhoss.md
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,
# 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.
# 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!
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 {
@dhoss
dhoss / yui.coffee
Created December 29, 2012 18:49 — forked from okuryu/yui.coffee
$ node yui.js
info: (yui): Modules missing: io, 1
info: (yui): Fetching loader: /usr/local/lib/node/.npm/yui3-core/3.3.0/package/build/loader/loader-debug.js
info: (get): URL: /usr/local/lib/node/.npm/yui3-core/3.3.0/package/build/loader/loader-debug.js
info: (get): Loaded: /usr/local/lib/node/.npm/yui3-core/3.3.0/package/build/loader/loader-debug.js
info: (yui): Modules missing: oop,parallel,event-custom-base,nodejs-dom,event-base,dom,node-base,dom-style-ie,node-style,queue-promote,datatype-xml,io,io-nodejs, 13
info: (yui): Using Loader
info: (loader): attempting to load oop, /usr/local/lib/node/.npm/yui3-core/3.3.0/package/build/
info: (get): URL: /usr/local/lib/node/.npm/yui3-core/3.3.0/package/build/oop/oop-min.js
info: (get): Loaded: /usr/local/lib/node/.npm/yui3-core/3.3.0/package/build/oop/oop-min.js
@dhoss
dhoss / gist:3164457
Created July 23, 2012 16:11 — forked from anonymous/gist:2523336
Changing author info
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "your@email.to.match" ]
@dhoss
dhoss / macros.tt
Created May 29, 2012 17:40 — forked from jshirley/macros.tt
Bootstrap Form Macros. Use these in combination with Twitter Bootstrap CSS, Catalyst::Plugin::MessageStack and Data::Manager
[%~
# Some illustrious documentation to get you started:
#
# The macros defined are to generate markup to save people from copy and pasting
# markup. They copy and paste hashes instead, which should be safer (in theory)
#
# The macros for forms are:
# * text_field - A simple text field, pass in type to override input type
# * password_field - A password field, equivalent to
# text_field({ type => 'password', ... })
@dhoss
dhoss / gist:1980554
Created March 5, 2012 19:38 — forked from jshirley/gist:1973907
Managing start_server with start-stop-daemon and graceful restarting.
#!/bin/bash
PORT=5000
# This should be the directory name/app name
APP="TDP"
PIDFILE="$HOME/$APP.pid"
STATUS="$HOME/$APP.status"
# The actual path on disk to the application.
APP_HOME="$HOME/$APP"