Awk example

Oct. 12, 2014, 3:09 p.m.

#!/usr/bin/awk -f
BEGIN {sum=0} 
{sum=sum+$5} 
END {print sum}

Convert dd/mm/yyyy to yyyy-mm-dd in Vim

Sept. 28, 2014, 11:20 p.m.

:%s/\(\d\{2}\)\/\(\d\{2}\)\/\(\d\{4}\)/\3-\2-\1/g
vim

New post

July 6, 2014, 5:58 p.m.

This is a new post

Java example

May 27, 2014, 8:53 p.m.

import java.util.Map;
import java.util.TreeSet;

public class GetEnv {
  /**
   * let's test generics
   * @param args the command line arguments
   */
  public static void main(String[] args) {
    // get a map of environment variables
    Map<String, String> env = System.getenv();
    // build a sorted set out of the keys and iterate
    for(String k: new TreeSet<String>(env.keySet())) {
      System.out.printf("%s = %s\n", k, env.get(k));
    }
  }    }

Haskell example

May 27, 2014, 8:51 p.m.

{-# LANGUAGE OverloadedStrings #-}
module Main where

--import Prelude hiding (id)
--import Control.Category (id)
import Control.Arrow ((>>>), (***), arr)
import Control.Monad (forM_)
-- import Data.Monoid (mempty, mconcat)

-- import System.FilePath

import Hakyll


main :: IO ()
main = hakyll $ do

    route   "css/*" $ setExtension "css"
    compile "css/*" $ byExtension (error "Not a (S)CSS file")
        [ (".css",  compressCssCompiler)
        , (".scss", sass)
        ]

    route   "js/**" idRoute
    compile "js/**" copyFileCompiler

    route   "img/*" idRoute
    compile "img/*" copyFileCompiler

    compile "templates/*" templateCompiler

    forM_ ["test.md", "index.md"] $ \page -> do
        route   page $ setExtension "html"
        compile page $ pageCompiler
            >>> applyTemplateCompiler "templates/default.html"
            >>> relativizeUrlsCompiler

sass :: Compiler Resource String
sass = getResourceString >>> unixFilter "sass" ["-s", "--scss"]
                         >>> arr compressCss