Skip to content

Instantly share code, notes, and snippets.

View josefdlange's full-sized avatar
🌱

Joey Lange josefdlange

🌱
View GitHub Profile
@josefdlange
josefdlange / mpr
Created November 21, 2019 19:03
Pull Request Generator
#!/bin/zsh
usage() {
echo "Usage: mpr [-h]"
printf "\n"
echo "Opens or creates a pull-request for the given branch."
echo "If branch is prefixed with a branch-type (feature/etc),"
echo "that will be used as a label upon creation."
printf "\n"
exit 2
@josefdlange
josefdlange / fields.py
Created October 23, 2017 17:51
Hashid-enabled PrimaryKeyField for Peewee ORM
from peewee import PrimaryKeyField
from hashids import Hashids
class HashidPrimaryKeyField(PrimaryKeyField):
hashid = Hashids(min_length=16)
@property
def prefix(self):
return self.model_class.__name__.lower() + '_'
@josefdlange
josefdlange / ReduxRestExample.js
Created September 21, 2016 21:04
Redux REST Example
// Actions
var startLoadingX = function() {
return {
type: START_LOADING_X // Define this above as you do with Actions.
}
}
var completeLoadingX = function(response, error) {
return {
@josefdlange
josefdlange / explanation.md
Created August 22, 2016 06:03
Four-player card draw

Seeing the others' answers I don't think matters in this solution.

The strategy -- given that it's allowable to discuss strategy before drawing cards -- is each person has a different modulo result (x) they have to compute the number they must add [to the sum of the other three], (m) in the following algebra. Solve for m to get the suit your should guess.

x = ([sum of others] + m) % 4

Suits: 0: Diamond 1: Heart 2: Club

@josefdlange
josefdlange / swizzle_slack.py
Created August 13, 2016 06:12
Swizzle the web socket client inside of the slack client library to find its own damn Root CA file
from slackclient import SlackClient as _SlackClient
class SlackClient(_SlackClient):
# I'm not sure if it's my local environment, but the Slack Client
# swallows an error where the websocket client beneath can't find
# the root CA file.
def __init__(self, *args, **kwargs):
super(SlackClient, self).__init__(*args, **kwargs)
def patched_connect_slack_websocket(self, ws_url):
@josefdlange
josefdlange / alpha2_guesser.py
Created June 24, 2016 19:38
Naive Country ISO3166 Alpha2 Resolver/Guesser
import difflib
import pycountry
def baseline_country(country_input, default="US"):
"""
Given a string input, return a two-character ISO3166 code.
"""
try:
if country_input and len(country_input) > 0:
if len(country_input) == 3: # Let's find the alpha2 for this probably-alpha3. Are there 3-letter countries?
@josefdlange
josefdlange / # libspatialite - 2016-06-20_13-04-40.txt
Created June 20, 2016 18:23
libspatialite on Mac OS X 10.12 - Homebrew build logs
Homebrew build logs for libspatialite on Mac OS X 10.12
Build date: 2016-06-20 13:04:40
@josefdlange
josefdlange / # gcc - 2016-06-20_12-39-26.txt
Created June 20, 2016 17:59
gcc on Mac OS X 10.12 - Homebrew build logs
Homebrew build logs for gcc on Mac OS X 10.12
Build date: 2016-06-20 12:39:26
@josefdlange
josefdlange / jerkins-check.py
Last active May 30, 2016 03:12
Simple script to pull Jenkins build status
#!/usr/bin/env python
"""
This script is pretty specific to my use case but perhaps someone else might find it useful.
I have two Jenkins jobs, and that's what this script supports displaying:
1) Build on every commit to my `development` branch of my project,
2) Build on every PR to the `development` branch (using https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin)
Requirements:
@josefdlange
josefdlange / .bashrc
Created May 24, 2016 21:19
Manners Shell (bash only)
# Get bash-preexec first:
# curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh
source ~/.bash-preexec.sh
preexec() {
python ~/.please.py
}