Skip to content

Instantly share code, notes, and snippets.

@max-power
max-power / phonetic.gemspec
Last active November 10, 2017 05:48
Phonetic Spelling: NATO, LAPD and lots more
Gem::Specification.new do |s|
s.name = 'phonetic'
s.version = '0.0.1'
s.platform = Gem::Platform::RUBY
s.author = 'Kevin Melchert'
s.email = 'kevin.melchert@gmail.com'
s.summary = 'Papa - Hotel - Oscar - November - Echo - Tango - India - Charlie - Sierra - Papa - Echo - Lima - Lima - India - November - Golf'
s.description = 'Phonetic Spelling: NATO, LAPD and lots more'
s.files = ['phonetic.rb']
@max-power
max-power / number_with_unit.rb
Last active November 11, 2017 04:36
Number with Unit
require 'delegate'
class NumberWithUnit < SimpleDelegator
def initialize(number, unit)
super number
@unit = unit
end
def to_s
"#{super}#{@unit}"
@max-power
max-power / age.rb
Last active December 10, 2017 18:45
Ruby Age Calculation
class Age
def initialize(dob)
@dob = dob
end
def now
at Time.now
end
def at(date)
@max-power
max-power / timer.rb
Last active December 8, 2023 22:06
Simple timing functions. Include it or use as standalone module
module Timer
module_function
def time unit = :microsecond
Process.clock_gettime(Process::CLOCK_MONOTONIC, unit)
end
def time_it start = time
yield
time_diff start
@max-power
max-power / base.css
Created March 7, 2024 11:11
Basic starter CSS
*, *::after, *::before {
box-sizing: border-box;
}
body { margin: 0; }
[hidden] { display: none; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
@max-power
max-power / tag.rb
Last active March 29, 2024 12:18
Very simple HTML-Tags in Ruby
class Tag
def initialize(name, content = nil, **attributes, &block)
@name = name
@content = block_given? ? yield : content
@attributes = attributes
end
def to_s
"<#{@name}#{attributes}>#{@content}</#{@name}>"
end