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
#!/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
{
"gateway": {
"token": "XXX"
}
}
@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
@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 / example.rb
Created October 5, 2013 14:52
Thoughts on wrapping the Realex Vault API for ActiveMerchant
response = store(cc)
token = response.authorization #=> "#{payer_ref}:#{card_ref}"
update(token, {...})
@ntalbott
ntalbott / ksync
Created March 12, 2013 04:14
Syncs a directory structure to a non-touch Kindle and writes collections metadata.
#!/usr/bin/env ruby
require "rubygems"
require "pathname"
require "fileutils"
require "json"
require "digest/sha1"
require "awesome_print"
require 'potluck/recipes/smoke'
task :smoke_test do
failed_tests = []
curl_result = `curl -s -w "%{http_code}" https://id.spreedly.com/signin -o /dev/null`
failed_tests << "Id smoke test FAILURE." unless (curl_result == "200")
curl_result = `curl -s -w "%{http_code}" https://spreedly.com/ -o /dev/null`
failed_tests << "Public smoke test FAILURE." unless (curl_result == "200")
if ENV["STITCH"] == "1"
require "rack-proxy"
class Stitcher < Rack::Proxy
EXACT = %w(/ /terms /privacy)
PREFIX = %w(/pricing /about /support /gateways /assets)
def initialize(app)
@app = app
end
module Kernel
def backtrace
caller
end
end
@ntalbott
ntalbott / inventory.lua
Last active December 12, 2015 05:18
ComputerCraft Repo
function select(slot)
assert(slot <= 16)
turtle.select(slot)
return turtle.getItemCount(slot) > 0
end
function waitFor(slot)
while not select(slot) do
os.sleep(1)
end