Skip to content

Instantly share code, notes, and snippets.

View progrium's full-sized avatar

Jeff Lindsay progrium

View GitHub Profile
@andreas
andreas / envelope_encryption.go
Created February 3, 2015 19:25
Envelope Encryption with Amazon KMS and Go
package main
import (
"bytes"
"crypto/rand"
"encoding/gob"
"fmt"
"io/ioutil"
"os"
"time"
export PS1="\[\033[01;31m\]\$(status=\$?; [[ \$status -ne 0 ]] && echo \"[\$status] \")\[\033[01;32m\]\u@\h \[\033[01;34m\]\w\n\$ \[\033[00m\]"
alias reload="curl -s https://gist.githubusercontent.com/progrium/6a24ae8d7ab93bc65579/raw/gistfile1.txt > ~/.profile.me; source ~/.profile"
alias g="git"
alias gpr="git pull --rebase origin"
alias gprr="git pull --rebase"
alias gpu="git push origin"
alias gpuu="git push"
alias gs="git status"
@emasaka
emasaka / pipeline.rb
Created September 29, 2014 05:05
shell-like pipeline in Ruby DSL
#!/usr/bin/env ruby
module PipeOperator
refine Array do
def |(x)
PipeLine.new(self) | x
end
end
end
@hvoecking
hvoecking / translate.go
Last active March 28, 2024 13:52
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
@ncw
ncw / README.txt
Last active February 20, 2024 19:30 — forked from spikebike/client output
Client side certificates with go
This demonstrates how to make client side certificates with go
First generate the certificates with
./makecert.sh test@test.com
Run the server in one terminal
go run server.go
@dherman
dherman / README.md
Last active July 10, 2023 19:15
How the ES6 Realm API makes it possible to create robust JS dialects

JS dialects with ES6 Realms

This essay explains how the ES6 Realm API makes it possible to create robust language abstractions that allow hooking into the behavior of eval, and how this can be used to implement different dialects of JavaScript.

Example scenario: Crock's "default operator"

Imagine we want to add Doug Crockford's ?? operator, which acts like a short-circuiting logical OR operator, except instead of checking truthiness, it returns the first argument's value if the first argument is any value other than undefined.

Since it makes everything simpler and cleaner, I'm going to assume I can use do-expressions for the implementation. (They're looking good for ES7!) So with that said, when we "crockpile" EXPR1 ?? EXPR2 we

#!/bin/bash
# Usage:
# $ ./heroku-deploy.sh <app name> <git repo url> <heroku api key>
APP="$1"
REPO="$2"
APIKEY="$3"
echo "-----> Creating application $APP"
curl -u ":$APIKEY" -d "app[name]=$APP" -X POST https://api.heroku.com/apps -s > /dev/null
@domenic
domenic / interop.md
Last active July 7, 2022 19:47
`module.exports =` and ES6 Module Interop in Node.js

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.

@scottburton11
scottburton11 / gist:3222152
Created August 1, 2012 00:58
Audio Compression for Voiceover

About compression

Audio compression is used to reduce the dynamic range of a recording. Dynamic range is the difference between the loudest and softest parts of an audio signal. It was originally used to guard against defects when cutting wax and vinyl phonograph records, but generally became useful as a way of increasing the loudness of an audio recording without achieving distortion.

The goal of most compression applications is to increase the amplitude of the softest parts of a recording, without increasing the amplitude of the loudest parts.

Compressor anatomy

Compressors generally all have the same conceptual parts. However, not all compressors present variable controls for all parts to the user. If you don't see all of your compressor's controls here, there's a chance it either has a fixed value (and no control), or is named something else:

@mpapis
mpapis / wait_port.sh
Created January 28, 2012 03:30 — forked from anonymous/gist:1692424
Wait for a port in bash, should work on sysv linux
#!/usr/bin/env bash
# wait_port <port> <seconds>
check_port ()
{
netstat -tpln 2> /dev/null | sed -E '/^[^t]/ d; s/^([^ ]+ +){3}//; s/ .*$//; s/^.*://;' | grep --color "^$1$" > /dev/null
}
wait_port ()