Skip to content

Instantly share code, notes, and snippets.

class BQDatasetAuthorizer(ContextDecorator):
def __init__(self, target, profile_file):
self.target = target
self.profile_file = profile_file
# this dict maps a dataset to a list of BigQuery Access entries defined by code.
# We expect groupByEmail and View.
# https://googleapis.dev/python/bigquery/latest/generated/google.cloud.bigquery.dataset.AccessEntry.html
self.auth_dict = defaultdict(list)
def __enter__(self):
@stujo
stujo / GitHub curl.sh
Last active February 15, 2019 21:39 — forked from Integralist/GitHub curl.sh
Download a single file from a private GitHub repo. You'll need an access token as described in this GitHub Help article: https://help.github.com/articles/creating-an-access-token-for-command-line-use
#!/usr/bin/env bash
TOKEN="INSERTACCESSTOKENHERE"
OWNER="BBC-News"
REPO="responsive-news"
FILE_PATH="scripts/build/tabloid.sh"
FILE="https://api.github.com/repos/$OWNER/$REPO/contents/$FILE_PATH"
curl --header "Authorization: token $TOKEN" \
--header 'Accept: application/vnd.github.v3.raw' \
@stujo
stujo / ab.sh
Created April 3, 2018 18:15 — forked from brentertz/ab.sh
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."
@stujo
stujo / ab.sh
Created April 3, 2018 18:15 — forked from brentertz/ab.sh
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."
@stujo
stujo / install_ruby_env.md
Created April 12, 2016 04:35 — forked from ThinkTankShark/install_ruby_env.md
Setup Terminal - Install Ruby Environment - OS X El Capitan

#Xcode Command Line Tools

Xcode > Preferences > Downloads > Command Line Tools

####Homebrew

# install package manager
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@stujo
stujo / ruby-setup.md
Created April 6, 2016 13:42 — forked from coder-sheep/ruby-setup.md
Instructions for installing Ruby and other development tools for use in intro ruby courses.

#Ruby For Beginners : Setup

Greetings Rubyists:

We hope you are excited to learn Ruby. Before the workshop, we need you to set up your development environment with Ruby and a text editor. Choose one of the three options listed below.

  1. Use an online development portal. This is a simple approach and you can do it from a Mac or Windows. You will be able to practice writing Ruby code without installing anything on your computer. At some future time, you will want to get ruby installed and ruby on your machine, but you don't have to for tonight.
    Instructions: Create an account at cloud9.
  2. Install Ruby, Sublime, and Git for a Mac. Skip this step if you can type $ gem install sinatra in your Terminal and install the sinatra gem without any errors.
  3. Install Ruby, Sublime, and Git for Windows Skip this step if you can type $ gem install sinatra in your Terminal and install the sinatra gem without any error
@stujo
stujo / README.md
Last active August 29, 2015 14:26 — forked from yhordi/README.md
refactored code from my "Applying Object Orientation"

Flexibility

Part of why we want to separate code into separate classes and modules is that it keeps things flexible. For example, let's say that there is no GothamCrimeFigher class and there is only a Human class. If we wanted to include the UtilityBelt module in the human class we would be giving all humans utility belts. While this would be fantastic, it is unnecessary. Therefore, we abstract out the functionality that is not shared across all of humanity into a subclass that we can change as we see fit

Modules vs Classes