Skip to content

Instantly share code, notes, and snippets.


Jack Danger JackDanger

View GitHub Profile
View rails-deprecation-count.rb
#!/usr/bin/env ruby
require 'pp'
DIR = File.expand_path(__dir__)
module Deprecations
extend self
PATTERN = /DEPRECATION WARNING: (?<message>.*) \(called from (?<source_method>.+) at (?<source_file>[\w\.\/]+):(?<source_line>\d+)/
# This script works on OS X with Homebrew Given a specific MySQL version this
# script will ensure that version is installed, nothing incompatible is
# blocking it from working, and the mysqld process responds to queries.
if [[ -z "${mysql_version}" ]]; then
echo "example: ${0} mysql@5.5"
View html view of docs in a google drive folder.js
function listDocs() {
var folderid = '{any folder id}';
var folder = DriveApp.getFolderById(folderid)
var contents = folder.getFiles();
var file;
var files = [];
while(contents.hasNext()) {
JackDanger /
Created May 20, 2017
Pry's `whereami` implemented for IPython
def whereami():
import traceback
for stack_frame in traceback.extract_stack():
if stack_frame[3] == 'from IPython.terminal.embed import embed; embed()':
line = stack_frame[1]
file = stack_frame[0]
if not line:
raise Exception("couldn't figure out the line number")

Keybase proof

I hereby claim:

  • I am jackdanger on github.
  • I am danger ( on keybase.
  • I have a public key whose fingerprint is 8FDA 10D5 FF86 25DC F4F0 2DFC 8A21 AF91 518D A66B

To claim this, I am signing this object:

View gist:b764a2940a776b6ed217
def sql
def sql_frozen
SQLo = /\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/o
SQL = /\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/
SQLFrozen = /\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/.freeze
View makefile.c
#include <ruby.h>
struct my_malloc {
size_t size;
void *ptr;
static void
my_malloc_free(void *p) {
struct my_malloc *ptr = p;
View gist:5afad5cd4fbb6ce7fbec
%w(pry method_source coderay slop).each do |name|
Dir["#{$GEM_HOME}/gems/#{name}-*"].each do |g|
$LOAD_PATH << "#{g}/lib"
require 'pry'
JackDanger / simple_ruby_profile.rb
Last active Aug 2, 2016
Fast way to profile a Ruby program
View simple_ruby_profile.rb
# In your code, right at the top of any source code file.
trap 'PROF' do"/tmp/profile-#{Time.current.to_f}", 'w') {|f| f.write caller(2).join("\n") }
pid = $$ { sleep 0.5; `kill -PROF #{pid}` }
# in a terminal
while true; do
sleep 0.1
View 1.9.3-p545-railsexpress.diff
diff --git a/.gitignore b/.gitignore
index 57557c9..7955376 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,3 +129,4 @@
# /win32/
diff --git a/array.c b/array.c