Skip to content

Instantly share code, notes, and snippets.

@gtd
gtd / coverage_checker.rb
Created September 20, 2015 21:48
This class returns a set of *.rb files which are not present in a SimpleCov resultset
# This class returns a set of *.rb files which are not present in a SimpleCov resultset
#
require 'json'
require 'set'
class CoverageChecker
def missed_files(dir = 'app')
uncovered_files(dir)
end
@gtd
gtd / honeybadger-users.rb
Created March 10, 2015 03:16
review honeybadger error users
api_key = 'KqdN3zU5csyXqoEExjMx'
ma_project_id = '40406'
no_viewing_fault_id = '9518398'
project_id = ma_project_id
fault_id = no_viewing_fault_id
notices_url = "https://api.honeybadger.io/v1/projects/#{project_id}/faults/#{fault_id}/notices?auth_token=#{api_key}"
@gtd
gtd / keybase.md
Created September 22, 2014 15:17

Keybase proof

I hereby claim:

  • I am gtd on github.
  • I am gtd (https://keybase.io/gtd) on keybase.
  • I have a public key whose fingerprint is 6A21 777F D1B1 978E E1C4 56CF 6216 0416 3F17 C9CF

To claim this, I am signing this object:

module RandomCode
extend self
def generate(size = 8)
charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T U V W X Y Z }
(0...size).map{ charset[SecureRandom.random_number(charset.size)] }.join
end
end
function rt {
if [ $# -le 1 ] ; then
echo Running: ruby -Itest $1
ruby -Itest $1
else
p2=$2
param=$p2[0,5]
if [ $param = 'test/' ] ; then # Assumes all test files are in test/**
while [ "$1" != "" ]; do
if [ ! $test_files ]; then
@gtd
gtd / extract-rails-log-request-entries.sh
Created November 20, 2013 10:38
Extract Default Rails Log Request Entries
awk '
/^Started .+ "\/services\/samsung/ {printf("\n");flag=1}
flag {print}
/^Completed /{flag=0}
' production.log
cat production.log | awk '
/^Started PUT "\/staged\/films\/.*\/still"/ {printf("\n");flag=1}
flag {print}
/^ User ID: /{flag=0}
@gtd
gtd / simple_redis_profile.rb
Created September 29, 2011 12:23 — forked from joeyAghion/simple_redis_profile.rb
By sampling keys from your redis databases, this script tries to identify what types of keys are occupying the most memory.
#!/usr/bin/env ruby
# Evaluates a sample of keys/values from each redis database, computing statistics for each key pattern:
# keys: number of keys matching the given pattern
# size: approximation of the associated memory occupied (based on size/length of value)
# percent: the proportion of this 'size' relative to the sample's total
#
# Copyright Weplay, Inc. 2010. Available for use under the MIT license.
class PalindromeFinder
def initialize(string)
@input = string
end
def longest
max, out = 0, ''
@input.chars.to_a.each_index do |i|
index, length = max_palindrome(i)
max, out = [length, @input[index, length]] if length > max