This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; guile-utf8.scm | |
;; A quickly hacked together set of functions to turn | |
;; utf-8-encoded text (which Guile sees as raw bytes) into | |
;; ASCII-encoded HTML, with a few other functions for | |
;; getting the code values out of a UTF-8 string. | |
;; anon-let is a hacky macro to create a new scope while | |
;; allowing definitions within it to bind in its enclosing | |
;; scope. It also allows define-local which only defines | |
;; within that scope. It is used here to close over constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A basic intepreter for the untyped lambda calculus | |
enum Term | |
{ Num(int) | |
, Var(~str) | |
, Lam(~str, ~Term) | |
, App(~Term, ~Term) | |
, Let(~str, ~Term, ~Term) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.List (nub) | |
import MonadLib | |
import UI.TCOD.Console | |
import UI.TCOD.Console.Types | |
import UI.TCOD.Color | |
type Pt = (Int, Int) | |
type St = (Pt, [Pt]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
-- WARNING! This is very bad, quickly-written code, and should not be | |
-- trusted to do anything right! It does not support writing, and still | |
-- has several problems even for reading. Also it's ugly and bad. | |
import qualified Data.ByteString as BSS | |
import Data.ByteString.Lazy (ByteString) | |
import qualified Data.ByteString.Lazy as BS | |
import Data.Char (isDigit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import NiceMain | |
main = nicemain go where go x y z = print $ (x && y) || z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Aeson (decode, FromJSON) | |
import Data.ByteString.Lazy (ByteString) | |
import Data.Monoid (First(..), (<>)) | |
decodeOneOf :: (FromJSON x, FromJSON y) => ByteString -> Maybe (Either x y) | |
decodeOneOf bs = getFirst (First (fmap Left (decode bs)) <> First (fmap Right (decode bs))) | |
-- or more straightforwardly | |
decodeOneOf' :: (FromJSON x, FromJSON y) => ByteString -> Maybe (Either x y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::File; | |
use std::io::stdio::{stdin,print}; | |
use std::iter::range; | |
use std::os; | |
use std::rand::{Rng,task_rng}; | |
use std::vec::as_vec; | |
/* This program will take a file that describes a 'mad libs template' as | |
* argument and ask the user for the correct parts of speech in a random | |
* order, and then stitch the resulting mad lib together. This was a very |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This is a wrapper around cabal which will fail to execute if | |
# it's not invoked in a sandbox, although this behaviour can be | |
# worked around (with a warning message) using the command-line | |
# flag `--trust-me`. | |
contains_escape() { | |
# Find out whether the arguments contain --trust-me | |
ARR=$@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(unboxed_closures)] | |
#![feature(core)] | |
#![feature(io)] | |
use std::old_io::stdio::{stdin}; | |
use std::collections::HashMap; | |
// This is our toy state example. | |
#[derive(Debug)] | |
struct State { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# ghc wrapper script (for managing installed GHC versions) | |
# this is a small script I use that allows multiple simultaneous ghc | |
# installations. This makes the following assumptions about how | |
# you want to set up your system: | |
# - GHC version {X} is installed with prefix ~/install/ghc-${X} | |
# - A file naming the current selected GHC version is placed | |
# at ~/.current-ghc | |
# - cabal is configured to point to this script instead of ghc |
OlderNewer