Skip to content

Instantly share code, notes, and snippets.

View markburns's full-sized avatar
💭
👋

Mark Burns markburns

💭
👋
View GitHub Profile
/Users/markburns/code/delfos/lib/delfos/call_stack.rb:18: [BUG] Segmentation fault at 0x00000000000038
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin14]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
@markburns
markburns / show_class_instance_variables.rb
Last active December 25, 2016 07:15
If you ever use class instance variables, you'll run into state hell. This recursively searches a namespace for any instance variables and prints them out. Skipping circular constant definitions
def show_class_instance_variables(n)
puts "#{n} #{n.instance_variables}" if n.instance_variables.length.positive?
return unless (n.is_a?(Class) || n.is_a?(Module))
n.constants.each do |c|
next if n==c
klass = n.const_get(c)
if klass.is_a?(Class) || klass.is_a?(Module)
module DomainConcepts
def self.prepended(base)
base.class_eval do
before_action :set_view_paths
end
end
%i(index show edit new).each do |a|
define_method a do
super()
Process: ruby [82556]
Path: /Users/USER/*/ruby
Identifier: ruby
Version: 0
Code Type: X86-64 (Native)
Parent Process: zsh [64346]
Responsible: iTerm2 [632]
User ID: 501
Date/Time: 2016-10-11 05:57:48.373 +0100
@markburns
markburns / dbg.rb
Last active March 10, 2016 09:51
dbg.rb
require "binding_of_caller"
class BasicObject
def dbg(variable_name=nil)
puts ">" * 80
other_binding = binding.of_caller(1)
vars =
other_binding.eval("local_variables") +
other_binding.eval("instance_variables")
require 'faraday'
require 'faraday_middleware'
require 'byebug'
def connection
@connection ||=
Faraday::Connection.new 'http://www.letsrevolutionizetesting.com/' do |c|
c.request :json
c.response :json, :content_type => /\bjson$/
module I15r; end
module Visitable
def accept(visitor)
visitor.send visitor_method_name, self
end
def visitor_method_name
"visit_#{self.class.name}".gsub(/::/, "__")
end
editor = ENV['EDITOR']
mapping = {
[:textmate, :txmt, :tm] => :textmate,
[:sublime, :subl, :st] => :sublime,
[:macvim, :mvim, :vim] => :macvim
}
mapping.each do |matches, value|
matches.each do |m|
@markburns
markburns / pgp.txt
Created August 24, 2013 19:16
PGP public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: OpenPGP.js v.1.20130820
Comment: http://openpgpjs.org
xo0EUhkGSQEEAIzpd6WBTyNt7wdBenr6Dj9eDnyRRCsy/n6TO7ow1SOT6h+k
t+p8MvYO2G+TprApJeIiFlZPCA6RdP2FPhQePyBSbf3VRrDDlojmRXOs+iWr
yzT1CGrnkkc46wKque6c4BXtz2dVb+y1TSQfn8BaKTfY8pvrj9agbOPCaE2C
gMt1ABEBAAHNJ01hcmsgQnVybnMgPG1hcmt0aGVkZXZlbG9wZXJAZ21haWwu
Y29tPsKcBBABCAAQBQJSGQZKCRCf0oceVRzIIQAASRYEAIdxD0oOrjRWRDbi
NESuwAJG6vJtNdaQ1HLTZixDmUWPlHHcRuxzxg/mU+BPQUGdA29xck54dBsr
layout title date comments categories
post
Ruby Hacking Guide ch. 11: Finite-state scanner
2013-04-01 02:19
true
software
ruby
insanity