Skip to content

Instantly share code, notes, and snippets.

https://mazzo.li/posts/fast-pipes.html
#! /usr/bin/env ruby
require 'nokogiri'
require 'set'
class Object
def as_node
Node.new(self)
end
end

linux notes

List all files in a pkg

$ dpkg -L ulauncher | grep service

Book systemd service

@jbodah
jbodah / courses.txt
Created April 19, 2021 00:31
courses
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
$ 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 .
<location>\(-\{-}\d\+\),\(-\{-}\d\+\)<\/location>
@jbodah
jbodah / find_unreferenced.rb
Last active February 22, 2019 18:16
finds unreferenced/dead methods
# 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 = []
@jbodah
jbodah / git-cc
Created February 4, 2019 15:39
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}"
# Processes nodes in depth-first order
class DepthFirstTraversal
def initialize(root, hierarchy = nil)
@root = root
@hierarchy = hierarchy
end
def traverse
stack = [@root]
order = []
@jbodah
jbodah / test_server.rb
Last active November 21, 2018 20:57
test server
#! /usr/bin/env ruby
$: << 'test'
require 'bundler/setup'
require 'socket'
require 'terminal-notifier' if ENV['NOTIFY']
module TestServer
class << self
SOCK = "test.sock".freeze