Skip to content

Instantly share code, notes, and snippets.


Mark Burns markburns

View GitHub Profile
markburns / problematic_variable_finder.rb
Last active Feb 14, 2019
Find class variables, class instance variables, global variables and cattr_accessors etc in all your dependencies
View problematic_variable_finder.rb
require 'parser/current'
require 'active_support/all'
require 'rspec'
require 'byebug'
require 'pstore'
module FsCaching
def store
@store ||=".gem_problems.pstore")
View gist:ababd7e5c8c8b89dc0ea1ee780e44159
const values = [true, false, 1, 0, -1, "true", "false", "1", "0", "-1", "", undefined, Infinity, -Infinity, [], {}, [[]], [0], [1], NaN]
var same = ((v==v2)==(v2==v));
if(!same){ console.log(v, v2, same)}
View prison_break.rb
module PrisonBreak
class Visit
attr_accessor :free_prisoner
attr_reader :prison, :payload
DISABLED_SYMBOLS = %w{, ` ( ? ! + <<}
DISABLED_WORDS = %w{send eval system exec popen rm puts require new load create file include free call push concat irb }
GUARD_RE = + DISABLED_WORDS).map {|i| Regexp.escape(i) }.join('|'))
View ruby_object_model_example.rb
module SomeClass
SomeClass == self
def self.a_class_method(options)
SomeClass == self
class << self
SomeClass.singleton_class == self
markburns / lint_spec.rb
Created Jul 24, 2017
run lint and db:seed in specs only if changed
View lint_spec.rb
# spec/lint_spec.rb
require "rails_helper"
RSpec.describe "Lint" do
it "FactoryGirl" do
should_run = directory_changed?("spec/factories") || directory_changed?("db")
next unless should_run
markburns / a.rb
Last active Jul 13, 2017
Defining methods at the top level scope
View a.rb
#!/usr/bin/env ruby
def do_something_probably_just_in_this_script!
puts "called in #{self} from #{caller[-1]}"
module HeresAnother
def this_one
puts "called in #{self} from #{caller[-1]}"
markburns / delfos_queries_ab.errors
Last active Jun 27, 2017
delfos bundler errors
View delfos_queries_ab.errors
View trace_point_usage.rb
require "binding_of_caller"
Thread.current[:current_thread_local_info] = "value set inside (main)"
class A
def something
t = do
Thread.current[:current_thread_local_info] = "value set inside A#something"
markburns / current-branch
Last active Aug 18, 2017
useful bash scripts for finding files/changed files/running specs etc
View current-branch
#!/usr/bin/env bash
git rev-parse --abbrev-ref HEAD | tail -2
View aliases.zsh
alias show-changed-directories="gd master --name-only | sort | sed -e 's/\/[^\/]*rb$//' |sed -e 's/\/.*\.js$//' | sed -e 's/\/.*\.haml$//' | sed -e 's/\/.*yml$//' | sort | uniq"
alias show-changed-specs="git diff master --name-only | grep spec.rb "
alias run-changed-specs="show-changed-specs | xargs zeus rspec"
alias update-pr="git checkout master && git pull --rebase && git checkout - && git rebase master"
alias docker-env-eval='eval "$(docker-machine env default)"'
alias docker-machine-refresh='(docker-machine stop || docker-machine kill) ; docker-machine start; docker-env-eval'
alias docker-setup="yes | docker-machine regenerate-certs && docker-env-eval && docker-machine start default"
You can’t perform that action at this time.