Skip to content

Instantly share code, notes, and snippets.

@deckool
deckool / hosts.hs
Last active December 14, 2015 02:09
top server side routing using Snap
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Snap.Core
import Snap.Util.FileServe
import Snap.Http.Server
main :: IO ()
@deckool
deckool / http.hs
Created October 27, 2013 11:01 — forked from owainlewis/Example.hs
-- The lack of documentation for these things is crazy
module HTTPExamples
where
import Network.HTTP
import Control.Applicative
url = "http://www.owainlewis.com"
#Quick cp from http://sekati.com/etc/install-nodejs-on-debian-squeeze
#
#Needed to install TileMill from MapBox
#
#Installs node.js which has npm bundled
#
#Build Dependencies
sudo apt-get update && apt-get install git-core curl build-essential openssl libssl-dev
#!/bin/sh
echo "deb http://ftp.debian.org/debian sid main" >> /etc/apt/sources.list
apt-get update
apt-get -t sid install libc6 libc6-dev libc6-dbg
echo "Please remember to hash out sid main from your sources list. /etc/apt/sources.list"
@deckool
deckool / streams.hs
Last active August 29, 2015 14:03
http-streams
{-# LANGUAGE OverloadedStrings #-}
import System.IO.Streams (InputStream, OutputStream, stdout)
import qualified System.IO.Streams as Streams
import Network.Http.Client
import qualified Blaze.ByteString.Builder.Char8 as Builder
import Control.Applicative
import Control.Monad
import Data.Aeson (FromJSON, parseJSON, (.:))
@deckool
deckool / dsj.hs
Created August 14, 2014 08:45
explore dead-simple-json with multiple json formats
import qualified Text.DeadSimpleJSON as JSON
import Text.DeadSimpleJSON (JSON)
main = do
let jsonData1 = read "[1,2,4,8,16]" :: JSON
print $ show jsonData1
plane = do
let jsonData = read "{\"seven\": 7, \"nine\": [1,2,4,8,16]}"
div.post::before {
content: attr(data-yearday);
color:rgba(255,255,255,0.5);
font-size:350%;
font-weight:bold;
}
h1 a {
color:white;
/* First we need to help some browsers along for this to work.
@deckool
deckool / post-receive
Created February 14, 2015 10:42
My hook
#!/bin/bash
while read oldrev newrev ref
do
echo "new: $newrev"
git show --pretty=format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"
if [[ $ref =~ .*/master$ ]];
then
echo "Master $ref received. Deploying master branch to production..."
GIT_WORK_TREE=~/tap git checkout -f
echo "$?"
@deckool
deckool / Main.hs
Last active August 29, 2015 14:15 — forked from jbpotonnier/Main.hs
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Snap.Core
import Snap.Util.FileServe
import Snap.Http.Server
import Data.Monoid (mconcat)
import Blaze.ByteString.Builder.Char8
import Blaze.ByteString.Builder
@deckool
deckool / Fork.hs
Last active August 29, 2015 14:25 — forked from AlexanderAA/Fork.hs
module Fork (
main
) where
import Control.Concurrent (forkIO, ThreadId, threadDelay)
import Control.Concurrent.STM
import Control.Monad
import Control.Monad.IO.Class (liftIO)
import System.Random