This file contains 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
from typing import Set | |
from typing import NamedTuple | |
class Key(NamedTuple): | |
name: str | |
group: str | |
class Uniquifier: |
This file contains 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
import { | |
MARKDOWN_FORMAT_CHARS, | |
truncate, | |
truncateCondensed, | |
truncateOnParagraphs, | |
truncateOnWords, | |
} from './friendlyTruncate'; | |
describe('truncate', () => { | |
it('returns the input if it is null or shorter than the limit', () => { |
This file contains 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
/** | |
* Convenience for timing specific function calls and logging to console. | |
* Works with both synchronous and asynchronous functions and also logs | |
* if the function exited or had an exception. minMs is the minimum number | |
* of milliseconds that the function must take to be logged. | |
* | |
* Usage example: To log when an expression like | |
* | |
* const result = someFunction(arg1, arg2); | |
* |
This file contains 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
import { comparisonChain, ordering } from './comparisonChain'; | |
interface Item { | |
title: string | null; | |
url: string | null; | |
sequenceNum: number | null; | |
} | |
// Setup a sample data | |
const items: Item[] = [ |
This file contains 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
// These hashes are for algorithmic use cases, such as bucketing in hashtables, where security isn't | |
// needed and 32 or 64 bits is enough (that is, rare collisions are acceptable). These are way simpler | |
// than sha1 (and all its deps) or similar, and with a short, clean (base 36 alphanumeric) result. | |
// A simple, *insecure* 32-bit hash that's short, fast, and has no dependencies. | |
// Output is always 7 characters. | |
// 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; |
This file contains 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 | |
# Convenience script to pretty-print and browse colored JSON without remembering flags. | |
# Read from files or stdin. | |
jq -C . "$@" | less -R -m |
This file contains 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 -euo pipefail | |
file1="${1:? | |
Usage: $(basename $0) file1.json file2.json | |
Show diff of JSON, normalizing key ordering. | |
}" |
This file contains 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 | |
# 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 |