Skip to content

Instantly share code, notes, and snippets.

View markburns's full-sized avatar
💭
👋

Mark Burns markburns

💭
👋
View GitHub Profile
@markburns
markburns / replace
Created December 28, 2023 05:50
replace
#!/bin/bash
# Find and replace by a given list of files supporting multiline matching.
#
# Usage: replace "find_pattern" "replace_with" **/*.rb
find_this="$1"
shift
replace_with="$1"
shift
@markburns
markburns / choose_1_or_2_or_both.rb
Created December 27, 2023 18:10
interactify ideas
# 1
class SomeOrganizer
include Interactify
organize \
self.if(:key_set_on_context,
self.chain(DoThingA, ThenB, ThenC),
self.chain(DoDifferentThingB, ThenDifferentC)
),
EitherWayDoThis
@markburns
markburns / flow-pr
Created May 26, 2021 08:12
create draft pr
#!/usr/bin/env bash
branch=${1:-$(current-branch)}
base_branch=${2:-develop}
# git push --force-with-lease || git push --set-upstream origin $branch
mkdir -p tmp/.github
VIM_FILE='tmp/.github/pr.md'
rm -f tmp/.github/pr.md

10:00 awesome print

> require 'ap'
> ap 1.methods

9:45 and get this

### Keybase proof
I hereby claim:
* I am markburns on github.
* I am markburns (https://keybase.io/markburns) on keybase.
* I have a public key ASBr1rTAPuZ3Ckll7M_n6ba4hmpKz9C9U7dcJNZ5yMs87Ao
To claim this, I am signing this object:
@markburns
markburns / problematic_variable_finder.rb
Last active September 15, 2022 11:53
Find class variables, class instance variables, global variables and cattr_accessors etc in all your dependencies
require 'parser/current'
require 'active_support/all'
require 'rspec'
require 'byebug'
require 'pstore'
module FsCaching
def store
@store ||= PStore.new(".gem_problems.pstore")
end
const values = [true, false, 1, 0, -1, "true", "false", "1", "0", "-1", "", undefined, Infinity, -Infinity, [], {}, [[]], [0], [1], NaN]
values.forEach(function(v){
values.forEach(function(v2){
var same = ((v==v2)==(v2==v));
if(!same){ console.log(v, v2, same)}
})
})
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 = Regexp.new((DISABLED_SYMBOLS + DISABLED_WORDS).map {|i| Regexp.escape(i) }.join('|'))
module SomeClass
SomeClass == self
def self.a_class_method(options)
SomeClass == self
end
class << self
SomeClass.singleton_class == self
@markburns
markburns / lint_spec.rb
Created July 24, 2017 15:44
run lint and db:seed in specs only if changed
# 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
FactoryGirl.lint