Skip to content

Instantly share code, notes, and snippets.

View cameronmaske's full-sized avatar

Cameron Maske cameronmaske

View GitHub Profile
@cameronmaske
cameronmaske / encode.py
Last active February 5, 2024 19:16
base64 that actually encodes URL safe (no '=' nonsense)
"""
base64's `urlsafe_b64encode` uses '=' as padding.
These are not URL safe when used in URL paramaters.
Functions below work around this to strip/add back in padding.
See:
https://docs.python.org/2/library/base64.html
https://mail.python.org/pipermail/python-bugs-list/2007-February/037195.html
"""
@cameronmaske
cameronmaske / README.md
Last active August 10, 2018 13:15
How to use CircleCI's docker executor instead of machine for a Docker Compose project

Docker Compose workarounds with CircleCI's docker executor.

Here is an example configuration with the work arounds listed below.

If you need to build Docker images (which our project does) you have to tell Circle to set up a remote docker environment to execute any docker commands. This isn't necessarily complex to add your configuration, it's a simple one-line addition.

However, it is not possible to mount folders (i.e the volumes key in Docker Compose) for containers run by the remote docker instance.

This means you either to set up a separate docker-compose.yml, without volumes and in your Dockerfile, make sure to ADD any folders/code that you need available to run your tests.

@cameronmaske
cameronmaske / pre-commit
Created April 3, 2018 20:51
Yapf + Isort Git Hook Pre-commit Script
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
### Keybase proof
I hereby claim:
* I am cameronmaske on github.
* I am cameronmaske (https://keybase.io/cameronmaske) on keybase.
* I have a public key whose fingerprint is E996 07E8 8E22 59A6 4844 71D8 5609 7552 9ACD 557B
To claim this, I am signing this object:
@cameronmaske
cameronmaske / DNS Local.md
Last active June 3, 2017 21:44
Setting up Docker DNS for local dev

After setting up your docker machine, change the dns opts to look for a locally running DNS server...

docker-machine ssh
sudo vi /var/lib/boot2docker/profile
# Then add the following...
EXTRA_ARGS='
--label provider=virtualbox
--dns 172.17.0.1
--dns-search dev
# encoding: utf-8
from __future__ import unicode_literals
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.ui import Select
class Scraper():
def __init__(self):
@cameronmaske
cameronmaske / shoe.mm
Created May 15, 2016 17:12
Python vs Objective C
NSArray *shoeOrder = @[@"Charles Smith", @(9.5), @"loafer", @"brown"];
NSMutableDictionary *shoeOrderDict = [[NSMutableDictionary alloc] init];
[shoeOrderDict setObject:[shoeOrder objectAtIndex:0] forKey:@"customer"];
[shoeOrderDict setObject:[shoeOrder objectAtIndex:1] forKey:@"size"];
[shoeOrderDict setObject:[shoeOrder objectAtIndex:2] forKey:@"style"];
[shoeOrderDict setObject:[shoeOrder objectAtIndex:3] forKey:@"color"];
@cameronmaske
cameronmaske / celery-monitor.py
Created October 27, 2014 02:55
Monitor celery queue backlog and concurrency with Librarto.
from myproject.config import celery_app # Change this.
import requests
import librato
import time
import os
LIBRATO_USERNAME = ""
LIBRATO_API_TOKEN = ""
RABBIT_MQ_API_URL "http://localhost:15672/api/"
RABBIT_MQ_USERNAME = ""
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];

Contributing a new backend.

Contributing a new locking backend is greatly appreciated! Each new backend must implement the following methods...

class Backend(object):
    """
    Each new backend must implement the following methods,
    - __init__