Skip to content

Instantly share code, notes, and snippets.

View schar's full-sized avatar
💭
🦧

Simon Charlow schar

💭
🦧
View GitHub Profile
@cth
cth / re2fa.pl
Created May 6, 2009 11:22
converts regex -> NFA -> DFA
:- use_module(library(chr)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program performs conversions from
% regex -> NFA -> DFA
%
% It consists of three parts:
% 1. A regular expression parser (DCG)
% 2. A CHR program for converting DCG parse tree to an NFA
% 3. A CHR program for converting the NFA to a DFA
@puffnfresh
puffnfresh / do.sjs
Created October 4, 2012 04:40
do-notation using sweet.js
macro $do {
case { $y:expr } => {
$y
}
case { $x:ident <- $y:expr $rest ... } => {
λ['>=']($y, function($x) {
return $do { $rest ... }
});
}
}
@guifromrio
guifromrio / compress-pdf-with-gs.md
Created August 30, 2013 14:39
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
tell application "Skim"
set theFile to the file of the front document
set outText to ""
set newLine to ASCII character 10
# Get the relevant bibliographic information for the front PDF in Skim
tell application "BibDesk"
repeat with currentPub in publications of front document
if linked file of currentPub is {} then
set bibFile to 0
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
-- * Typed tagless-final interpreters for
-- * Linear Lambda Calculus
-- * de Bruijn indices
-- Linear lambda-calculus: each bound variable
-- is referenced exactly once.
@msullivan
msullivan / MicroKanren.hs
Created February 26, 2015 22:54
MicroKanren (μKanren) in Haskell
import Control.Monad
type Var = Integer
type Subst = [(Var, Term)]
type State = (Subst, Integer)
type Program = State -> KList State
data Term = Atom String | Pair Term Term | Var Var deriving Show
-- Apply a substitution to the top level of a term
@wenkokke
wenkokke / AB_grammar.hs
Last active January 24, 2024 14:51
AB grammars and extensible effects can do some fun things—depends on Eff1.hs found on <http://okmij.org/ftp/Haskell/extensible/>
{-# LANGUAGE TemplateHaskell, QuasiQuotes, FlexibleInstances, FlexibleContexts,
TypeFamilies, GADTs, TypeOperators, DataKinds, PolyKinds, RankNTypes,
KindSignatures, UndecidableInstances, StandaloneDeriving,
RecordWildCards, DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
module AB where
import Prelude hiding (lookup, lex)
import Control.Applicative ((<|>),empty)
import Data.Maybe (maybeToList)
@jtobin
jtobin / foo.hs
Created February 15, 2016 21:39
Independence and Applicativeness
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
import Control.Applicative.Free
import Control.Monad
import Control.Monad.Free
import Control.Monad.Primitive
import System.Random.MWC.Probability (Prob)
import qualified System.Random.MWC.Probability as MWC
@danidiaz
danidiaz / _FP reading lists.md
Last active May 23, 2024 04:02
assorted reading lists

A series of reading lists mostly related to functional programming.

@dylnb
dylnb / Paychecks.hs
Last active February 18, 2019 00:31
testing dependent currying
{-# LANGUAGE GADTs, FlexibleInstances #-}
module Paychecks where
type E = String
data Z
data S n
data Arity k where