Skip to content

Instantly share code, notes, and snippets.

@luciferous
luciferous / # python@2 - 2018-03-08_20-42-24.txt
Created Nov 21, 2018
python@2 on macOS 10.11.6 - Homebrew build logs
View # python@2 - 2018-03-08_20-42-24.txt
Homebrew build logs for python@2 on macOS 10.11.6
Build date: 2018-03-08 20:42:24
View comonad-graph.md
layout title date comments author categories commentIssueId
post
A comonad of graph decompositions
2016-04-02 13:02:54 -0400
true
Rúnar
scala comonads
22
@luciferous
luciferous / help.md
Created Jun 25, 2016
Bazel: Python modules
View help.md

Why does Bazel build the Python module under app? Is there a parameter to make it build foo so that I can write from foo import bar? (Note: if I change foo_test.py to use from app.foo import bar the command below succeeds.)

This is my directory structure.

$ find .
.
./app
./app/foo
./app/foo/__init__.py
@luciferous
luciferous / Main.hs
Last active Jul 16, 2016
STM example
View Main.hs
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Network ( withSocketsDo, listenOn, PortID(..) )
import Network.Socket ( accept, close, recv, send, Socket )
import Control.Concurrent ( forkIO, threadDelay, ThreadId )
import Control.Concurrent.STM ( atomically
, orElse
, newTChan
, readTChan
@luciferous
luciferous / TestClose.scala
Created Mar 8, 2016
Test socket closed by remote
View TestClose.scala
import com.twitter.finagle.Http
import com.twitter.finagle.http.{Http => _, _}
import com.twitter.io.{Buf, Reader}
import com.twitter.util.Await
val tls = Http.client.withStreaming(enabled=true).withTlsWithoutValidation.newService("localhost:4433")
val plain = Http.client.withStreaming(enabled=true).newService("localhost:3000")
val tlsReq = Request(Version.Http11, Method.Get, "/", Reader.writable())
val tlsRes = Await.result(tls(tlsReq).liftToTry)
@luciferous
luciferous / Main.hs
Created Dec 20, 2015
HTTP Basic Authentication with Servant
View Main.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
module Main where
import Control.Monad.Trans.Either
import Data.Aeson
import GHC.Generics
import Servant
@luciferous
luciferous / gist:1846c46b9870cbd729ce
Last active Dec 1, 2015 — forked from anonymous/gist:7aa72601f708150a2870
HttpStreamingServer for mpeg2 videos
View gist:1846c46b9870cbd729ce
import com.twitter.finagle.http
import com.twitter.conversions.time._
import com.twitter.finagle.http.{Request, Response, Status}
import com.twitter.finagle.{Http, Service}
import com.twitter.io.{Buf, Reader, Writer}
import com.twitter.util.{Await, Future, Base64StringEncoder}
import sys.process._
object HttpStreamingServer extends App {
View 1.scala
sealed trait Value
sealed trait Prim[A] extends Value {
def value: A
}
case class StringPrim(value: String) extends Prim[String]
val x: Value = StringPrim("hi")
def get[A](v: Value): Option[A] = v match {
case p: Prim[A] => Some(p.value)
case _ => None
@luciferous
luciferous / AsyncStream.scala
Last active Mar 27, 2017
Too Cool for Spool
View AsyncStream.scala
package com.twitter.concurrent
import com.twitter.util.{Await, Future}
/**
* Value class to wrap the Cons cell.
*/
protected case class Cons[A](tuple: (A, AsyncStream[A])) extends AnyVal {
def head: A = tuple._1
def tail: AsyncStream[A] = tuple._2