Skip to content

Instantly share code, notes, and snippets.

@charleso
charleso / Transformer.java
Created October 13, 2011 07:35
Spot the bug...
public class Transformer {
private LegacyScreenImpl screen;
public LegacyScreenImpl asLegacyScreen(Model model, String previousScreen) {
screen = asLegacyScreen(model);
screen.setPreviousScreenName(previousScreen);
return screen;
}
import sys, os, os.path
import signal
from threading import Thread
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SimpleHTTPServer import SimpleHTTPRequestHandler
class PUTHandler(SimpleHTTPRequestHandler):
def do_PUT(self):
length = int(self.headers['Content-Length'])
content = self.rfile.read(length)
@charleso
charleso / default.nix
Last active August 29, 2015 14:00
Trying to depend on a nix file in another repository
{ pkgs ? import <nixpkgs> {} }:
let
a = import pkgs.fetchgit {
# This repo contains default.nix
url = "file:///...";
rev = "0657ac75791c8d4a0a3d68d8705151fa6c756f66";
} {};
in rec {
# What do I need to do here?!? It throws 'error: cannot coerce a function to a string'
# Eventually I'm hoping to use this as a buildInput
@charleso
charleso / ylj2015-submissions
Last active August 29, 2015 14:15
YLJ 2015 Submission - Practical property-based testing
Category:
Talk
Target:
Intermediate
Language:
@charleso
charleso / FoldM.scala
Created August 29, 2015 03:49
Playing around with different ways to break out of FoldM
package com.ambiata.origami
import scalaz._, Scalaz._
trait FoldM[M[_], T, U] { self =>
type S
def start: M[S]
def fold(s: S, t: T): M[S]
def end(s: S): M[U]
@charleso
charleso / Data.hs
Last active October 10, 2018 22:22
Generic functional apply using Reader - replying to https://twitter.com/typesthings/status/1049983980395610113
-- A data type with a generic result for each function
data Foo m =
Foo {
a :: Int -> m Bah
, b :: String -> String -> m Bah
}
-- Generic helper for applying a function to each function of Foo
--
-- Depending on the intent of the question this might be "cheating" because
- sbt.ParseKey$.An explicitly specified axis is always parsed to that explicit value: Falsified after 2720 passed tests
> StructureKeyMask(Env:
Tasks:
aΑ͂ (delegates: )
Build a2:I;#b :
Project A
Delegates:
ProjectRef(a2:I;#b,A0)
ProjectRef(a2:I;#b,A00)
Configurations:
@charleso
charleso / ArbitraryFileTreeNew.scala
Last active June 30, 2020 03:19
Generator of random file trees for Scalacheck
package com.example
import java.nio.file._
import org.scalacheck._, Gen._, Prop._
import scala.reflect.io.Directory
sealed trait FileTree
object FileTree {