Skip to content

Instantly share code, notes, and snippets.

View hoff2's full-sized avatar

Charles Hoffman hoff2

  • Iowa
View GitHub Profile
@hoff2
hoff2 / deploy.yml
Last active December 16, 2020 20:05
actions workflow to build a jekyll site and update it somewhere over rsync/ssh
name: Build and deploy Jekyll site to wherever
on:
push:
branches:
- master
jobs:
build-and-upload:
runs-on: ubuntu-16.04
@hoff2
hoff2 / Codec.scala
Created September 4, 2018 16:36
circe enumeration codec with better error message?
def enumEncoder[A <: Enumeration](a: A): Encoder[a.Value] =
Encoder.encodeString.contramap[a.Value](_.toString)
def enumDecoder[A <: Enumeration](a: A): Decoder[a.Value] =
Decoder.decodeString.emap(s =>
try {
Right(a.withName(s))
} catch {
case _: NoSuchElementException => Left(s"Invalid enumeration value, valid values are: ${a.values}")
})
@hoff2
hoff2 / gist:58419054708bac318959653f8c740fa7
Created July 19, 2018 21:46
error message at end of tests
{"@timestamp":"2018-07-19T16:46:14.228-05:00","@version":"1","message":"Failed to submit a listener notification task. Event loop shut down?","logger_name":"org.testcontainers.shaded.io.netty.util.concurrent.DefaultPromise.rejectedExecution","thread_name":"pool-8-thread-1","level":"ERROR","level_value":40000,"stack_trace":"java.util.concurrent.RejectedExecutionException: event executor terminated\n\tat org.testcontainers.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:821)\n\tat org.testcontainers.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:327)\n\tat org.testcontainers.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:320)\n\tat org.testcontainers.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:746)\n\tat org.testcontainers.shaded.io.netty.util.concurrent.DefaultPromise.safeExecute(DefaultPromise.java:760)\n\tat
~/dev/gripds-integration-tests(master) $ big up -d
run docker-compose -f /Users/chuckhoffman/dev/big/current-compose.yml up -d from "/Users/chuckhoffman/dev/big"
Starting big_zookeeper_1
Starting big_citydata-solr_1
Starting big_merchants-solr_1
Starting big_redis_1
Starting big_core-fetch_1
Starting big_dns_1
Starting big_hbase35_1
Starting big_grip-admin_1
@hoff2
hoff2 / gist:3a05a6bff6390d9ec1f6
Created January 6, 2016 20:59
Homebrew: "Error: undefined method `<' for nil:NilClass"
~ $ brew doctor
Error: undefined method `<' for nil:NilClass
Please report this bug:
https://git.io/brew-troubleshooting
/usr/local/Library/Homebrew/os/mac/xcode.rb:131:in `provides_autotools?'
/usr/local/Library/Homebrew/diagnostic.rb:1038:in `check_for_autoconf'
/usr/local/Library/Homebrew/cmd/doctor.rb:30:in `block in doctor'
/usr/local/Library/Homebrew/cmd/doctor.rb:23:in `each'
/usr/local/Library/Homebrew/cmd/doctor.rb:23:in `doctor'
/usr/local/Library/brew.rb:143:in `<main>'
### Keybase proof
I hereby claim:
* I am hoff2 on github.
* I am centipedefarmer (https://keybase.io/centipedefarmer) on keybase.
* I have a public key whose fingerprint is 65EE EFFD F4FF 4B3B 6F37 82A3 F8E7 1C46 A007 9449
To claim this, I am signing this object:
@hoff2
hoff2 / app.rb
Created August 8, 2013 21:04
wrapping a sinatra app around a static web site
# for those times when you have a static web site but then it turns out you
# need a contact form or some such.
# just sticking the whole site in public/ gets you most of the way there --
# the web server just serves up anything it finds there without calling on
# your app for anything
# but that doesn't work for the default index.html page for paths like
# "/" or "/foo".
@hoff2
hoff2 / gist:5378506
Created April 13, 2013 13:58
Rails 3.2.13, Ruby 2.0.0-p0, "rake cucumber:ok" spits out this annoying stack trace at the end if there are failing steps. "cucumber features" does not.
1 scenario (1 failed)
5 steps (1 failed, 3 skipped, 1 passed)
0m0.438s
rake aborted!
Command failed with status (1): [/Users/charleshoffman/.rvm/rubies/ruby-2.0...]
/Users/charleshoffman/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/charleshoffman/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `call'
/Users/charleshoffman/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils.rb:45:in `sh'
/Users/charleshoffman/.rvm/gems/ruby-2.0.0-p0@global/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in `sh'
/Users/charleshoffman/.rvm/gems/ruby-2.0.0-p0@aggress/gems/cucumber-1.2.5/lib/cucumber/rake/task.rb:104:in `run'
@hoff2
hoff2 / fibs.rb
Created October 6, 2012 14:48
yay Enumerator
fibs = Enumerator.new do |y|
recent = [0,1]
loop do
y << recent.last
recent = (recent << recent[0..1].inject(:+)).pop(2)
end
end
fibs.first(20) #=> [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]
@hoff2
hoff2 / gist:1323195
Created October 28, 2011 19:13
overriding #call in the singleton class of a Proc, a bad idea in the first place, but also:
ruby-1.9.2-p290 :030 > a = proc{'eh'}
=> #<Proc:0x000001009ac850@(irb):30>
ruby-1.9.2-p290 :031 > a.()
=> "eh"
ruby-1.9.2-p290 :032 > a[]
=> "eh"
ruby-1.9.2-p290 :033 > a.call
=> "eh"
ruby-1.9.2-p290 :034 > def a.call; super + '?'; end
=> nil