Skip to content

Instantly share code, notes, and snippets.

View paulp's full-sized avatar
🤫

Paul Phillips paulp

🤫
  • CAZ, Inc.
  • Cascadia Autonomous Zone
View GitHub Profile
@paulp
paulp / died.txt
Created September 20, 2017 03:08
Skull fracture.
Trench engulfment.
Worker electrocuted.
Worker fatally shot.
Worker was murdered.
Worker died in falll.
Possible heart attack.
Worker died in a fall.
Worker fell from lift.
Worker killed in fall.
@paulp
paulp / global.sbt
Last active October 16, 2018 19:09
continuous compilation of the sbt build
// These lines go in ~/.sbt/0.13/global.sbt
watchSources ++= (
(baseDirectory.value * "*.sbt").get
++ (baseDirectory.value / "project" * "*.scala").get
++ (baseDirectory.value / "project" * "*.sbt").get
)
addCommandAlias("rtu", "; reload ; test:update")
addCommandAlias("rtc", "; reload ; test:compile")
addCommandAlias("ru", "; reload ; update")
instance Monad f => Applicative (OptionalT f) where
pure = OptionalT . pure . Full
mf <*> ma = OptionalT $ do
optf <- runOptionalT mf
case optf of
Empty -> return Empty
Full f -> do
opta <- runOptionalT ma
return $ f <$> opta
instance Monad f => Monad (OptionalT f) where
f =<< x = OptionalT $ runOptionalT x >>= \case
Empty -> return Empty
Full a -> runOptionalT $ f a
instance Monad f => Monad (OptionalT f) where
f =<< x = OptionalT $ runOptionalT x >>= \case
Empty -> return Empty
Full a -> runOptionalT $ f a
@paulp
paulp / chrome-dns
Created August 15, 2018 23:23
Visibility into chrome's internal dns
#!/usr/bin/env bash
#
output () {
pup 'tbody[id="dns-view-cache-tbody"] tr json{}' \
| jq -r '.[].children[] | select(.tag == "td").text' \
| ag --nocolor --literal .
}
@paulp
paulp / lazylist.scala
Last active August 15, 2018 23:01
interesting LazyList evaluation semantics
% mscala -v 2.13.0-M4
Welcome to Scala 2.13.0-M4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_181).
Type in expressions for evaluation. Or try :help.
scala> val counter = {
| var count = 0
| () => {
| val res = try "x" + count finally count = count + 1
| try res finally println(res)
| }
@paulp
paulp / demo.sh
Last active June 8, 2018 09:16
Enabling sbt plugins from the command line in any sbt project
% sbtx dependencyGraph
... blah blah ...
[info] *** Welcome to the sbt build definition for Scala! ***
[info] Check README.md for more information.
[error] Not a valid command: dependencyGraph
[error] Not a valid project ID: dependencyGraph
% sbtx -Dplugins=graph dependencyGraph
... blah blah ...
object ttypes {
type ->[+A, +B] = (A, B)
type PairOf[+A] = A -> A
type SumOf[+A] = A \/ A
trait Interpret[T[_[_]]] {
type ^[Outer[_], Inner[_]] = Outer[T[Inner]]
trait Transform[F[_], G[_]] {
type FTF = F[T[F]]
/*
* Copyright 2014–2016 SlamData Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software