Skip to content

Instantly share code, notes, and snippets.

View RickyCook's full-sized avatar
🏳️‍🌈

Ricky Cook RickyCook

🏳️‍🌈
View GitHub Profile
@RickyCook
RickyCook / multiprocessing_latency.py
Last active August 29, 2015 14:08
Test the "latency" of different ways to trigger multiprocessing start
"""
Test the "latency" of different ways to trigger multiprocessing start.
This will essentially create a multiprocessing `Process` object and measure the
time from when we tell that process to start processing (not necessarily
`Process.start`) until the time that the process picks up the request to start.
This is done in several ways:
- Without a blocker: the time is recorded, then the `Process.start` method
@RickyCook
RickyCook / rsync.yaml
Created October 27, 2014 05:45
Ansible rsync changed status
# Uses the rsync change summary to figure out how many things changed, and uses that
# to tell Ansible if something changed or not
- name: sync hieradata
shell: rsync --delete -ri "/tmp/repo/hieradata" "/etc/puppet/hieradata" | awk '{print $1}' | grep -vE '..\.\..\.\.\.\.' | wc -l
register: hieradata_changes
changed_when: "hieradata_changes.stdout|int != 0"
@RickyCook
RickyCook / keybase.md
Last active August 29, 2015 14:06
Keybase

Keybase proof

I hereby claim:

  • I am rickycook on github.
  • I am rickycook (https://keybase.io/rickycook) on keybase.
  • I have a public key whose fingerprint is 1255 FA8D 8DE3 0534 D431 4564 79D6 68B9 12F3 6735

To claim this, I am signing this object:

@RickyCook
RickyCook / pylint.conf
Created September 19, 2014 08:29
Default Pylint RC
[MESSAGES CONTROL]
disable=bad-continuation,
fixme,
locally-disabled,
relative-import,
star-args,
wildcard-import,
[REPORTS]
output-format=colorized
@RickyCook
RickyCook / tag.sh
Last active August 29, 2015 14:03
Retrospectively tag releases from setup.py commits
#!/bin/bash
for version_line in $(git log -G 'version=' setup.py | grep commit | awk '{print $2}' | \
xargs git show --date=iso | \
grep -E '^((\+\s*version=)|(commit )|Date:)' | \
sed "s/\+\s*version='//" | sed "s/',$//" | \
sed 's/commit //' | \
sed 's/Date:\s*//' | \
awk '{printf("%s%s", $0, (NR%3 ? "," : "\n"))}' | \
sed 's/ /_/g'); do
c="$(echo $version_line | awk -F ',' '{print $1}')"
@RickyCook
RickyCook / #migration_notes.md
Last active January 4, 2016 05:18
South migration of a OneToOne relationship to a GenericForeignKey relationship

See models.old.py for the models we will be migrating from and models.py for the models we will be migrating to.

Step one

  1. Add the GFK to your model so that you have the OneToOne and GenericForeignKey side by side for data migration
  2. Auto generate a schema migration to add the GFK to the schema: ./manage.py schemamigration <yourapp> --auto
  3. Set the defaults for content_type_id and object_id to 1; We will change them in the data migration

Step two

@RickyCook
RickyCook / example.py
Last active January 3, 2016 07:29
List a Django app's urlpatterns in a table
#
# General setup
# Import your app and set APP_URLS to your urlpatterns
#
import iss.urls
APP_URLS = iss.urls.urlpatterns
from url_levels import url_levels
out = url_levels(APP_URLS)
@RickyCook
RickyCook / pa.py
Last active January 3, 2016 01:59
Playing around with libpulseaudio and ctypes
"""
Very simple play with libpulseaudio
pip install libpulseaudio
Help with the API:
http://www.ypass.net/blog/2009/10/pulseaudio-an-async-example-to-get-device-lists/
http://freedesktop.org/software/pulseaudio/doxygen/index.html
"""
@RickyCook
RickyCook / stats.sh
Last active December 31, 2015 04:39
Record free RAM and number of docs in an index for ElasticSearch over time
#!/bin/bash
########
ELASTIC_URL="<host>:9200/<index>/"
SLEEP=5
########
# AHAHHAHAHAHAHHAHAHH awwwwwful
PYTHON_CODE='
@RickyCook
RickyCook / update_stories.py
Last active December 29, 2015 16:39
Pivotal Tracer story fix
#!/usr/bin/python
import re
import requests
DEBUG = True
PROJECT_ID = ''
TOKEN = ''