Skip to content

Instantly share code, notes, and snippets.

View courses.txt
Power and Politics in Today's World: https://www.youtube.com/playlist?list=PLh9mgdi4rNeyViG2ar68jkgEi4y6doNZy
Financial Markets: https://www.youtube.com/playlist?list=PL8FB14A2200B87185
The Moral Foundations of Politics: https://www.youtube.com/playlist?list=PL2FD48CE33DFBEA7E
Environmental Politics and Law: https://www.youtube.com/playlist?list=PL84DCD72C5B5DC403
Financial Theory: https://www.youtube.com/playlist?list=PLEDC55106E0BA18FC
View gist:14a38cbff2474feb40d223f308074723
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2cdef4202c1c cg-ruby-sem_sem "rails c" 19 minutes ago Up 19 minutes 3000/tcp cg-ruby-sem_sem_run_73d6529b9b23
$ cat Dockerfile.debug
FROM alpine
RUN apk update && apk add strace
CMD ["strace", "-p", "1"]
$ docker build -f Dockerfile.debug -t strace .
View vim-submatch.vim
<location>\(-\{-}\d\+\),\(-\{-}\d\+\)<\/location>
@jbodah
jbodah / find_unreferenced.rb
Last active Feb 22, 2019
finds unreferenced/dead methods
View find_unreferenced.rb
# Usage: find app/models -name '*.rb' | xargs -n 1 ruby find_unreferenced.rb
require 'parser/current'
class ASTProcessor
include AST::Processor::Mixin
attr_reader :possibly_unreferenced
def initialize
@possibly_unreferenced = []
View git-cc
#! /usr/bin/env ruby
require 'tty/prompt'
require 'tty/prompt/vim'
prompt = TTY::Prompt.new
branches = `git for-each-ref --sort=-committerdate --count=20 --format='%(refname:short)' refs/heads/`.each_line.map(&:rstrip)
branch = prompt.select("Choose a branch:", branches)
exec "git checkout #{branch}"
View gist:9ab329d62d9734a786b20a429879f119
# Processes nodes in depth-first order
class DepthFirstTraversal
def initialize(root, hierarchy = nil)
@root = root
@hierarchy = hierarchy
end
def traverse
stack = [@root]
order = []
View test_server.rb
#! /usr/bin/env ruby
$: << 'test'
require 'bundler/setup'
require 'socket'
require 'terminal-notifier' if ENV['NOTIFY']
module TestServer
class << self
SOCK = "test.sock".freeze
@jbodah
jbodah / autoyard.rb
Created Sep 21, 2018
autoyard spike
View autoyard.rb
require 'spy'
require 'spy/util'
TypeAnalysis = Module.new
TypeAnalysis.extend(Spy::API)
singleton_spy = TypeAnalysis.on_object(NegativeKeywordSelectorTrie)
singleton_spy = Spy::Util::TypeAnalysis.new(singleton_spy).decorate
class_spy = TypeAnalysis.on_class(NegativeKeywordSelectorTrie)
class_spy = Spy::Util::TypeAnalysis.new(class_spy).decorate
@jbodah
jbodah / arel_patch.rb
Created Sep 19, 2018
adding Arel-supported alias_column support to Rails
View arel_patch.rb
require 'arel/attributes/attribute'
module ColumnAlias
module ArelAttributePatch
def name
return super unless relation.engine.respond_to?(:column_aliases)
name_given = super
relation.engine.column_aliases[name_given] || name_given
end
end
@jbodah
jbodah / disk_bottleneck.sh
Created Jun 4, 2018
how to check for a disk bottleneck
View disk_bottleneck.sh
iostat -xmt 2
# Example output:
06/04/2018 03:29:38 PM
avg-cpu: %user %nice %system %iowait %steal %idle
11.14 0.00 0.75 1.00 0.13 86.98
Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %util
xvda 0.00 65.00 18.00 1450.50 0.21 23.29 32.79 6.17 4.20 0.08 11.40