Skip to content

Instantly share code, notes, and snippets.

Shannon Skipper havenwood

Block or report user

Report or block havenwood

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
havenwood / ascii_art_png.rb
Created Jul 4, 2019
A quick spike to turn ascii art into a png
View ascii_art_png.rb
# frozen_string_literal: true
require 'chunky_png'
ascii = <<~ASCII
@@@@@@ @@@@@@
@@@@@@@@@@ @@@@@@@@@@
@@@@@@@@@@@@@@ @@@@@@@@@@@@@@
havenwood / base58.rb
Created Jun 28, 2019
Example Base58 Implementation (showing haxx0r> on #ruby irc)
View base58.rb
module Base58
CHARACTERS = [*?1..?9, *?a..?k, *?m..?z, *?A..?H, *?J..?N, *?P..?Z].freeze
def encode(n)
chars = []
while n >= 58
chars.unshift BASE58_CHARACTERS[n % 58]
havenwood /
Created Jun 21, 2019
Debian 9 Installation Instructions for system wide Ruby 2.6.3 in /usr/local
sudo apt-get update
sudo apt-get install -y bison build-essential libffi-dev libgdbm-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev
cd /usr/local/src
tar -xjvf ruby-2.6.3.tar.bz2
cd ruby-2.6.3
./configure --prefix="/usr/local"
make -j"$(getconf _NPROCESSORS_ONLN)"
sudo make install
havenwood /
Last active Jun 29, 2019
Run ./ then browse to localhost:3000.
#!/usr/bin/env -S falcon serve --bind http://localhost:3000 --count 1 --config
# frozen_string_literal: true
require 'roda'
class App < Roda
<!DOCTYPE html>
<html lang="en">
havenwood / user.rb
Created Jun 11, 2019
suggestion for GeorgesLeYeti on #rubyonrails irc
View user.rb
class User < ApplicationRecord
validates :email, uniqueness: true, unless: :gmail?
validates :email, :unique_gmail, if: :gmail?
def unique_gmail
username, symbol, domain = email.partition '@'
email_without_periods = "#{username.delete('.')}#{symbol}#{domain}"
duplicate = self.class.find_by email: email_without_periods
errors.add :email, "#{duplicate} has already been taken" if duplicate
havenwood / censor.rb
Last active Jun 7, 2019
A solution to comet23's problem from #ruby irc
View censor.rb
def censor(sentence, words, redact: 'aeiou', filler: '*')
sentence.gsub /#{Regexp.union(words).source}/i do |word| redact, filler
censor 'Gosh darned it', %w[gosh darn shoot]
#=> "G*sh d*rned it"
havenwood / time_of_day.rb
Created May 31, 2019
A TimeOfDay class for leftylink on IRC
View time_of_day.rb
# frozen_string_literal: true
class TimeOfDay
include Comparable
HOURS_MATCH = /\A\d+/.freeze
MINUTES_MATCH = /(?<=#{SEPARATOR})\d+/o.freeze
attr_reader :hour
View application_helper.rb
module ApplicationHelper
def bell_notification_with_conditional_counter
keyword_arguments = {class: 'notification-bell'}
keyword_arguments[:data] = {count: '...'} if Notification.unread_count(current_user).nonzero?
icon("fas", "bell", **keyword_arguments)
View x.rb
class Hangman
DICTIONARY = ["cat", "dog", "bootcamp", "pizza"]
def initialize()
@secret_word = Hangman.random_word
@guess_word =, "-")
@attempted_chars =
@remaining_incorrect_guesses = 5
havenwood / foo.rb
Created Mar 9, 2019
example for #ruby irc
View foo.rb
class Foo
def Foo
Foo { puts 'hi' }
You can’t perform that action at this time.