Skip to content

Instantly share code, notes, and snippets.

@elasticdog
elasticdog / verify-chain
Last active December 28, 2015 05:59
verify the ssl certificate chain for multiple domains using openssl
#!/bin/bash
readonly FILE='domains.list'
readonly MAX_CHAIN_LENGTH=5
readonly PORT=443
while IFS= read -r domain; do
echo -ne "${domain} $(/usr/bin/dig ${domain} +short | tail -n 1)\n"
echo QUIT | /usr/bin/openssl s_client -verify ${MAX_CHAIN_LENGTH} -connect ${domain}:${PORT} 2>1 | grep 'Verify return code'
done < "$FILE"
@elasticdog
elasticdog / gist:8806073
Last active May 9, 2019 18:19
Working with Git Submodules

Add New Submodule

$ cd ~/.dotfiles/
$ git submodule add http://github.com/scrooloose/nerdtree.git vim/bundle/nerdtree
$ git submodule init
$ git commit -m 'Add nerd tree plugin as submodule'

Updating

@elasticdog
elasticdog / gist:9276527
Created February 28, 2014 18:13
Broken AWS Repository
stderr: E: Failed to fetch http://us-east-1.ec2.archive.ubuntu.com/ubuntu/pool/universe/a/arpack/libarpack2_3.1.5-2_amd64.deb 403 Forbidden
@elasticdog
elasticdog / delete-ami
Last active March 7, 2023 12:19
Deregister an Amazon Machine Image (AMI) and delete its corresponding root device snapshot
#!/usr/bin/env bash
#
# delete-ami
#
# A script to deregister an Amazon Machine Image (AMI) and
# delete its corresponding root device snapshot.
#
##### Functions
@elasticdog
elasticdog / keybase.md
Created May 6, 2014 22:20
Keybase.io GitHub Verification

Keybase proof

I hereby claim:

  • I am elasticdog on github.
  • I am elasticdog (https://keybase.io/elasticdog) on keybase.
  • I have a public key whose fingerprint is 5FC9 160D A643 E0E9 B83A F4BB 5E34 0427 C31E 7946

To claim this, I am signing this object:

@elasticdog
elasticdog / english.rs
Created November 11, 2014 18:05
Determine likelyhood of text being in English using Rust
/// Uses the Bhattacharyya coefficient to determine if text is likely to be English.
///
/// Higher is better.
pub fn probability_english(text: &str) -> f64 {
// count of the number of times a character occurs in the given text
let mut count: BTreeMap<char, f64> = BTreeMap::new();
for letter in text.chars() {
match count.entry(char::to_uppercase(letter)) {
Vacant(entry) => { entry.set(1f64); },
Occupied(mut entry) => *entry.get_mut() += 1f64,
javascript:(function(){var%20ps=document.getElementsByTagName("pre");for(var%20i=0;i<ps.length;i++){ps[i].style.whiteSpace="pre-wrap";ps[i].style.width="600px";}})();
@elasticdog
elasticdog / poolboy_demo.ex
Created October 23, 2015 14:20 — forked from henrik/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000
@elasticdog
elasticdog / vagrant-box-clean
Last active May 25, 2018 13:44
clean up old versions of vagrant boxes
#!/usr/bin/env bash
##### Functions
# print this script's usage message to stderr
usage() {
cat <<-EOF >&2
usage: vagrant-box-clean [-p PREFIX] [-d] [-h]
EOF
}
@elasticdog
elasticdog / git-dmz-flow.md
Created October 4, 2016 18:29 — forked from djspiewak/git-dmz-flow.md
Git DMZ Flow

Git DMZ Flow

I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.

  • Two developers working on independent features must never be blocked by each other
    • No code freeze! Ever! For any reason!
  • A developer must be able to base derivative work on another developer's work, without waiting for any third party
  • Two developers working on inter-dependent features (or even the same feature) must be able to do so without interference from (or interfering with) any other parties
  • Developers must be able to work on multiple features simultaneously, or at lea