Skip to content

Instantly share code, notes, and snippets.

@jacaetevha
jacaetevha / errors-by-date-hour
Last active December 24, 2015 13:29
Parses a Heroku log (defaults to /var/log/heroku, but you can pass it a log file as the first argument to the script), then prints out the date and hour, the error code, the count, and the percentage of the total.
#!/bin/bash
# ---------------
# Example output:
# ---------------
# Date/Hour Error Count % of Total
# 3-Oct 03 code=H12 98 73.68%
# 3-Oct 04 code=H12 35 26.32%
LOG=${1:-/var/log/heroku}
@jacaetevha
jacaetevha / pdftk.rb
Created September 23, 2013 16:43 — forked from Echos/pdftk.rb
require 'formula'
class Pdftk < Formula
url 'http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-1.44-src.zip'
homepage 'http://www.pdflabs.com/'
md5 '9eb50fffcd621a627d387750c60982b4'
depends_on 'gcc' # with "--enable-java" option , required "Homebrew-alt" .
# via : https://github.com/adamv/homebrew-alt/
def install
stuff:
built:
- tested
- implemented
- broke
- fixed
delegated to:
- people
- groups
- machines
[__TICKET_NUMBER__]
@jacaetevha
jacaetevha / guard.bash
Created April 19, 2013 15:17
Guardfile bash completion
# bash completion for Guard groups
#
# INSTALL
#
# Place in your bash completions.d and/or source in your .bash_profile
#
# USAGE
#
# Type 'guard' and hit tab twice to get completions.
# To clear the cache, run guard_cache_clear() in your shell.
@jacaetevha
jacaetevha / output
Created December 17, 2012 14:52 — forked from anonymous/output
RE: http://eval.in/4817 ... Singleton methods add some cost of execution to objects in MRI 1.9.3, not much in MRI 1.8.7, and JRuby doesn't seem to be affected. Note: the original anonymous Gist was mine also (didn't realize I wasn't logged in).
~/.rvm/rubies/jruby-1.6.5/bin/ruby
before singleton method definition
0.991000 0.000000 0.991000 ( 0.990000)
after singleton method definition
0.641000 0.000000 0.641000 ( 0.641000)
~/.rvm/rubies/jruby-1.6.7.2/bin/ruby
before singleton method definition
0.554000 0.000000 0.554000 ( 0.555000)
@jacaetevha
jacaetevha / command-line output
Created December 11, 2012 21:15
drip on jruby-head doesn't seem to be helping. Test runs are still abominably slow -- in fact, tests take longer using drip than by running jruby directly, and my CPU is pegged at 355+% during test runs. Specs randomly fail (always with a java.lang.InternalError coming from java.lang.invoke.MethodHandleStatics.newInternalError(MethodHandleStatic…
$ echo $DRIP_INIT_CLASS
org.jruby.main.DripMain
$ cat dripmain.rb
require File.expand_path('./config/environment', __FILE__)
$ bundle exec guard
16:07:29 - INFO - Guard uses Growl to send notifications.
16:07:29 - INFO - Guard uses TerminalTitle to send notifications.
16:07:29 - INFO - Guard is now watching at '/Users/jrogers/Documents/Programming/samasource/sh3'
[27-Nov 22:18] ~/.rvm/rubies/jruby-1.7.0 (111.872 Kb) ]
! ./bin/jruby -v
jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (OpenJDK 64-Bit Server VM 1.7.0-u12-b02) [darwin-x86_64-java]
@jacaetevha
jacaetevha / sequel_reconnector.rb
Created September 28, 2012 17:30 — forked from qerub/sequel_reconnector.rb
Rack middleware that makes sure requests don't get a dead Sequel connection
class SequelReconnector
RETRY_LIMIT = 10 # Match this to your connection pool size.
def initialize(app, db)
@app = app
@db = db
end
def call(env)
retries = 0
@jacaetevha
jacaetevha / gist:3795784
Created September 27, 2012 19:02
Smalltalk syntax on a postcard
exampleWithNumber: x
"A method that illustrates every part of Smalltalk method syntax
except primitives. It has unary, binary, and keyword messages,
declares arguments and temporaries, accesses a global variable
(but not and instance variable), uses literals (array, character,
symbol, string, integer, float), uses the pseudo variables
true false, nil, self, and super, and has sequence, assignment,
return and cascade. It has both zero argument and one argument blocks."