Skip to content

Instantly share code, notes, and snippets.

View mbixby's full-sized avatar

Michal Obrocnik mbixby

View GitHub Profile
@mbixby
mbixby / Markdown.tmlanguage
Last active December 15, 2015 15:19
Quick fix for bullet coloring in Markdown.tmlanguage
<dict>
<key>begin</key>
<!-- By default, maximum number of spaces before the bullet
character is 3. To support multiple nested lists, I changed
it to infinite. -->
<string>^[ ]*([*+-])(?=\s)</string>
<key>captures</key>
<dict>
<key>1</key>
@mbixby
mbixby / EXTNull.h
Last active December 14, 2015 17:59
EXTNull
/**
EXTNull
Experimental
EXTNull is a subclass of NSNull that acts more like nil.
Calling unrecognized methods on EXTNull *will not* throw
a NSInvalidArgumentException but again return EXTNull.
-- parseExpr :: something -> Either ParseError Expression
convert :: String -> Either String String
convert input = case parseExpr input of
Left err -> Left $ show err
Right x -> Right $ show x
-- Want:
convert = magicfunction show $ parseExpr
@mbixby
mbixby / gist:2359042
Created April 11, 2012 12:29
Translate directory tree to a tree
data Tree a = Leaf a | Node a [Tree a]
scanDir :: String -> IO (Tree String)
scanDir path = do
contents <- getDirectoryContents path `catch` const (return [])
let files = sort . filter (`notElem` [".", ".."]) $ contents
let pathsAndFiles = zip (repeat path) files
tree <- forM pathsAndFiles $ \(path, file) -> do
isDirectory <- doesDirectoryExist path
if isDirectory