Skip to content

Instantly share code, notes, and snippets.

View ntalbott's full-sized avatar
💻
Writing and Coding

Nathaniel Talbott ntalbott

💻
Writing and Coding
View GitHub Profile
@ntalbott
ntalbott / total
Created October 14, 2013 04:53
A little script to take memory profiling output from rdbtool and do some key prefix totalling
#!/usr/bin/env ruby
hash = Hash.new{|h,k| h[k] = [0,0]}
aggregate_n = (ARGV[0] || 1).to_i
STDIN.each_line do |line|
parts = line.split(",")
key = parts[2][1..-2]
prefix = key.split(":")[0..(-1-aggregate_n)].join(":")
size = parts[3]
@ntalbott
ntalbott / operable-software.md
Last active December 31, 2015 13:29
Operable Software

Operable Software

What does it mean to make software that doesn't just run, but is operable?

Good question! This represents some current thinking on the topic; there's tons of details in each of these things, so this list is expected to change and get more detailed over time.

Operable Software seems to involve (at a minimum) thinking a lot harder about and making sure there is a strategy (and code where appropriate) for:

  • Metrics
  • Logging
{
"gateway": {
"token": "XXX"
}
}
#!/usr/bin/env ruby
require 'open-uri'
require 'uri'
require 'rss/1.0'
require 'rss/2.0'
class Time
def distance_ago_in_words
seconds = (Time.now - self).to_i
@ntalbott
ntalbott / check-cert-revocation
Created April 15, 2014 19:31
Checks whether a cert in PEM format is revoked or not.
#!/usr/bin/env ruby
require "open-uri"
text = `openssl x509 -text -in #{ARGV[0]}`
#puts text
raw_serial = text[/Serial Number:\s*\n?\s*(\d+ \(0x\w+\)|\w{2}(?::\w{2})+)/, 1]
puts "Raw serial: #{raw_serial}"
serial = case raw_serial
when %r{\d+ \(0x(\w+)\)}
require "formula"
class Cargo < Formula
homepage "http://crates.io"
url "https://github.com/rust-lang/cargo/archive/master.tar.gz"
version "wip"
head "https://github.com/rust-lang/cargo.git"
depends_on "rust"
depends_on "cmake" => :build
@ntalbott
ntalbott / build.log
Last active August 29, 2015 14:11
Reduction showing challenge with a struct containing mutable and (intended) immutable fields.
ntalbott@lorica:~/play/rust-sandbox$ cargo build
Compiling rust-sandbox v0.0.1 (file:///Users/ntalbott/play/rust-sandbox)
/Users/ntalbott/play/rust-sandbox/src/main.rs:18:17: 18:39 error: cannot assign to `self.offset` because it is borrowed
/Users/ntalbott/play/rust-sandbox/src/main.rs:18 self.offset += c.len();
^~~~~~~~~~~~~~~~~~~~~~
/Users/ntalbott/play/rust-sandbox/src/main.rs:16:15: 16:19 note: borrow of `self.offset` occurs here
/Users/ntalbott/play/rust-sandbox/src/main.rs:16 match self.peek() {
^~~~
/Users/ntalbott/play/rust-sandbox/src/main.rs:29:41: 29:49 error: cannot borrow `s.offset` as immutable because `s` is also borrowed as mutable
/Users/ntalbott/play/rust-sandbox/src/main.rs:29 println!("char: {}, offset: {}", c, s.offset);
@ntalbott
ntalbott / gpgme.rb
Last active August 29, 2015 14:12
gpgme formula using gpg1
require "formula"
class Gpgme < Formula
homepage "https://www.gnupg.org/related_software/gpgme/"
url "ftp://ftp.gnupg.org/gcrypt/gpgme/gpgme-1.5.1.tar.bz2"
mirror "https://mirrors.kernel.org/debian/pool/main/g/gpgme1.0/gpgme1.0_1.5.1.orig.tar.bz2"
sha1 "a91c258e79acf30ec86a667e07f835e5e79342d8"
depends_on "gnupg"
depends_on "libgpg-error"
@ntalbott
ntalbott / verify
Created January 12, 2015 20:01
Verify secretsharing permutations
#!/usr/bin/env ruby
require "securerandom"
TESTS = (ARGV[0] || 1).to_i
N = (ARGV[1] || 4).to_i
K = (ARGV[2] || 2).to_i
BYTES = (ARGV[3] || 24).to_i
puts "Running #{TESTS} tests of n=#{N} k=#{K} with bytelength of #{BYTES}..."

Keybase proof

I hereby claim:

  • I am ntalbott on github.
  • I am ntalbott (https://keybase.io/ntalbott) on keybase.
  • I have a public key whose fingerprint is 5E2C CDC3 C673 A034 85BE EC4C D9B0 B680 05FC B035

To claim this, I am signing this object: