Skip to content

Instantly share code, notes, and snippets.

View roman's full-sized avatar

Roman Gonzalez roman

View GitHub Profile
@roman
roman / ArbitraryInstances.hs
Created September 29, 2011 22:12
QuickCheck generator for Canonicalized and Normal URI generation
module Test.Util.ArbitraryInstances where
import Data.List (intercalate)
import Control.Applicative ((<$>), (<*>), pure)
import Network.URI (URI(..), URIAuth(..), uriToString)
import Test.QuickCheck
newtype URIPair
= URIPair { fromPair :: (String, String) }
deriving (Show)
@roman
roman / git1.pp
Created September 23, 2011 21:13
Code for a puppet post on romanandreg.com
class git {
include git::install
...
}
@roman
roman / GithubDate.hs
Created September 17, 2011 01:55
Code to parse Github dates out of it's API using Aeson
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Aeson (FromJSON(..), Value(..), Result(..))
import Data.Aeson.Types (parse)
import Data.Time.Clock (UTCTime)
import Data.Time.Format (FormatTime, parseTime)
import Data.Typeable (Typeable)
@roman
roman / Github.hs
Created September 16, 2011 18:11
Experiments with Github + Redis + Haskell
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Failure (Failure(..))
import Control.Monad.Trans (MonadIO, liftIO, lift)
import Control.Monad.IO.Control (MonadControlIO)
@roman
roman / Git.hs
Created September 15, 2011 22:05
Experiments with Git + Haskell
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import HSH ((-|-))
import qualified HSH as Shell
import qualified Data.Attoparsec.Char8 as Parser
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BS
@roman
roman / Zip.hs
Created August 23, 2011 17:13
Haskell's zip and zipWith functionality in Clojure
numbers :: [Int]
numbers = zip [1, 2, 3] [4, 5, 6]
main :: IO ()
main = print numbers
-- Output: [(1,4), (2,5), (3,6)]
@roman
roman / plug.vim
Created August 11, 2011 19:17
Plugs not working
if !hasmapto('<Plug>GoldenRatioResize') &&
\ !hasmapto('<LEADER>g', 'n')
echom "Doing mapping to <LEADER>g"
nnoremap <LEADER>g <Plug>GoldenRatioResize
endif
nnoremap <unique> <Plug>GoldenRatioResize :call <SID>ResizeToGoldenRatio()<CR>
@roman
roman / JQuery.hs
Created July 28, 2011 21:34
jQuery on Haskell
j <- select "p" $ do
addHTMLClass "ohmy" -- internally using s2js
show $ do -- internal monad (different one)
speed Slow
easing 1024
appendCallback $ do
-- some callback
appendCallback otherIOAction
-- other attributes are Nothing by default
@roman
roman / AllBase.hs
Created July 13, 2011 18:08
All Base exercise from Google Code Jam 2009
module Main where
import Data.Map (Map)
import qualified Data.Map as Map
import Data.List (foldl')
import Data.Maybe (fromMaybe, fromJust)
import Control.Monad (liftM, forM_)
allBase :: String -> Int
allBase xs = foldr fn 0 $ zip [0..] (xs' ++ [1])
@roman
roman / tmux.conf
Created July 4, 2011 16:42
My tmux conf
# Set prefix to C-a to keeps things simpler
unbind C-b
unbind l
set -g prefix C-a
bind C-a send-prefix
set -g default-terminal "screen-256color"
# Use vi keybindings in the copy and scroll mode
set-window-option -g mode-keys vi
# Use vi keybindings on the prompt