Skip to content

Instantly share code, notes, and snippets.

View kwstannard's full-sized avatar
🌎
On the planet Earth

Wolf kwstannard

🌎
On the planet Earth
  • Andros
  • New York City
View GitHub Profile
@kwstannard
kwstannard / foo.sh
Last active September 24, 2019 20:42
dotenv, but its a one line bash function
$ be() { if [ -f .env ]; then env $(<.env grep -v "^#") bundle exec "$@"; else bundle exec "$@"; fi; }
$ echo HELLO=WORLD > .env
$ echo "# a comment" >> .env
$ be ruby -e 'puts ENV["HELLO"]'
WORLD
@kwstannard
kwstannard / line lengths
Created September 8, 2020 23:52
Every line in makery ordered by line length
[[3, "end"],
[3, "end"],
[3, "end"],
[3, "end"],
[5, " end"],
[5, " end"],
[5, " end"],
[5, " end"],
[5, " end"],
[5, " end"],
@class_generator = ->(name, attrs) {
file = "tmp/meta_classes/#{name.underscore}.rb"
FileUtils.mkdir_p(File.dirname(file))
template = File.write(file, ERB.new(<<TEMP, nil, "%").result(binding))
class <%= name %>
attr_accessor <%= attrs.map(&:inspect).join(', ') %>
def initialize(<%= attrs.join(", ") %>)
% attrs.each do |attr|
@<%= attr %> = <%= attr %>
@kwstannard
kwstannard / gist:613cebba33eaf0bf767d473d9e5eaa57
Last active October 24, 2020 19:05
a logger with no if statements
require 'active_support/core_ext/string'
module Logger
class Null
def initialize
@blob = {}
end
def unknown(*); end
def fatal(*); end