Skip to content

Instantly share code, notes, and snippets.

View steinwaywhw's full-sized avatar

Steinway Wu steinwaywhw

View GitHub Profile
@steinwaywhw
steinwaywhw / matrix.dats
Created March 5, 2014 15:07
Matrix in ATS
#include "share/atspre_staload.hats"
typedef matrix (a:t@ype) = mtrxszref (a)
extern fun {a:t@ype} matrix_transpose (matrix (a)): matrix (a)
extern fun {a:t@ype} foreach (matrix (a), (a, size_t, size_t) -<cloref1> void): matrix (a)
extern fun matrix_print (matrix (int)): void
implement {a} foreach (m, f) = let
val nrow = mtrxszref_get_nrow (m)
@steinwaywhw
steinwaywhw / README.md
Last active August 29, 2015 13:57
A quick script for installing ATS2. Just make sure you have libgmp installed already.

Installing ATS on Linux

Just copy and execute the code, and you get the latest ATS. Just make sure you already have libgmp3-dev installed. Also make sure to setup PATSHOME environment variable.

@steinwaywhw
steinwaywhw / lazy.dats
Last active August 29, 2015 13:58
An exercise for lazy evaluation in ATS
#include "share/atspre_staload.hats"
staload UN = "prelude/SATS/unsafe.sats"
//make patscc -o lazy lazy.dats -DATS_MEMALLOC_LIBC
datatype list (a:t@ype) =
| list_cons of (a, lazy (list (a)))
| list_nil of ()
#define nil list_nil
@steinwaywhw
steinwaywhw / Dockerfile
Created April 3, 2014 16:30
A docker image for ATS development.
FROM stackbrew/ubuntu:13.10
RUN apt-get update
RUN apt-get install -y libgmp3-dev
RUN apt-get install -y make
RUN apt-get install -y gcc
RUN apt-get install -y build-essential
RUN apt-get install -y wget
RUN apt-get install -y bash
@steinwaywhw
steinwaywhw / install.sh
Created April 3, 2014 18:19
Install Java on Ubuntu Server
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu saucy main" >> /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu saucy main" >> /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install -y oracle-java8-installer
@steinwaywhw
steinwaywhw / README.md
Last active August 29, 2015 14:01
Enigma Machine in ATS

Enigma Machine in ATS

This is an Enigma Machine implementation in ATS programming language. Please visit this blog for more information.

License: GPL v3

@steinwaywhw
steinwaywhw / update.sh
Created May 11, 2014 21:36
Upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
@steinwaywhw
steinwaywhw / log_files.yml
Last active August 29, 2015 14:01
Gist for ats-pad deployment provisioning.
files:
- /var/log/tomcat7/*
- /home/vagrant/server/*log*
destination:
host: logs.papertrailapp.com
port: 20895

#Installing Node.js and NPM in 30s

@steinwaywhw
steinwaywhw / Util.groovy
Last active August 29, 2015 14:03
Get server IP address at runtime in Grails/Groovy
def getIPAddress() {
return "ip route show dev eth0".execute().getText().tokenize()[9]
}