Skip to content

Instantly share code, notes, and snippets.

[1] pry(#<Context>)> u = User.new(user_id: "disobedientlib")
=> #<BggTools::User:0x0000000106557fb0 @user_id="disobedientlib">
[2] pry(#<Context>)> u.owned.map(&:rating).select { |r| r.to_i > 0 }.flat_map { |r| r.item.mechanics.map { |m| [m, r.to_i]}}.group_by {|k,v|k}.select { |k,v| v.size > 4 }.map {|k,v| [k, v.map(&:last).mean.round(2), v.size]}.sort_by {|k,v,p| -v}.first(15)
=> [["Deck Construction", 8.67, 6],
["Simulation", 8.42, 12],
["Turn Order: Progressive", 8.36, 11],
["Card Play Conflict Resolution", 8.36, 14],
["Hexagon Grid", 8.33, 15],
["Campaign / Battle Card Driven", 8.3, 10],
["Tags", 8.29, 7],
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 = []