Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Control.Applicative
import Data.Binary
import qualified Data.Map as M
import Network.Socket hiding (recv)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
import Network.Socket.ByteString (recv, sendAll)
{-# LANGUAGE DeriveGeneric, TypeSynonymInstances, FlexibleInstances, DeriveDataTypeable #-}
module TimeTracker where
import Control.Monad
import qualified Control.Exception as E
import Control.Concurrent
import Control.Concurrent.STM
import qualified Data.ByteString.Lazy as BL
import qualified Data.Map as M
import scala.collection.mutable.ListBuffer
import scala.io.Source
/**
* Created by portnov on 01.08.15.
*/
object HelloWorld {
case class Word(wordIdx : Int, wordInt : List[Int])
@portnov
portnov / Entities.hs
Created January 31, 2012 11:47
Persistent issue #48
{-# LANGUAGE TemplateHaskell, QuasiQuotes, EmptyDataDecls, TypeFamilies, FlexibleContexts, GADTs, OverloadedStrings #-}
module Entities where
import Database.Persist
import Database.Persist.TH
import Data.Text
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persist|
Group
title Text
@portnov
portnov / aggregates.R
Last active December 15, 2015 11:49
yaledger-charts script
aggregates <- function(formula, data=NULL, FUNS){
if(class(FUNS)=="list"){
f <- function(x) sapply(FUNS, function(fun) fun(x))
}else{f <- FUNS}
temp <- aggregate(formula, data, f)
out <- data.frame(temp[,-ncol(temp)], temp[,ncol(temp)])
colnames(out)[1] <- colnames(temp)[1]
return(out)
}
@portnov
portnov / Chan2.hs
Created February 19, 2016 16:31
Two-way Chan
module Chan2 where
import Control.Concurrent
type Chan2 rq rs = Chan (rq, MVar rs)
call :: Chan2 rq rs -> rq -> IO rs
call chan rq = do
mvar <- newEmptyMVar
writeChan chan (rq, mvar)
@portnov
portnov / Dockerfile
Created June 17, 2016 16:19
Sbcl 1.3.6 && Fricas svn
FROM ubuntu:16.04
MAINTAINER Ilya Portnov <portnov@iportnov.ru>
RUN apt-get update && \
apt-get install -y sbcl build-essential \
wget subversion autoconf libgmp-dev
RUN cd /usr/src/ && \
wget http://prdownloads.sourceforge.net/sbcl/sbcl-1.3.6-source.tar.bz2?download && \
tar xf sbcl-1.3.6-source.tar.bz2\?download && \
@portnov
portnov / Dockerfile
Created June 17, 2016 18:46
sbcl+fricas+jupyter
FROM ubuntu:16.04
MAINTAINER Ilya Portnov <portnov@iportnov.ru>
#RUN DEBIAN_FRONTEND=noninteractive locale-gen en_US.UTF-8 && \
# DEBIAN_FRONTEND=noninteractive dpkg-reconfigure locales
# Not essential, but wise to set the lang # Note: Users with other languages should set this in their derivative image
#ENV LANGUAGE en_US.UTF-8
#ENV LANG en_US.UTF-8
#ENV LC_ALL en_US.UTF-8
@portnov
portnov / Build instructions
Last active June 21, 2016 18:40
Jupyter with FriCAS, Maxima, R, Octave, Haskell, Python
$ sudo apt-get install -y docker.io
$ docker build -t jupyter .
# drink a cup of tea, then eat lunch, then walk your dog, then...
$ docker run --name jupyter -d -p 8888:8888 -v ~/notebooks:/notebooks jupyter
$ x-www-browser http://localhost:8888
import Control.Monad
import Data.Tree
import Data.List
import Data.Function (on)
type Path = [String]
splitPath :: String -> Path
splitPath s = unfoldr go s