Skip to content

Instantly share code, notes, and snippets.

Jason Gedge thegedge

Block or report user

Report or block thegedge

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thegedge
thegedge / profile-curl.sh
Created Nov 23, 2016
Run a series of curl requests and profile the mean / std. dev. of those requests
View profile-curl.sh
#!/bin/bash
profile-curl() {
local num_iters=500
local num_warmups=10
local -a times
for x in $(seq 1 "${num_warmups}"); do
curl -s -o /dev/null "$@" 2>&1
done
@thegedge
thegedge / thunderstorm_timelapse.py
Created Aug 7, 2016
Produces a timelapse video of a thunderstorm with an emphasis on lightning
View thunderstorm_timelapse.py
#!/usr/bin/env python
import cv2
import os.path
import sys
import tqdm
def frames(reader, indices=None, desc=None):
frame_count = int(reader.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
if indices is None:
indices = xrange(0, frame_count)
@thegedge
thegedge / native_libs.rb
Last active Jun 16, 2016
Read -l flags from Makefiles for gems with native extensions
View native_libs.rb
require 'set'
libs = Set.new
Gem::Specification.reject { |spec| spec.extensions.empty? }.each do |spec|
spec.extensions.each do |ext_path|
extconf_rb_path = Pathname.new(spec.gem_dir).join(ext_path)
makefile_path = extconf_rb_path.dirname.join('Makefile')
if makefile_path.readable?
last_was_lib_flag = false
makefile_path.readlines.map(&:strip).each do |line|
@thegedge
thegedge / find_unused_functions.rb
Last active May 25, 2016
Find (maybe) unused functions in Ruby
View find_unused_functions.rb
#!/usr/bin/env ruby
require 'optparse'
module CLI
extend self
PATHS_TO_CHECK = %w(app bin config engines lib script)
EXTENSIONS_TO_CHECK_FOR_DEFINITIONS = %w(.rb .rake)
EXTENSIONS_TO_CHECK_FOR_USAGE = EXTENSIONS_TO_CHECK_FOR_DEFINITIONS + %w(.yml .yaml .erb)
@thegedge
thegedge / app--controllers--v1-welcome_controller.rb
Created Apr 29, 2016
Rails versioned controllers via Accept header
View app--controllers--v1-welcome_controller.rb
class V1::WelcomeController < V1::ApplicationController
def index
respond_to do |format|
format.welcome { render plain: "testing v1" }
end
end
end
@thegedge
thegedge / example.tf
Created Oct 5, 2015
Forwarding module outputs for remote state or `terraform output`
View example.tf
// Foo has outputs "bar" and "baz"
module "foo" {
source = "..."
arg1 = "spam"
arg2 = "eggs"
}
// If you want `terraform output` or your remote state to show the outputs of
// `module.foo` you need to "forward" them along here:
output "bar" { value = "${module.foo.bar}" }
@thegedge
thegedge / multi_sg_rule.tf
Created Sep 30, 2015
Security group rule for multiple SGs
View multi_sg_rule.tf
resource "aws_security_group_rule" "allow_all" {
count = "${length(split(",", var.security_group_ids))}"
type = "ingress"
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = "${element(split(",", var.security_group_ids), count.index)}"
@thegedge
thegedge / gist:dcacba817bfb405afc59
Last active Sep 16, 2015
Terraform stack layout
View gist:dcacba817bfb405afc59
// Directory layout
stacks/
|__ us-east-1
|__ test
|__ vpc
|__ services
|__ apps
|__ foo
|__ bar
@thegedge
thegedge / example-use.tf
Last active Aug 29, 2015
Terraform zone module
View example-use.tf
resource "terraform_remote_state" "region" {
backend = "s3"
config {
bucket = "foo"
key = "bar"
region = "us-east-1"
}
}
module "sub1_zone" {
@thegedge
thegedge / main.tf
Last active Aug 29, 2015
Terraform count on aws_instance resource
View main.tf
variable "instances" {}
variable "flavor" {}
variable "ami" {}
variable "ami_list" {}
resource "aws_instance" "default" {
count = "${var.instances}"
ami = "${var.ami}"
instance_type = "${var.flavor}"
}
You can’t perform that action at this time.