Skip to content

Instantly share code, notes, and snippets.

@ktheory
ktheory / simple-note-backup.rb
Created December 2, 2010 23:11
Script to automatically export simplenote data from http://simplenote-backup.appspot.com/
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
require 'yaml'
config = YAML.load_file(File.expand_path("~/.simple-note-backup.yml"))
email = config['email']
password = config['password']
@ktheory
ktheory / Readme.md
Last active November 26, 2025 10:44
Easily make HTTPS requests that return promises w/ nodejs

Javascript request yak shave

I wanted to easily make HTTP requests (both GET & POST) with a simple interface that returns promises.

The popular request & request-promises package are good, but I wanted to figure out how to do it w/out using external dependencies.

The key features are:

  • the ability to set a timeout
  • non-200 responses are considered errors that reject the promise.
  • any errors at the TCP socker/DNS level reject the promise.
@ktheory
ktheory / dd.log
Last active November 10, 2023 23:41
EC2 EBS-SSD vs instance-store performance on an EBS-optimized m3.2xlarge
# /tmp/test = EBS-SSD
# /mnt/test = instance-store
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
268435456 bytes (268 MB) copied, 3.26957 s, 82.1 MB/s
root@ip-10-0-2-6:~# dd bs=1M count=256 if=/dev/zero of=/tmp/test
256+0 records in
256+0 records out
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 8.
Event,Status,Event category,Region / ZoneInfo,Start time,Last update time,Affected resources
Operational issue - Billing (Global),Closed,Issue,-,"June 15, 2022 at 9:15:54 PM UTC-4","June 15, 2022 at 9:53:46 PM UTC-4",-
Operational issue - ELB (N. Virginia),Closed,Issue,us-east-1,"June 9, 2022 at 9:52:48 PM UTC-4","June 10, 2022 at 2:38:31 AM UTC-4",-
CertificateManager renewal state change,Completed,Scheduled change,us-east-1,"June 10, 2022 at 1:17:02 AM UTC-4","June 10, 2022 at 1:17:04 AM UTC-4",1 entity
Operational issue - Route53 (Global),Closed,Issue,-,"May 26, 2022 at 10:21:35 PM UTC-4","May 27, 2022 at 1:24:40 AM UTC-4",-
Operational issue - Billing (N. Virginia),Closed,Issue,us-east-1,"May 25, 2022 at 5:22:21 PM UTC-4","May 25, 2022 at 7:05:09 PM UTC-4",-
Operational issue - Billing (Global),Closed,Issue,-,"May 25, 2022 at 6:53:50 PM UTC-4","May 25, 2022 at 6:58:45 PM UTC-4",-
Operational issue - Kinesis (Stockholm),Closed,Issue,eu-north-1,"May 19, 2022 at 2:44:47 PM UTC-4","May 19, 2022 at 3:29:58 PM
@ktheory
ktheory / check_aws_status.rb
Created January 13, 2012 05:11
Nagios plugin to check AWS Status RSS feeds
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'net/http'
# check_aws_status.rb
# A nagios plugin for fetching RSS feeds from http://status.aws.amazon.com.
# Source: https://gist.github.com/1604786
# Written by Aaron Suggs: https://github.com/ktheory
@ktheory
ktheory / redis.md
Created August 25, 2014 22:56
Redis hash benchmarks

Determine the memory impact of storing indicator counts in one big hash, or several smaller hashes.

See the redis memory docs for the advantages of several smaller hashes.

Test 1: One big hash

Store 10mm values in one big hash. Code:

r = Redis.new
@ktheory
ktheory / README.rdoc
Created April 14, 2011 18:12
An example for logging Fog requests in a Rails app

Instrument Fog Requests in Rails

This code adds debug statements to the rails log for each fog reqests (similar to how active record shows SQL queries):

Fog AWS Compute Request (803.0ms)  [ {"Action"=>"DescribeInstances", ...} ]

The end of the request includes cumulative Fog info:

Completed 200 OK in 6043ms (Views: 2955.0ms | ActiveRecord: 319.9ms | Fog: 1642.6ms, 4 reqs)
@ktheory
ktheory / vault-ecs-approle-s3.md
Last active January 20, 2018 14:41
Idea for authorizing ECS tasks with Vault using AppRole and S3

AWS ECS auth with AppRole and S3

I'm interested in having AWS ECS services authenticate to Vault (like issue #1298).

Here's an idea for how to implement ECS auth using recent features, like Vault's AppRole auth backend, and IAM roles per ECS task.

I'm eager to hear if folks think it's a reasonable approach.

@ktheory
ktheory / enumerable_pluck.rb
Created February 15, 2012 22:54
An Enumerable#pluck method for ruby
module Enumerable
def pluck(key)
map {|obj| obj[key] }
end
end
#!/usr/bin/env ruby
##
# Restore simplenote backup
#
# If you want to restore your Simplenote for Mac database, you can use this script.
# I created it for this issue:
# http://help.simplenote.com/customer/en/portal/questions/2773965-most-of-my-notes-were-deleted?new=2773965
#
# First, find a good backup of your simplenote database stored in