Skip to content

Instantly share code, notes, and snippets.

Joshua Levy jlevy

Block or report user

Report or block jlevy

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
@jlevy
jlevy / simple-hash.js
Created Oct 23, 2019
Fast and simple insecure string hash for JavaScript
View simple-hash.js
// This is a simple, *insecure* hash that's short, fast, and has no dependencies.
// For algorithmic use, where security isn't needed, it's way simpler than sha1 (and all its deps)
// or similar, and with a short, clean (base 36 alphanumeric) result.
// Loosely based on the Java version; see
// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript
const simpleHash = str => {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = (hash << 5) - hash + char;
@jlevy
jlevy / pjson
Created May 28, 2019
Command-line JSON pretty-printer
View pjson
#!/bin/bash
# Convenience script to pretty-print and browse colored JSON without remembering flags.
# Read from files or stdin.
jq -C . "$@" | less -R -m
@jlevy
jlevy / diffjson
Created May 28, 2019
Command-line JSON diff (colorized and with normalized key ordering)
View diffjson
#!/bin/bash
set -euo pipefail
file1="${1:?
Usage: $(basename $0) file1.json file2.json
Show diff of JSON, normalizing key ordering.
}"
@jlevy
jlevy / SecConfig.py
Last active Nov 4, 2019
SecConfig.py from AWS Re-Invent 2013 (export AWS security configurations)
View SecConfig.py
#! /usr/bin/python
# This script is taken (unmodified except for this comment) from: https://s3.amazonaws.com/reinvent2013-sec402/SecConfig.py
# Talk: http://www.slideshare.net/AmazonWebServices/intrusion-detection-in-the-cloud-sec402-aws-reinvent-2013
# Example code to output account security config
__author__ = 'Greg Roth'
import boto
import urllib
You can’t perform that action at this time.