Skip to content

Instantly share code, notes, and snippets.

View pauldraper's full-sized avatar

Paul Draper pauldraper

View GitHub Profile
@pauldraper
pauldraper / BUILD.bazel
Last active November 18, 2023 02:22
Bazel pkg_runfiles and pkg_executable
View BUILD.bazel
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load(":rules.bzl", "pkg_executable")
#
# Package executable :bin to tar
#
pkg_executable(
name = "pkg",
bin = ":bin",
@pauldraper
pauldraper / README.md
Last active August 23, 2019 18:49
Generator vs Array vs Inline iteration
View README.md

In this test, inline is 10x faster than arrayt which is 1.4x faster than generator.

@pauldraper
pauldraper / install.sh
Last active May 11, 2021 15:40
Docker ECR credential helper
View install.sh
# A docker credential helper that automatically calls AWS CLI for docker push/pull.
cat <<EOF
grep -q 'dkr.ecr.[^.]\+.amazonaws.com' - || exit
aws --output text ecr get-authorization-token --query authorizationData[0].authorizationToken \
| base64 --decode \
| sed -e 's/:/", "Secret":"/' -e 's/^/{"Username":"/' -e 's/$/"}/'
EOF | sudo tee /usr/local/bin/docker-credential-ecr-login
sudo chmod +x /usr/local/bin/docker-credential-ecr-login
@pauldraper
pauldraper / events.ts
Last active March 15, 2019 12:37
OpenTracing for Node.js http
View events.ts
import { EventEmitter } from 'events';
import { globalTracer, Span } from 'opentracing';
/**
* All events from the emitter share the same span.
*/
export function activateEventEmitter(span: Span, emitter: EventEmitter) {
const { emit } = emitter;
emitter.emit = function(this: any) {
const args = arguments;
@pauldraper
pauldraper / BiMap.scala
Created December 22, 2013 02:38
Scala BiMap - a bidirectional map for Scala
View BiMap.scala
import scala.collection.mutable.Map
class BiMap[A,B] extends BiMapHelper(Map[A,B](), Map[B,A]()) {
}
object BiMap {
def apply[A,B](elems:(A,B)*) = new BiMap[A,B] ++= elems