This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env pypy3 | |
# Find a number with a multiplicative persistance larger than 11. | |
from collections import Counter | |
from functools import reduce | |
from multiprocessing import Pool | |
import json | |
import requests | |
import time | |
URL = 'https://api.pushover.net/1/messages.json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I didn't write this code. I just found it online. | |
# make sure to install python-smbus using below command | |
# sudo apt-get install python-smbus | |
import smbus | |
import time | |
from ctypes import c_short | |
DEVICE = 0x77 # Default device I2C address |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A terrible way to calculate the absolute value of any integer with no reliance on complex computer math! | |
# Do not do this. | |
# Usage: | |
# >>> abs(10) | |
# 10 | |
# >>> abs(-10) | |
# 10 | |
# >>> abs(10.2) | |
# 10.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# A basic CentOS Setup Script | |
echo "[$(date)] Starting Base Installs" | |
sudo yum -y update | |
sudo yum install -y tmux git epel-release htop | |
echo "[$(date)] Installing Docker" | |
sudo yum -y install docker docker-registry | |
sudo systemctl enable docker.service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
set -e; | |
MODE="api" | |
log() { | |
echo "[$(date)] $@" | |
} | |
load_secrets() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Before we allow a commit, let's first enable preflight. | |
# To disable this check, set NO_PREFLIGHT=1 | |
# The commit will fail if the preflight checks do. | |
set -e; | |
should_check() { | |
APP=$1 | |
FOUND="-1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def query(q, data, default=None, should_raise=False): | |
""" This method allows for a simple recursive queries on JSON fields, | |
including Python's native dictionary. | |
Sample query: | |
data = { | |
'user' { | |
'aliases': [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# https://docs.ejabberd.im/developer/guide/#toc_8 | |
import sys, os | |
from struct import * | |
from requests import get | |
BASE_URL = os.environ['BASE_URL'] | |
DJANGO_AUTH = os.environ['DJANGO_AUTH'] | |
DJANGO_IS_USER = os.environ['DJANGO_IS_USER'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Interactively clean up branches in a given repository. | |
# | |
# author: Brian Schrader | |
# Usage: cd /path/to/repo && ./cleanup-git-branches | |
BRANCHES="$(git branch | sed 's/[ \*]//g')" | |
for BRANCH in $BRANCHES; do | |
CONFIRM_MSG=">>> Delete $BRANCH? [y/n, default: n]: " | |
read -en 1 -p "$CONFIRM_MSG"; |