Skip to content

Instantly share code, notes, and snippets.

View timsears's full-sized avatar

Tim Sears timsears

  • Silicon Valley, CA
View GitHub Profile
@timsears
timsears / shell.nix
Last active December 3, 2019 20:04
paganini environment. includes python and dependencies. needs nixpkgs to contain cvxpy.
with import <nixpkgs> {};
# As of 2019-12-03 this requries nixpkgs-unstable, plus additional cvxpy derivations.
# Those can be found in https://github.com/teh/nixpkgs/tree/cvxpy.
# If your <nixpkgs> is managed by git, then one way to get cvxpy is ...
# git remote add teh git@github.com:teh/nixpkgs.git
# git checkout -b cvxpy teh/cvxpy
# git rebase nixpkgs-unstable
# Then your nixpkgs will contain the necessary derivations.
# Soon this step may be unnecessary.
stdenv.mkDerivation {
self: super:
let
lib = super.haskell.lib;
#addPkg = path: rest: lib.dontCheck (lib.dontHaddock (self.haskellPackages.callPackage path rest));
stdenv = super.stdenv;
pkgs = super.pkgs;
in {
haskellPackages = super.haskellPackages.extend (hself: hsuper: {
"Agda" = super.haskellPackages.callPackage
({ mkDerivation, aeson, alex, array, async, base, binary
#Usage to install;
#curl -Lks https://gist.githubusercontent.com/timsears/ee325ee4a0e60923cfc12c4cda561cb9/raw/dotfile-install | bash
git clone --bare https://github.com/timsears/dotfile.git $HOME/.dotfile
function dotfile {
git --git-dir=$HOME/.dotfile/ --work-tree=$HOME $@
}
mkdir -p .dotfile-backup
dotfile checkout
if [ $? = 0 ]; then
echo "Checked out dotfile project.";
@timsears
timsears / Main.hs
Created June 29, 2015 06:39
Simple Sudoku solver
module Main where
import Text.Printf
import Control.Applicative
import Data.List
import Data.Function (on)
import qualified Data.Map as M
import Data.Map ((!))
import Control.Monad
--import Control.Monad.Logic
@timsears
timsears / fizzbuzz.hs
Created April 9, 2015 13:59
fizzbuzz program in Haskell
-- | fizzbuzz
module Main where
import Control.Monad (join)
import Text.Printf (printf)
data FB = Fizz | Buzz | FizzBuzz deriving Show
-- lazy infinite lists
threes :: [Maybe FB]
@timsears
timsears / robot_example.hs
Created September 11, 2014 01:38
Code example from "Free Monads Just Got Cheaper" blog post
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ViewPatterns #-}
module Main where
import Fixed.FreeMonad
import Data.Interface.TSequence
import Control.Monad
import Control.Applicative
import qualified Control.Monad.Free as F
data FDirective next = FL next | FR next | FS