Skip to content

Instantly share code, notes, and snippets.

View simonmichael's full-sized avatar

Simon Michael simonmichael

View GitHub Profile
-- test for hsSDL unknown symbol issue on mac OSX leopard
--
-- with macports sdl libs and hackage SDL libs installed,
-- this script compiles and runs via ghc --make, but via
-- runhaskell gives an error like:
-- /Users/simon/.cabal/lib/SDL-0.6.2/ghc-6.12.3/HSSDL-0.6.2.o: unknown symbol `_SDL_FreeSurface'
import Graphics.UI.SDL (getTicks)
main = do
-- frame-based animation, SDL
mainloop1 :: Game -> IO ()
mainloop1 game@Game{fpsmgr=fpsmgr,time=t0} = do
t1 <- SDL.getTicks
game' <- handleEvents game
let game'' = step game'
t2 <- SDL.getTicks
sdlRender game''
t3 <- SDL.getTicks
Framerate.delay $ fpsmgr
-- | Apply a function the specified number of times.
applyN :: Int -> (a -> a) -> a -> a
applyN n f = (!! n) . iterate f
@simonmichael
simonmichael / gist:4354506
Last active December 10, 2015 00:58 — forked from anonymous/gist:4354489
hledger --width design notes

The --width/-w options adjusts the width of the output. By default, register's output is 80 characters wide. To allow more space for long descriptions and account names, use -w to increase the width to 120 characters, or -wN to set any desired width (at least 45 recommended). The date and amount fields have fixed width, and the remainder is split between description and account.

With multiple comma-separated values, -w sets the respective field widths:

-w 10,20,30,10,10

A total width or field width of auto means be as wide as necessary to avoid clipping data. If a current terminal width can be detected, the total width will be limited to this. Eg:

@simonmichael
simonmichael / gist:5005481
Last active December 14, 2015 01:19 — forked from anonymous/gist:5005479
http-conduit issues
-- | Fetch the contents of a uri, which must be an ascii string.
-- Redirects, authentication, https: and file: uris are supported.
readUri :: Manager -> String -> Opts -> IO String
readUri manager s opts =
case parseURI' s of
Just URI{uriScheme="file:",uriPath=f} -> readFeedFile f
Just _ -> do
r <- parseUrl s
let cachecontrol = cache_control opts
r' | null cachecontrol = r
YEAR:=$(shell date +%Y)
MONTH:=$(shell date +%m)
MONTHS:=$(shell ghc -e "(putStr . unwords . map show) [1..$(MONTH)]")
# quick income statement for specified (single-word) period
INCOMESTATEMENTACCTS=^income ^expenses ^draw
INCOMESTATEMENTOPTS=--cost --effective --depth 1 #--flat --drop 1
income-statement-%:
@printf "\nincome statement for $*:\n"
$(HLEDGER) balance $(INCOMESTATEMENTACCTS) --period '$*' $(INCOMESTATEMENTOPTS)
@simonmichael
simonmichael / gist:6525372
Last active December 22, 2015 20:19 — forked from anonymous/gist:6525360
darcs diff shows correct change, darcs whatsnew does not
$ darcs diff lib/smarty.inc
diff -rN -u lib/smarty.inc lib/smarty.inc
--- lib/smarty.inc 2013-09-11 08:36:05.000000000 -0700
+++ lib/smarty.inc 2013-09-11 08:36:05.000000000 -0700
@@ -26,6 +27,7 @@
}
}
+global $__template_register_outputfilter;
$__template_register_outputfilter = array();
@simonmichael
simonmichael / iXpenseIt.csv.rules
Last active December 24, 2015 20:39 — forked from anonymous/gist:6859060
hledger CSV conversion rules for iXpenseIt phone app
skip 1
fields Date,Type,Category,Subcategory,Vendor,Payment,Currency,Amount,Note
description %vendor
account1 assets:%payment
account2 expenses:%type:%category:%subcategory
comment %note
~/src/hledger$ git l -1000 hledger-0.23.3..master
2014-09-07 2227997 revert an unnecessary "fix" in efe7c7a that broke tests (HEAD, origin/master, origin/HEAD, master)
2014-09-07 a65116a fix func. test numbering
2014-09-12 42a22be tools: fix tagrelease
2014-09-12 5d403c2 doc: changelogs (resolve conflicts)
2014-09-12 53aee0e resolve conflict
2014-09-12 d7f1733 remove text upper bound, allowing 1.2+ (fixes #207)
2014-09-06 efe7c7a journal: dates should be followed by whitespace or newline
2014-08-14 2992ce0 web: add form ignores trailing blank fields
2014-08-14 8d1ceb0 web: increase initial add form postings to four