This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
Include in your rspec config like so: | |
RSpec.configure do |spec| | |
spec.include RSpec::RedisHelper, redis: true | |
end | |
This helper will clean redis around each example. | |
=end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Derived from https://github.com/apangin/jstackmem/blob/master/jstackmem.py | |
import bisect | |
import re | |
import subprocess | |
import sys | |
if len(sys.argv) < 2: | |
print("Calculate stack memory used by a Java process") | |
print("Usage: python jstackmem.py <pid>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT pid, | |
age(clock_timestamp(), query_start), | |
usename, | |
state, | |
-- get rid of newlines, runs of spaces | |
regexp_replace(query, E'[\\n\\r ]+', ' ', 'g' ) as query | |
-- , pg_terminate_backend(pid) -- UNCOMMENT TO KILL | |
FROM pg_stat_activity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def assert condition | |
raise unless condition | |
end | |
# | |
# @fields at the class level are singleton fields. | |
# Singleton fields may be initialized but this is not required. | |
# Singleton fields can only be accessed by singleton methods. | |
# Singleton fields are not inherited by subclasses (although singleton methods *are* inherited). | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def assert condition | |
raise unless condition | |
end | |
# | |
# @@fields are class fields, shared by all instances and all subclasses. | |
# Class fields MUST be initialized. | |
# Class fields can be accessed by instance methods. | |
# Class fields can be accessed by singleton methods. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /tmp | |
mkdir bash-fix | |
cd bash-fix | |
curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf - | |
cd bash-92/bash-3.2 | |
curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-052 | patch -p0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2014 Mark Lanett. | |
# Permission is hereby granted, free of charge, to deal in this software without restriction of any sort. | |
module Fluent | |
def self.included(base) | |
base.extend(ClassSingletonMethods) | |
end | |
module ClassSingletonMethods |