Skip to content

Instantly share code, notes, and snippets.

Avatar

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+)/
View ensure_mysql_is_installed_correctly.sh
#!/bin/bash
#
# 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.
#
mysql_version=$1
if [[ -z "${mysql_version}" ]]; then
echo "USAGE: ${0} MYSQL_VERSION_THAT_HOMEBREW_RECOGNIZES"
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
JackDanger / whereami.py
Created May 20, 2017
Pry's `whereami` implemented for IPython
View whereami.py
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]
break
if not line:
raise Exception("couldn't figure out the line number")
View keybase.md

Keybase proof

I hereby claim:

  • I am jackdanger on github.
  • I am danger (https://keybase.io/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
/\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/
end
def sql_frozen
/\A\s*(SELECT|INSERT|UPDATE|DELETE).*(FROM|JOIN)\s*`?(my_interesting|tables)`?/.freeze
end
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"
end
end
require 'pry'
@JackDanger
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
File.open("/tmp/profile-#{Time.current.to_f}", 'w') {|f| f.write caller(2).join("\n") }
pid = $$
Thread.new { sleep 0.5; `kill -PROF #{pid}` }
end
# 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 @@ y.tab.c
# /win32/
/win32/*.ico
+ext/win32ole/.document
diff --git a/array.c b/array.c