Skip to content

Instantly share code, notes, and snippets.

View peteoleary's full-sized avatar

Peter O'Leary peteoleary

View GitHub Profile
@peteoleary
peteoleary / tiered-web-app.json
Created November 1, 2020 19:04
Cloud Formation Tiered Web App
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Description here.",
"Parameters": {
"SubnetAvailabilityZone1": {
"Description": "Availability Zone for Subnet 1",
"Type": "String",
"Default": "us-west-2a"
},
"SubnetAvailabilityZone2": {
@peteoleary
peteoleary / convert_heroku_config_to_files.rb
Last active October 18, 2020 15:48
Converts output of 'heroku config' to separate files in /tmp/env directoru
regex = /([0-9A-Z\_]+)\:\s*(.*)/
ARGF.each do |line|
match_data = regex.match line
if match_data
File.write("./env/" + match_data[1], match_data[2], mode: "w")
end
end
package com.chefsfeed.spark
// Spark
import org.apache.spark.{
SparkContext,
SparkConf
}
import SparkContext._
@peteoleary
peteoleary / tail_heroku_log_for_swap.rb
Last active August 29, 2015 14:21
A simple Ruby command line tool which takes a Heroku log tail as STDIN and tries to detect an increase in swap space on a particular dyno
#!/usr/bin/env ruby
require 'time'
LINE_REGEXP = /(\d{4})-(\d{2})-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})\.(\d{6})\+(\d{2})\:(\d{2})\s(.+?)\[(.+?)\.(.+?)\]\:(.+)/
MAX_MEMORY = ARGV[0].to_f
APP = ARGV[1].to_s
printf "Max Memory is #{MAX_MEMORY}\n"
@peteoleary
peteoleary / gist:45cbbf94746567523ac8
Created February 4, 2015 00:24
Parse Penn Treebank strings into nodes and edges, easy to render with d3
function pennTreeParse(penn_string) {
function eatWhiteSpace(s) {
while (s.length && /\s/.test(s[0])) s = s.slice(1);
return s;
}
function isCharacter(c) {
return /^[a-z0-9ÀÈÌÒÙàèìòùÁÉÍÓÚÝáéíóúýÂÊÎÔÛâêîôûÃÑÕãñõÄËÏÖÜäëïöüçÇߨøÅ寿ÞþÐð]+/i.test( c );
}
@peteoleary
peteoleary / Family.scala
Created September 10, 2014 14:21
First working version of Family plugin for Craftbukkit server using Josh Cough's excellent Scala wrapper
package com.joshcough.minecraft.examples
import java.util.logging.Logger
import org.bukkit.entity.Player
import org.bukkit.Location
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.player.PlayerMoveEvent
import com.joshcough.minecraft._
import org.bukkit.block.Block
@peteoleary
peteoleary / logstash_conf.g4
Created September 9, 2014 04:17
ANTLR grammar for Logstash conf file format
grammar logstash_conf;
filler: (comment | WS)*;
comment: (WS? '#' .*? '\r'? '\n')+;
config: filler plugin_section (filler plugin_section)* ;
plugin_section: plugin_type filler '{'
filler (branch_or_plugin filler)*
'}';
plugin_type: ('input' | 'filter' | 'output');
branch_or_plugin: branch | plugin;
branch: r_if (filler else_if)* (filler r_else)?;