Skip to content

Instantly share code, notes, and snippets.

@shajra
shajra / ParseOpts.scala
Last active August 29, 2015 14:10
illustration of my usage of scala-optparse-applicative
package actionstat.builtwith.load
package config
import java.io.File
import java.lang.String
import scala.{ StringContext, Unit }
import scala.collection.immutable.List
@shajra
shajra / 1.syntax.scala
Last active August 29, 2015 14:09
Took a while to get Unapply working. . . very open to some code review
case class ProcessMSyntax[F[_], MM[_], A]
(self: Process[F, MM[A]], trav: Traverse[MM]) {
def throughM[MB]
(c: Channel[F, A, MB])
(implicit
uBindB: Unapply[Bind, MB] { type M[X] = MM[X] })
: Process[F, uBindB.M[uBindB.A]] = {
val substC = uBindB.leibniz.subst[Channel[F, A, ?]](c)
ProcessFunctions.throughChannelM(self, substC)(uBindB.TC, trav)
@shajra
shajra / Result.scala
Last active August 29, 2015 14:09
an idea for error handling in scalaz-stream
package myorg.extn.scalaz.stream
sealed abstract class Result[E, O] {
def fold[A]
(cont: O => A, done: => A, failCont: E => A, failStop: E => A) =
this match {
case Cont(o) => cont(o)
case Done() => done
case FailCont(e) => failCont(e)
@shajra
shajra / IdOps.scala
Created November 5, 2014 01:20
Is this idea for a Phantom-like operator reasonable?
implicit class IdOps[A](a: A) {
def callNullable[B](f: A => B): Maybe[B] =
if (a != null) {
val b = f(a)
if (b != null) Maybe.just(b) else Maybe.empty
} else Maybe.empty
def ?>[B](f: A => B): Maybe[B] = callNullable(f)
package actionstat.extn.pirate
import io.mth.pirate.Flag
import io.mth.pirate.Flag._
import scalaz.Isomorphism.{<=>, Iso}
@shajra
shajra / invitation.md
Last active August 29, 2015 14:07
an open invitation

If you're interested in making great software by discovering the deeper truth of logic and abstraction, then this is an open invitation for your participation in our community. Unfortunately, most software communities are notoriously imbalanced, creating needless hurdles for people of various gender identities, races, religions, political groups, sexual orientation, and disabled communities (to name a few). Such exclusion services no one's best interest. So, we want to actively call for participation from anyone interested in making our software better.

We guarantee a safe environment where we promote well-reasoned arguments that lead to the greatest software we can possibly make. Unfortunately, along the way someone may make an error, or worse yet, exercise malice. We'll work hard towards keeping conversations objective and inclusive. Sometimes it's tough work, but we're completely invested in the process. If you feel a public forum has not served you well, please contact us privately so we have a ch

@shajra
shajra / nix_log.txt
Last active August 29, 2015 14:06
How do two different derivations have the same roots?
shajra bagel ~
$ nix-store -q --roots /nix/store/zr69y5131gwh9jjfpmrdbn17l30xm47v-bash42-028.drv | cat
cannot read potential root ‘/nix/var/nix/manifests’
/nix/var/nix/profiles/chroot-13-link
/nix/var/nix/profiles/default-10-link
/nix/var/nix/profiles/per-user/shajra/default-8-link
shajra bagel ~
$ nix-store -q --roots /nix/store/yarb0fn7xgrby4a00q1r1iys2i3rl7sv-bash42-030.drv | cat
cannot read potential root ‘/nix/var/nix/manifests’
@shajra
shajra / nix-store.log
Created September 3, 2014 21:03
Why isn't nix-store working here?
shajra bagel /nix/var/nix/profiles
$ readlink -f /nix/var/nix/profiles/chroot/bin/bash
/nix/store/q5wfq0i6w4p6a7155p4hia6p3n8rk7aq-bash-4.2-p47/bin/bash
shajra bagel /nix/var/nix/profiles
$ nix-store -qR /nix/var/nix/profiles/chroot/bin/bash
error: path ‘/nix/var/nix/profiles/chroot/bin/bash’ is not in the Nix store

BuiltWith Firehose API (DRAFT)

This is a draft proposal for BuiltWith's Firehose web service API. It leans a bit on HTTP and uses some status codes from spec extensions and custom media types. If a user agent only accepts application/json, the API should still work as each representation is still JSON. The only thing a user agent would lose is a clear indication of the contract of the payload, which specifies how to parse it beyond just JSON.

This covers enough to give a feel for the API, but probably isn't yet comprehensive for all the edge cases.

Submitting a Request

Request

@shajra
shajra / free1.scala
Last active August 29, 2015 14:03 — forked from danclien/step1.scala
// Implementing functor manually
import scalaz._, Scalaz._, Free.liftF
sealed trait TestF[+A]
case class Foo[A](o: A) extends TestF[A]
case class Bar[A](h: (Int => A)) extends TestF[A]
case class Baz[A](h: (Int => A)) extends TestF[A]
implicit def testFFunctor[B]: Functor[TestF] = new Functor[TestF] {