Skip to content

Instantly share code, notes, and snippets.

View jferris's full-sized avatar

Joe Ferris jferris

  • thoughtbot, inc.
  • Cambridge, MA
View GitHub Profile
@jferris
jferris / list-public-s3-objects
Created April 30, 2024 15:01
List public S3 objects
#!/bin/sh
set -e
bucket="$1"
if [ -z "$1" ]; then
echo "Using: list-public-s3-objects BUCKET"
exit 1
fi
@jferris
jferris / random-color
Created January 27, 2023 16:00
Generate a random color name
#!/bin/sh
set -e
colors() {
cat <<EOS
acid
aero
alabaster
alizarin
@jferris
jferris / configmap.yaml
Last active October 28, 2024 01:42
Rails Kubernetes Manifests
apiVersion: v1
kind: ConfigMap
metadata:
name: example
namespace: default
data:
APPLICATION_HOST: example.com
LANG: en_US.UTF-8
PIDFILE: /tmp/server.pid
PORT: "3000"
@jferris
jferris / BufferedCommitter.scala
Created March 1, 2019 22:04
Buffered commit to Kafka
import cats.effect.{ContextShift, IO}
import cats.effect.concurrent.Ref
import cats.implicits._
import fs2.{Chunk, Pipe, Stream}
class BufferedCommitter(
config: Config,
consumer: Consumer,
pipe: Pipe[IO, Record, Unit])(implicit cs: ContextShift[IO]) {
def run: IO[Unit] =
@jferris
jferris / EitherT.scala
Created November 30, 2017 20:24
EitherT, partially applied
import cats.{Applicative, Functor}
import cats.data.EitherT
import scala.language.higherKinds
object EitherTF {
def apply[F[_], A]: EitherTPartiallyApplied[F, A] =
new EitherTPartiallyApplied[F, A]
}
@jferris
jferris / Demo.scala
Created November 16, 2017 21:24
Type Inference
import cats.data.EitherT
import cats.instances.future._
import cats.syntax.all._
import scala.concurrent.{ExecutionContext, Future}
/*
* Compiled with:
* Scala 2.12.4
* cats-core 1.0.0-RC1
* -Ypartial-unification
@jferris
jferris / Wrap2.scala
Last active April 20, 2017 20:08
Reproduction for Shapeless Issue: Can't Comap a type with two type parameters
import shapeless._
import ops.hlist._
case class Wrap2[T, U](t: T, u: U)
class WrapTest[T, WL <: HList, L <: HList] {
def unwrap
(wrapped: WL)
(implicit comapped: Comapped.Aux[WL, ({ type l[U] = Wrap2[T, U] })#l, L])
= true
@jferris
jferris / defaults.json
Created September 6, 2016 15:09
Chart.js defaults
{
"global": {
"responsive": true,
"responsiveAnimationDuration": 0,
"maintainAspectRatio": true,
"events": [
"mousemove",
"mouseout",
"click",
"touchstart",
@jferris
jferris / Example.hs
Created April 14, 2016 19:46
Arrows
{-# LANGUAGE Arrows #-}
import Control.Arrow
double :: Int -> Int
double x = x * 2
triple :: Int -> Int
triple x = x * 3
@jferris
jferris / JSON.hs
Created April 14, 2016 15:17
Test.Hspec.JSON
module Test.Hspec.JSON
( shouldBeJson
) where
import Control.Monad (when)
import Control.Monad.State (StateT, get, modify, runStateT)
import Control.Monad.Writer (Writer, execWriter, tell)
import Data.ByteString.Lazy (ByteString)
import Data.Function (on)
import Data.Monoid ((<>))