Skip to content

Instantly share code, notes, and snippets.

View JackDanger's full-sized avatar

Jack Danger JackDanger

View GitHub Profile
#!/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+)/
#!/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"
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 06:35
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]
break
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 (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:

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
#include <ruby.h>
struct my_malloc {
size_t size;
void *ptr;
};
static void
my_malloc_free(void *p) {
struct my_malloc *ptr = p;
%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 August 2, 2016 18:05
Fast way to profile a Ruby program
# 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
@JackDanger
JackDanger / 1.9.3-p545-railsexpress.diff
Last active August 29, 2015 14:02 — forked from xaviershay/require-performance-fix-r31758.patch
Xavier Shay's Kernel#require speedup
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