Skip to content

Instantly share code, notes, and snippets.

View djm's full-sized avatar

Darian Moody djm

View GitHub Profile
@djm
djm / bitbucket_open_all_diffs_bookmarklet.js
Created January 3, 2017 10:14
Bitbucket: JavaScript bookmarklet to open all diffs (2017)
javascript:(function(){$(".load-diff").click();}());
@djm
djm / bookmarklets.js
Created September 26, 2016 13:22 — forked from Geekfish/bookmarklets.js
Trello Card bookmarklets
// Get Card's last URL segment (eg 4468-fix-the-login-page):
javascript:(function(s){try{s=document.selection.createRange().text}catch(_){s=document.getSelection()}prompt('', window.location.href.split("/").pop().split("#")[0])})()
// Get Card's full hash (eg 5731b92ef660293533517de9) :
javascript:(function(s){try{s=document.selection.createRange().text}catch(_){s=document.getSelection()}$('.js-more-menu').click(); prompt('', $('.js-export-json').attr('href').split("/")[2]); $('.js-more-menu').click();})()
// Get Card's unique id (board-independent, eg rKBmQeOk) :
javascript:(function(s){try{s=document.selection.createRange().text}catch(_){s=document.getSelection()}$('.js-more-menu').click(); prompt('', $('.js-short-url').attr('value').split("/").slice(-1)[0]); $('.js-more-menu').click();})()
@djm
djm / pre-commit.py
Created September 21, 2016 13:53 — forked from Geekfish/pre-commit.py
Pre-commit hook with flake8 and auto-named migrations
#!/usr/bin/env python
import sys, subprocess, collections
from flake8.hooks import git_hook, get_git_param
# `get_git_param` will retrieve configuration from your local git config and
# then fall back to using the environment variables that the hook has always
# supported.
# For example, to set the complexity, you'll need to do:
# git config flake8.complexity 10
COMPLEXITY = get_git_param('FLAKE8_COMPLEXITY', 10)

Keybase proof

I hereby claim:

  • I am djm on github.
  • I am djm (https://keybase.io/djm) on keybase.
  • I have a public key whose fingerprint is DBB9 0727 AD94 8582 ECED 66EB 7EA3 B5B0 D8AD 79BB

To claim this, I am signing this object:

@djm
djm / cancel_jobs.py
Last active August 31, 2015 21:02
Delete/cancel all in progress and pending jobs in an Elastic Transcoder region
import time
from boto import elastictranscoder
REQUEST_FREQ = 0.3 # Every x seconds
REGION = 'eu-west-1'
TO_CANCEL = [
'Progressing',
'Submitted'
]
@djm
djm / chunk.js
Created August 19, 2015 19:49
Javascript: chunk an ES6 Map into an Array of similar sized Maps
export function chunkMap (map, chunkSize) {
const chunkedMaps = []
const mapAsArray = Array.from(map)
for (var i = 0; i < map.size; i += chunkSize) {
let chunked = mapAsArray.slice(i, i + chunkSize)
chunkedMaps.push(new Map(chunked))
}
return chunkedMaps
}
@djm
djm / aws.lambda.upload.error.output
Last active July 4, 2020 07:19
Node Lambda Upload Error: "Cross-account pass role is not allowed"
Reading zip file to memory
Uploading zip file to AWS Lambda eu-west-1 with parameters:
{ FunctionName: 'xxx-staging-1-0-0',
FunctionZip: <Buffer 50 478 0b 00 ...>,
Handler: 'index.handler',
Mode: 'event',
Role: 'arn:aws:iam::xxx:role/xxx',
Runtime: 'nodejs',
Description: 'Resizes images for the xxx project.',
MemorySize: '512',
@djm
djm / closures_ftw.py
Created February 26, 2015 02:57
Prefer closures over classes keeping state
# Bad
class Join(object):
"""
>>> join_by_commas = Join(',')
>>> join_by_commas(['o', 'm', 'g'])
'o,m,g'
"""
def __init__(self, separator=u' '):
self.separator = separator
@djm
djm / Dockerfile
Created October 20, 2014 21:03
Simple docker/fig setup for Django
FROM python:2.7
# Force stdin, stdout and stderr to be totally unbuffered.
ENV PYTHONUNBUFFERED 1
# For Pillow to have freetype support.
RUN ln -s /usr/include/freetype2 /usr/include/freetype
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
@djm
djm / gae_shell.py
Created September 28, 2014 12:20
Google App Engine Development Shell
#!/usr/bin/env python -i
"""
A local interactive IPython shell for Google App Engine on Mac OSX.
Usage:
cd /to/project/folder/with/app.yaml
python gae_shell.py
Notes: