Skip to content

Instantly share code, notes, and snippets.

View nevans's full-sized avatar

nicholas a. evans nevans

View GitHub Profile
@bitbckt
bitbckt / resque.rb
Created January 20, 2010 21:32
munin plugin for resque
#!/usr/bin/env ruby
require 'rubygems'
require 'resque'
HOST = ENV['host'] ? ENV['host'] : '127.0.0.1'
PORT = ENV['port'] ? ENV['port'] : '6379'
Resque.redis = "#{HOST}:#{PORT}"
@kbaum
kbaum / gist:892247
Created March 29, 2011 12:12
prune_workers_from_terminated_instance.rb
module Resque
def self.unregister_workers_for_host(host)
Resque.workers.select{|worker| worker.id.split(':').first==host}.each(&:unregister_worker)
end
end
Resque.unregister_workers_for_host("ip-10-250-192-51")
@pjb3
pjb3 / baltimore_hipster_guide.mdown
Created May 15, 2011 17:22
Hipster's Guide to Baltimore by @bmuller

Food

  • Little Italy has a number of great places (I think Amicci's has the best happy hour) and is accessible by the circulator's Orange Line.
  • Best pizza/risotto is Joe Squared on North Ave (purple line accessible).
  • Best Mexican is La Guadalupana on 500 South Wolfe Street (Orange/Green route will get you there). You will need to know some basic Spanish to order there, but the food is amazing.
  • Best odd assortment of random food is Lexington Market, the longest running market in the world(according to Wikipedia). It's accessible by heading north on the light rail and then walking West and would be good for lunch one day.
  • Best fancy food is Woodberry Kitchen, which is light rail accessible.
  • Best late night food is Never on Sunday on N Charles across the street from Helmand, which is open until 3:30am.
  • Best sushi is an easy pick - Kiku (1017 Light Street). It's a literal Mom and Pop operation with an amazing chirashi.
HAI
BTW Cheater's quine
I HAS A quine
GIMMEH LINEZ quine OUTTA "quine.lol"
I HAS A loop_max ITZ ALL quine
I HAS A loop_index ITZ 0
IM IN YR loop
IZ loop_index LIEK loop_max O RLY?
YA RLY
@rmoriz
rmoriz / install-ruby-debug-ruby-1.9.3.sh
Created November 29, 2011 02:17 — forked from hoverlover/install-ruby-debug-ruby-1.9.3.sh
ruby-debug in ruby-1.9.3 and rbenv
#!/bin/bash
cd /tmp
wget http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
wget http://rubyforge.org/frs/download.php/74596/ruby_core_source-0.1.5.gem
wget http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
wget http://rubyforge.org/frs/download.php/63094/ruby-debug19-0.11.6.gem
export RBENV_INCLUDE=$HOME/.rbenv/versions/1.9.3-p0/include/ruby-1.9.1/ruby-1.9.3-p0
gem install archive-tar-minitar
@avdi
avdi / apology101.markdown
Created March 22, 2012 17:36
How to apologize

Chances are your head's spinning right now. That accusation of bias caught you off guard, you got kind of defensive, and now all hell has broken loose. You're feeling attacked on all sides. You're a good person at heart, and having all these people treat you like the antichrist is pretty upsetting.

You need to say something, but you're probably not in the best headspace to write copy right now. So to help you along, here's my 100% guaranteed-or-you-money-back scandal defusement apology template:

@kddnewton
kddnewton / annoy_scanners_server.rb
Last active June 22, 2022 15:31
Annoy scanners
# I really don't like getting routing error notifications when scanners try to
# find vulnerabilities in our application. As such, this extends our routing
# to actually give a response, but it's likely not what they were looking for.
# If they're not using a headless browser, the `alert` is going to kill their
# productivity. If they are, they just might enjoy the youtube video anyway.
class AnnoyScannersServer
SCANNER_PATHS = %w[
/a2billing/admin/Public/index.php
/a2billing/common/javascript/misc.js
/a2billing/customer/templates/default/css/popup.css
@arsduo
arsduo / check_changed_coverage.rb
Last active June 9, 2023 19:10
SimpleCov Test Coverage for Files Changed in a Branch
output = `cat #{ENV["CIRCLE_ARTIFACTS"] || "."}/coverage/index.html | grep Changed -A 2 | grep "[0-9\.]*%"`
percentage_match = output.match(/([0-9\.]+)%/)
raise "Unable to determine test coverage change" unless percentage_match
RED = "\033[0;31m"
BOLD = "\033[1m"
NO_COLOR = "\033[0m"
percentage = percentage_match[0].to_f
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@kddnewton
kddnewton / json.rb
Last active October 6, 2023 09:25
JSON parser with pattern matching
require "json"
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] }
source = JSON.dump(struct)
tokens = []
index = 0
until source.empty?
tokens <<