Skip to content

Instantly share code, notes, and snippets.

Joël Franusic jpf

Block or report user

Report or block jpf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jpf
jpf / count-bits.py
Created Aug 27, 2018
Counts the number of "1" and "0" bits in an input file
View count-bits.py
#!/usr/bin/env python3
# Counts the number of "1" and "0" bits in an input file
import sys
bits_per_byte = 8
# Via: https://stackoverflow.com/a/1035456
def bytes_from_file(filename, chunksize=8192):
with open(filename, "rb") as f:
while True:
View as-a-service.js
var tracery = require('tracery-grammar'); // https://github.com/v21/tracery
var grammar = tracery.createGrammar({
'aas': ['#thing# as a service.'],
'thing': [
'Chaos',
'Denial of Service',
'Insurrection',
'Monday',
'Sucks',
'apocalypse',
View showoff.sh
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl -p xmlstarlet -p imagemagick -p jp2a -p lolcat
#
# showoff.sh:
# Demonstrate the capabilities of Nix by writing a gratuitously complex shell
# script that combines 5 different command line utilities together.
#
# Do the following to run this demo:
# If you don't have Nix yet, install it with this command:
# $ curl https://nixos.org/nix/install | sh
@jpf
jpf / nix_and_python.py
Created Jun 1, 2016
A Python script that uses Nix to automatically bootstrap dependencies.
View nix_and_python.py
#! /usr/bin/env nix-shell
#! nix-shell -i python -p python27Packages.flask python27Packages.emoji
#
# This is a demo of using Nix to manage packages for a program in a language agnostic way.
# If you run this example as an executable, it'll Just Work, even if you don't have Flask or emoji installed. Try it out!
#
# $ curl https://nixos.org/nix/install | sh
# $ chmod a+x nix_and_python.py
# $ ./nix_and_python.py
from flask import Flask
@jpf
jpf / thoughts-on-literate-programming.md
Last active Aug 25, 2018
Thoughts after 6 months of literate programming
View thoughts-on-literate-programming.md

Thoughts after 6 months of literate programming

I wrote my first literate program in November of 2015. Since then, I've been writing literate programs on an almost daily basis. It has been an experience with a sort of enlightenment that I haven't had in a long time. Not only is it a lot of fun to write literate programs, I feel like I have gained a new "super power" of sorts.

Below are my thoughts on my experiences with literate programming so far.

View get_id_token.sh
#!/bin/bash
# http://stackoverflow.com/questions/8175000/parsing-arguments-options-flags-in-a-bash-script
base_url=""
client_id=""
origin=""
password=""
username=""
verbose=0
@jpf
jpf / output.sh
Created Mar 7, 2016
Don't hate: cavitate
View output.sh
$ for w in `cat /usr/share/dict/words | egrep 'ate$'`; do echo "Don't hate: ${w}"; done
Don't hate: abacate
Don't hate: abacinate
Don't hate: abalienate
Don't hate: abate
Don't hate: abbreviate
Don't hate: abdicate
Don't hate: aberrate
Don't hate: abietate
Don't hate: abintestate
@jpf
jpf / requirements.org
Last active Feb 26, 2016
What a requirements.txt file might look like in a literate program
@jpf
jpf / signed-jwt-in-python.md
Last active Aug 19, 2019
JWTs signed with RS256 in Python: A demonstration of org-babel
View signed-jwt-in-python.md

Introduction

This is a guide to using pyjwt to sign and validate a JWT using RS256.

The trickiest part of doing this is knowing what the proper OpenSSL commands are to generate the RSA keypair. I demonstrate that below.

Generating RSA keys

@jpf
jpf / fetch-ssl-from-okta-com.sh
Created Nov 10, 2015
How to fetch the SSL certificate from www.okta.com
View fetch-ssl-from-okta-com.sh
echo '' | openssl s_client -connect www.okta.com:443
You can’t perform that action at this time.