Skip to content

Instantly share code, notes, and snippets.

View flanger001's full-sized avatar
🧱

David Shaffer flanger001

🧱
View GitHub Profile
@flanger001
flanger001 / breakfast.py
Last active April 4, 2017 13:35
Eggs in a mug
# An object-oriented breakfast
class Mug(object):
def __init__(self, article):
self.article = article
print('You put a', self.article.get_name().lower(), 'in the mug')
def heat(self, heater, time):
heater.heat(self.article, time)
def get_article(self):
class A
def foo
'hello'
end
alias_method :bar, :foo
end
class B < A
def foo
'bye'
@flanger001
flanger001 / pre-commit
Last active October 18, 2017 22:46
Rubcop git hook
#! /usr/bin/env ruby
if system('bundle exec rubocop')
puts 'Rubocop is pleased.'
else
puts 'Rubocop demands penance.'
exit(1)
end
$animation: MoveBG 100s ease infinite;
body {
background: linear-gradient(240deg,#a24bcf,#4b79cf,#4bc5cf);
background-size: 400% 400%;
-webkit-animation: $animation;
-moz-animation: $animation;
-o-animation: $animation;
animation: $animation;
}
class String
def spongebob
each_char.map { |c| rand > 0.5 ? c.swapcase : c }.join
end
end
@flanger001
flanger001 / btw.md
Last active October 15, 2018 02:03
Babel + Typescript + Webpack resources
@flanger001
flanger001 / adding_a_key.md
Last active October 15, 2018 16:28
PGP stuff

Adding a new PGP key

Scenario:

I have a key that is currently on two computers. I want to do these things:

  • Create a new key with better security
  • Sign my old key with my new key
  • Revoke my old key
  • Export both keys
@flanger001
flanger001 / gem_update.rb
Last active April 30, 2020 19:11
Gem update script. Put this in bin/gem_update and chmod +x bin/gem_update. Thanks to https://www.honeybadger.io/blog/capturing-stdout-stderr-from-shell-commands-via-ruby/
#!/usr/bin/env ruby
require "open3"
puts "Create new branch? (press y to continue)"
print "> "
if gets.chomp.casecmp?("y")
system("git checkout master")
system("git branch -D gems/outdated")
system("git checkout -b gems/outdated")
@flanger001
flanger001 / development.rb
Last active May 27, 2020 17:50
This exists because Paperclip emits a lot of 404 errors if you clone your development db from production. If you do not clone your development db from production, you probably should not use this.
require "middleware/paperclip_middleware"
Rails.application.configure do
# other stuff
config.middleware.use(PaperclipMiddleware)
end
@flanger001
flanger001 / mysql
Last active April 13, 2022 12:51
Installing MySQL on macOS
MySQL
If the mysql2 gem fails to install, be sure your Xcode Command Line Tools are installed:
$ xcode-select --install
Then try reinstalling the gem with either of these 3 commands:
$ gem install mysql2 -- \
--with-cflags=\"-I$(brew --prefix)/opt/openssl/include\" \