Skip to content

Instantly share code, notes, and snippets.

View djm's full-sized avatar

Darian Moody djm

View GitHub Profile
@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)
@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 / circle.yml
Created February 12, 2017 14:48 — forked from jonah-williams/circle.yml
Automating deployments to Heroku from CircleCI
test:
override:
- bundle exec rspec spec
deployment:
acceptance:
branch: master
commands:
- ./script/heroku_deploy.sh <ACCEPTANCE_HEROKU_APP>:
timeout: 300
@djm
djm / remove_tags.sh
Created March 8, 2017 12:38 — forked from hugorodgerbrown/remove_tags.sh
Git - remove all remote tags
# removes all tags from a git remote
# 1. `git ls-remote --tags origin` - lists all the tags at origin: '<hash> refs/tags/<tag>'
# 2. `awk '/^(.*)(\s+)(.*[a-zA-Z0-9])$/ {print ":" $2}'` - extract the ':/ref/tags/<tag>' from each
# 3. `xargs git push origin` - run 'git push origin :/ref/tags/<tag>' against each tag
git ls-remote --tags origin | awk '/^(.*)(\s+)(.*[a-zA-Z0-9])$/ {print ":" $2}' | xargs git push origin
@djm
djm / Dockerfile
Created October 13, 2017 06:12 — forked from mjackson/Dockerfile
Running `gatsby develop` on a container in development
FROM node:8
WORKDIR /home/node/app
ADD https://github.com/Yelp/dumb-init/releases/download/v1.1.1/dumb-init_1.1.1_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
COPY package.json yarn.lock ./
RUN yarn --pure-lockfile
COPY . .
@djm
djm / bulk.py
Created June 29, 2018 14:57 — forked from danfairs/bulk.py
Bulk utilities
"""
Utilities for working with bulk data and batches.
"""
import itertools
def batches(items, batch_size=500):
"""
Given an iterable of items and a batch size, yield individual lists
of items of maximum length `batch_size`.
@djm
djm / handler.py
Created December 5, 2018 13:16 — forked from Geekfish/handler.py
DjangoRQ Transaction aware job decorator
from jobs import send_welcome_email
# ...
def register_user():
user = do_the_registration()
send_welcome_email.transaction_aware_delay(user.id)
# or
# send_welcome_email.request_aware_delay(user.id)
defmodule Test do
def thing() do
1+1
end
defmacro my_macro do
quote do
1 + 1
end
end
@djm
djm / DateInput.vue
Created August 27, 2019 12:08 — forked from reinink/DateInput.vue
Pikaday Vue Component
<template>
<div>
<label v-if="label" class="form-label" :for="`date-input-${_uid}`">{{ label }}:</label>
<input v-bind="$attrs" class="form-input" :id="`date-input-${_uid}`" :class="{ error: error }" type="text" ref="input" :value="value" @change="change" @keyup="change">
<div v-if="error" class="form-error">{{ error }}</div>
</div>
</template>
<script>
import pikaday from 'pikaday'
@djm
djm / websocket_redis_pubsub.ts
Created January 2, 2021 12:32 — forked from philipyoungg/websocket_redis_pubsub.ts
Only support one room—but it's scalable horizontally
import * as redis from "redis";
import * as Websocket from "ws";
import { v4 } from "uuid";
import * as http from "http";
function noop() {}
enum WebsocketSendType {
BROADCAST_EMIT = "BROADCAST_EMIT",
}