Skip to content

Instantly share code, notes, and snippets.

View bhardin's full-sized avatar
🍖
In meatspace

Brett Hardin bhardin

🍖
In meatspace
View GitHub Profile
### Keybase proof
I hereby claim:
* I am bhardin on github.
* I am bretthardin (https://keybase.io/bretthardin) on keybase.
* I have a public key whose fingerprint is 3BCB B264 8E38 785F 63A5 CF30 B4EF 287D F5E9 AE04
To claim this, I am signing this object:
@bhardin
bhardin / GIF-Screencast-OSX.md
Created August 18, 2016 16:51 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@bhardin
bhardin / mount_ebs.sh
Last active September 12, 2016 21:33 — forked from stingh711/mount_ebs.sh
How to mount another EBS as /var on EC2 (ubuntu)
#!/bin/bash
#attach the EBS to /dev/sdf before running it
# If not mounted... format EBS
mkfs -t ext4 /dev/xvdb
mkdir /mnt/new
mount /dev/xvdb /mnt
#copy original /var to /dev/xvdb
sudo cp -ax /var/* /mnt
@bhardin
bhardin / long_running_tasks.py
Last active September 21, 2016 15:11
Examples of how to use celery beat
# app/some_cool_app/tasks.py
@celery_app.task(bind=True, queue=’whenever’)
def a_long_running_process(self):
process = LongRunningProcess()
process.run()
import logging
from myapp.celery_config import celery_app
from myapp.corporations.models import Corporation
logger = logging.getLogger()
@celery_app.task(
name='analytics.update_corporation_data',
from celery.schedules import crontab
from myapp.common import constants
ALL = 'all'
tasks = {
# Tasks that should be run in all environments
ALL: {},
# Tasks that should be run on production
### MORE CODE ABOVE THIS ###
from datetime import timedelta
'add-every-30-seconds': {
'task': 'tasks.update_something',
'schedule': timedelta(seconds=30),
'args': (16, 16)
},
@bhardin
bhardin / tmux-cheatsheet.md
Last active May 31, 2017 15:09 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@bhardin
bhardin / create_release_notes.py
Created May 21, 2018 16:01
Create nice looking PR notes from a milestone
from github import Github
import os
import sys
release = str(sys.argv[1])
# or using an access token
GITHUB_ACCESS_TOKEN = os.environ['GITHUB_ACCESS_TOKEN']
g = Github(GITHUB_ACCESS_TOKEN)
FEATURES = 'Feature'
with
dau as (
-- This part of the query can be pretty much anything.
-- The only requirement is that it have three columns:
-- dt, user_id, inc_amt
-- Where dt is a date and user_id is some unique identifier for a user.
-- Each dt-user_id pair should be unique in this table.
-- inc_amt represents the amount of value that this user created on dt.
-- The most common case is
-- inc_amt = incremental revenue from the user on dt