Skip to content

Instantly share code, notes, and snippets.

@shauns
shauns / damm_check.gs
Created September 11, 2020 08:00
Damm Algorithm check digit for Google Sheets
// See https://en.wikipedia.org/wiki/Damm_algorithm
// =DAMM(5724) == true
const cols = {
"0": {
"0": "0",
"1": "7",
"2": "4",
"3": "1",
"4": "6",
@shauns
shauns / gist:453b076ec53e51ce518a0e374172a4ea
Created November 7, 2018 11:41
Setting up Apache Superset on EC2 Ubuntu 18
sudo apt-get update
sudo apt-get install build-essential libssl-dev libffi-dev python-dev python-pip libsasl2-dev libldap2-dev
sudo apt-get install build-essential libssl-dev libffi-dev python3.6-dev python-pip libsasl2-dev libldap2-dev
pip install virtualenv
sudo apt install python3-venv
pyvenv venv
source venv/bin/activate
pip install --upgrade setuptools pip
pip install superset
pip install psycopg2
@shauns
shauns / webtask.js
Created November 29, 2016 16:21
Webtask to swap auth0 ID token for stream.io one
"use latest";
import jwt from 'jsonwebtoken';
export default function(ctx, cb) {
const authSecret = ctx.data.AUTH0_CLIENT_SECRET;
const streamSecret = ctx.data.STREAM_CLIENT_SECRET;
const token = ctx.data.token;
const userId = jwt.verify(token, new Buffer(authSecret, 'base64')).sub;
const slug = ctx.data.feed;
@shauns
shauns / index.html
Created November 22, 2016 15:49
Bad login page (uses GET)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Insecure Login</title>
</head>
@shauns
shauns / backing-up-github.sh
Created November 11, 2016 16:35
Backing up Github repositories and wikis and issues
# uses https://github.com/josegonzalez/python-github-backup
github-backup -o ff-backup -p "API token" -u shauns --all -P -R "ff-docs" Freeformers
@shauns
shauns / gist:c8bc24868c1e9c61aa3f8cd80efeb332
Created October 27, 2016 10:06
Running Django manage commands on EBS
[eb ssh]
source /opt/python/run/venv/bin/activate
source /opt/python/current/env
cd /opt/python/current/app
./manage.py help
@shauns
shauns / qr.sh
Created October 25, 2016 10:26
QR code to terminal
qrencode -o - 1234eabcdf | imgcat
@shauns
shauns / creating_auth0_user.py
Last active September 23, 2016 10:04
Use management API to create an Auth0 user
import requests
# Needs create:users scope, https://auth0.com/docs/api/management/v2#!/Users/post_users
headers = {'Authorization': 'Bearer qwertyuiop'}
body = {'connection': 'Username-Password-Authentication', 'email': u'xxx@foo.freeformers.com', 'family_name': 'Bloggs', 'given_name': 'Joe', 'password': 'secrets'}
res = requests.post('https://freeformers.auth0.com/api/v2/users', json=body, headers=headers)
res.json()
@shauns
shauns / slack.py
Created August 10, 2016 14:44
Deleting and listing slack files, sorting by size
from slacker import Slacker
import itertools
slack = Slacker('<API TOKEN>')
pages = slack.files.list(page=1).body['paging']['pages']
all_the_files = list(itertools.chain(*[slack.files.list(page=i).body['files'] for i in range(1,pages + 1)]))
biggest_first = sorted(all_the_files, key=lambda f: f['size'], reverse=True)
<script src='https://www.workable.com/assets/embed.js' type='text/javascript'></script>
<script type='text/javascript' charset='utf-8'>
whr(document).ready(function(){
whr_embed(116603, {detail: 'titles', base: 'jobs', zoom: 'country', grouping: 'none'});
});
</script>
<div id="whr_embed_hook"></div>