Skip to content

Instantly share code, notes, and snippets.

@elasticdog
elasticdog / config.nix
Last active December 3, 2020 15:51
~/.nixpkgs/config.nix package override for Ansible v2.1.4.0
{
packageOverrides = pkgs: rec {
ansible2 = pkgs.stdenv.lib.overrideDerivation pkgs.ansible2 (oldAttrs: rec {
variable = "2.1.4.0";
name = "ansible-${variable}";
src = pkgs.fetchurl {
url = "http://releases.ansible.com/ansible/${name}.tar.gz";
sha256 = "05nc68900qrzqp88970j2lmyvclgrjki66xavcpzyzamaqrh7wg9";
};
@elasticdog
elasticdog / signing-releases.md
Created June 30, 2022 14:01
Tagging and Signing Releases in Git

Tagging and Signing Releases in Git

Fish:

$ set -x GPG_TTY (tty)

Bash:

@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,
@elasticdog
elasticdog / LICENSE
Last active October 17, 2022 14:00
Git Triangular Workflow
Copyright (c) 2018, Aaron Bull Schaefer <aaron@elasticdog.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@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 / vault-cp
Created July 27, 2018 18:32
A script to copy Vault secrets from one path to another
#!/usr/bin/env bash
# ensure we were given two command line arguments
if [[ $# -ne 2 ]]; then
echo 'usage: vault-cp SOURCE DEST' >&2
exit 1
fi
source=$1
dest=$2