I hereby claim:
- I am dbrady on github.
- I am davidbrady (https://keybase.io/davidbrady) on keybase.
- I have a public key ASCU2G-o7IcAgrhUI8FSzm7ePC9Bcf8gMD1UuQZIEnYF0Ao
To claim this, I am signing this object:
(defun run-vim () | |
(interactive) | |
(eshell) | |
(switch-to-buffer "*eshell*") | |
(insert "vi") | |
(eshell-send-input)) |
I hereby claim:
To claim this, I am signing this object:
# Names of classes and methods have been changed to protect the innocent. Namely | |
# my sweet, innocent, cherubic, and hopefully continuing, employment. | |
class MessageTwiddler | |
# Okay, so: say I want to make a class method private. What's the best idiom | |
# for doing this in Ruby circa 2017? | |
# In Ruby 2.0 I can do Options 1 or 2: | |
# Option 1 - Original Flavor, Most Explicit |
# Names of classes and methods have been changed to protect the innocent. Namely | |
# my sweet, innocent, cherubic, and hopefully continuing, employment. | |
class MessageTwiddler | |
# Okay, so: say I want to make a class method private. What's the best idiom | |
# for doing this in Ruby circa 2017? | |
# In Ruby 2.0 I can do Options 1 or 2: | |
# Option 1 - Original Flavor, Most Explicit |
;; Grateful thanks are given to Brian Marick (@marick) for helping me | |
;; write these. I got the original idea while reading through | |
;; http://xahlee.org/emacs/elisp_idioms.html, but couldn't work out | |
;; the elisp regexes. Brian Marick (@marick) stepped in and helped. He | |
;; took my tortured and broken camelcase-region and turned it into | |
;; something that actually worked. I then created | |
;; camelcase-word-or-region. I then wrote the snakecase versions but I | |
;; see now that all I did was copy the camelcase defuns over and, | |
;; meaning to go back and finish them Real Soon Now, forgot all about | |
;; them. I've had a quick look (2011-02-27) but elisp regexes are |
class Person | |
def poop | |
puts "I pooped today!" | |
end | |
# One common way to make a class method is to declare it amongst the instance | |
# methods prefixed with self... | |
def self.poop! | |
puts "Everybody pooped today!" | |
end |
EDIT: Was gonna tweetstorm this, then decided to just gist it. Enjoy. ;-) | |
Tweetstorm about deceptive code incoming. | |
First Point: People believe comments over the code, even if the code is obvious: x=1; /* put 2 in x */ <-- people believe the 2 | |
Second Point: People maintain code without maintaining (or sometimes even reading) the comments for that code | |
Third Point: Programmers love to optimize. Makes us feel smart. We think it makes us LOOK smart. But that way lies madness... | |
So. Dateline: Salt Lake City, 2002. I find this piece of assembly code: "XOR EAX, EAX ; PUT 1 IN EAX" | |
XOR any number with itself, you get 0. So the comment here was wrong, but if you don't know the XOR trick, it's outright deceptive | |
If you DO know the trick, it's still distracting and makes you stop and question your sanity for a moment | |
So I tracked down the commit history for the commit, and here's what happened (exit tweetstorm here if you don't want full history) |
#!/usr/bin/env ruby | |
require 'debug_inspector' | |
def find_matchers(keys) | |
matchers = [] | |
matcher_suffixes = ["IS"] | |
keys.any? do |key| | |
matcher_suffixes.any? do |suffix| | |
var = "%s_%s" % [key.upcase, suffix] | |
matchers << [var, ENV[var]] if ENV.key?(var) |