Skip to content

Instantly share code, notes, and snippets.

@tedsparc
tedsparc / PreprocessSystemProperties.java
Created August 29, 2012 13:00
AWS Elastic Beanstalk limits JVM properties to 200 chars, so to get more system properties than that, pack them into the other properties that are supported
import java.util.Properties;
import java.util.Enumeration;
public class PreprocessSystemProperties {
public static void main(String[] args) {
System.out.println("Before preprocessing");
print_properties();
String[] property_list = {"PARAM1", "PARAM2", "PARAM3", "PARAM4", "PARAM5"};
for (String this_property : property_list) {
@tedsparc
tedsparc / tailrate.pl
Created April 10, 2012 15:40
tailrate -- read STDIN, showing how many lines per X seconds; good for tailing an Apache access log, etc.
#!/usr/bin/perl
use strict;
use warnings;
# tailrate -- read STDIN, showing how many lines per X seconds
# Example invocation to tail a log file and print lines per second every 5 seconds:
# tail -f /var/log/httpd/access_log | perl tailrate.pl 5
my $interval = shift || 1;
@tedsparc
tedsparc / github-autodeploy.rb
Created March 22, 2012 22:59
Github post-receive hook for auto-deployment of a Web site document root
require "rubygems"
require "sinatra"
require "json"
# Configure this with the directory path for the Web server's clone of the Git repo
git_dir = '/var/www/origin.git'
# Configure the mappings between Git branches and Web document roots
branch_to_working_directory = {
'www' => '/var/www/www.example.com',
@tedsparc
tedsparc / bson2json.rb
Created February 8, 2012 00:21
Easily convert a MongoDB BSON file to JSON with Ruby
#!/usr/bin/ruby
# This script acts as a command-line filter to convert a BSON file (such as from mongodump) to an equivalent JSON file
# The resulting JSON file will be an array of hashes
# Any binary values from the BSON file are converted to base64 (such as Mongo's _id fields)
# I originally wrote this script so that Mongo files can be easily used with jsawk for
# offline data processing -- https://github.com/micha/jsawk
#
# To invoke, assuming mycollection.bson is a file from mongodump:
# ruby bson2json.rb < mycollection.bson > mycollection.json