Skip to content

Instantly share code, notes, and snippets.

📝
Documenting things

Brandon Weaver baweaver

📝
Documenting things
Block or report user

Report or block baweaver

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tutor_subjects.rb
user_id_tp = tutor_profiles.index_by(&:user_id)
tutor_subjects = TutorSubject
.where(tutor_id: user_id_tp.keys)
.group_by(&:tutor_id)
.to_h { |uid, subjects| [user_id_tp[uid], subjects.map(&:subject_id)] }
# Faster
user_id_tp = tutor_profiles.index_by(&:user_id)
hash_of_arrays = Hash.new { |h,k| [] }
@baweaver
baweaver / pre_2019_article_difficulty.md
Last active Jan 28, 2019
Pre 2019 article difficulty rankings for some of my writings
View pre_2019_article_difficulty.md

Pre 2019 Articles by Difficulty Ranking

Posts are referenced doubly by difficulty then by chronological release order. Articles with a (+x) notation contain an advanced section that is not necessary reading, but dives into more advanced subject matter as a post-article exploration.

Beginner

Requires no prerequisite knowledge. Frequently these articles are not directly programming related, and address other topical areas.

This ranking is more likely to grow in 2019, but in the mean time I would suggest reading the content that Mehdi has been writing over the past few years.

@baweaver
baweaver / argument_ripper.rb
Created Dec 31, 2018
First round of argument ripper
View argument_ripper.rb
# Based on: https://twitter.com/josh_cheek/status/1079827841095749632
require 'method_source'
require 'parser/ruby25'
module ArgRipper
class << self
def get_args(meth)
Parser::Ruby25
.parse(meth.source)
@baweaver
baweaver / sf.rb
Created Dec 27, 2018
Experimental version of Sf, pre-release
View sf.rb
class Sf
attr_reader :operations
OPERATORS = %i(+ - * / % < > <= >= == && & || |)
INSTANCE_OP = -> name {
-> method_name, *args, **kwargs, &fn {
@operations.push(method_name: name, args: args, kwargs: kwargs, fn: fn)
self
@baweaver
baweaver / sf.rb
Created Dec 27, 2018
Redux of Stack Functions, testing a few things out
View sf.rb
class Sf
attr_reader :operations
def initialize(operations)
@operations = operations
end
def self.method_missing(method_name, *args, **kwargs, &fn)
p where: 'self.method_missing', method_name: method_name, args: args, kwargs: kwargs, fn: fn
@baweaver
baweaver / parser_error.rb
Created Dec 9, 2018
Why does Ruby break on this?
View parser_error.rb
class Foo
attr_accessor :bar
def initialize
@bar = 99
end
def baz
puts bar
@baweaver
baweaver / definitive_lemur_archive.md
Created Dec 7, 2018
Archive of all the lemur talks, put here until I redo the homepage later.
View definitive_lemur_archive.md

The Definitive Lemur Archive

A collection of links and resources pertaining to the lemurs and presentations involving them.

Why the Lemurs?

That's a good question, and one I frequently get. These articles dive into that subject

@baweaver
baweaver / paste_tmux_pry.md
Created Dec 2, 2018
Pasting in Pry with TMUX
View paste_tmux_pry.md
@baweaver
baweaver / ruby_quotes.txt
Created Oct 20, 2018
Best of Ruby IRC channel quotes
View ruby_quotes.txt
phaul - I don't know :) I don't understand you code :)
baweaver - Ah good
baweaver - that makes two of us
View destructure_method.rb
def destructure(method_name)
# Intercept the original class
meta_klass = class << self; self end
# Save the original method as a proc
method_proc = method(method_name)
# We only want to do this for keyword argument type
# methods
unless method_proc.parameters.all? { |t, _| t == :key }
You can’t perform that action at this time.