Skip to content

Instantly share code, notes, and snippets.

@psibi
psibi / records.sml
Created January 31, 2013 11:10
Pattern Matching Records in SML
(* Pattern Matching in Records
Let us pattern match {first:string,second:string,third:string}
*)
(*You should not code like this.
This code will produce a type of val test = fn : {a:'a, b:'b, c:'c} -> {first:'a, second:'b, third:'c}
So, it creates actually records with fields of a, b and c. This is not what you want.
*)
fun test e =
@psibi
psibi / index.html
Created April 2, 2014 19:52
Working jqplot with legends
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
<link href="./jquery.jqplot.min.css" rel="stylesheet"
type="text/css" />
@psibi
psibi / tree.hs
Created June 17, 2014 02:05
Binary tree
import Control.Applicative
data Tree a = Leaf a
| Node (Tree a) (Tree a)
deriving Show
instance Functor Tree where
fmap f (Leaf a) = Leaf (f a)
fmap f (Node x y) = Node (fmap f x) (fmap f y)
@psibi
psibi / output
Created July 9, 2014 07:44
Cabal sandbox issue
$ cabal install -v3 --only-dependencies
Searching for ghc in path.
Found ghc at /usr/bin/ghc
("/usr/bin/ghc",["--numeric-version"])
/usr/bin/ghc is version 7.6.2
looking for tool ghc-pkg near compiler in /usr/bin
found ghc-pkg in /usr/bin/ghc-pkg
("/usr/bin/ghc-pkg",["--version"])
/usr/bin/ghc-pkg is version 7.6.2
("/usr/bin/ghc",["--supported-languages"])
@psibi
psibi / ipython_config.py
Created December 15, 2014 12:18
Ipython configuration
# Configuration file for ipython.
c = get_config()
#------------------------------------------------------------------------------
# InteractiveShellApp configuration
#------------------------------------------------------------------------------
# A Mixin for applications that start InteractiveShell instances.
#
@psibi
psibi / auctex
Created July 14, 2015 07:56
Aucex Error Message
Install package `auctex-11.88.6'? (y or n) y
Contacting host: elpa.gnu.org:80 [2 times]
Parsing tar file...done
Extracting auctex-11.88.6/
Extracting auctex-11.88.6/tex-site.el
Wrote /home/sibi/.emacs.d/elpa/auctex-11.88.6/tex-site.el
Extracting auctex-11.88.6/tests/
Extracting auctex-11.88.6/tests/latex/
Extracting auctex-11.88.6/tests/latex/latex-test.el
Wrote /home/sibi/.emacs.d/elpa/auctex-11.88.6/tests/latex/latex-test.el
@psibi
psibi / mockMigrationTest.hs
Created July 27, 2015 22:05
Mock Migration
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Monad.IO.Class (liftIO)
these derivations will be built:
/nix/store/hjl2pj0l8hp4q8qjdz25ysa3zpgdn6f8-ghc-7.10.2.drv
building path(s) ‘/nix/store/xcskd8vlbfalyj45az1c3x44wv0fgzby-ghc-7.10.2’
collision between `/nix/store/9ch1py7iv3id2fyn0rz0sd28sdhhgnlq-persistent-2.2/lib/ghc-7.10.2/persistent-2.2.2/libHSpersistent-2.2.2-JLgfajdmTC3AD8guoyGkEF-ghc7.10.2.so' and `/nix/store/dzlk7m2gs0jd89f69vbyfph2v7daxslv-persistent-2.2.2/lib/ghc-7.10.2/persistent-2.2.2/libHSpersistent-2.2.2-JLgfajdmTC3AD8guoyGkEF-ghc7.10.2.so'
builder for ‘/nix/store/hjl2pj0l8hp4q8qjdz25ysa3zpgdn6f8-ghc-7.10.2.drv’ failed with exit code 2
error: build of ‘/nix/store/hjl2pj0l8hp4q8qjdz25ysa3zpgdn6f8-ghc-7.10.2.drv’ failed
/home/sibi/.nix-profile/bin/nix-shell: failed to build all dependencies
@psibi
psibi / YesodServantExample.hs
Created September 14, 2016 02:47
Code showing Subsite doesn't handle authentication
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@psibi
psibi / Utils.java
Created October 22, 2016 06:29
Utils
package ghcvm.oldtime;
import java.util.Date;
import java.util.Calendar;
import java.util.TimeZone;
import java.text.SimpleDateFormat;
public class Utils {
public static long getClockTimePrim() {