Skip to content

Instantly share code, notes, and snippets.

View darach's full-sized avatar

Darach Ennis darach

  • Squircle Systems Ltd
  • London, UK
View GitHub Profile
use "collections"
use "time"
primitive Factorial
""" Factorial
"""
fun fac(n:U64): U64 =>
var f : U64 = 1
var i : U64 = 1
if n == 0 then
@darach
darach / Pony on MIPS [ Work in Progress ]
Last active May 17, 2016 19:21
Pony on MIPS - C and RT test results
root@mylinkit:/tmp/run/mountd/sda2/current/bin# ./ponyc --pic --debug -V=4 foo
Building builtin -> /tmp/run/mountd/sda2/current/packages/builtin
Building foo -> /tmp/run/mountd/sda2/current/bin/foo
Generating
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
'generic' is not a recognized processor for this target (ignoring processor)
@darach
darach / getifaddr.pony
Created February 23, 2016 23:25
A minimal example of mapping a native C structure to pony struct using FFI - Shows usage of Maybe, FFI and structs working together
// Use Pony struct's, FFI, and Maybe to map native structures to C
// Thanks to sclebsch for a little help with the embedded sa_data
// structure for which details are well hidden in sockaddr_in and sockaddr_in6
//
struct SockAddr
var sa_len: U8 = 0
var sa_family: U8 = 0
var sa_port: U16 = 0
var sa_data_1: U32 = 0
#--------
# Dockerfile to configure salt minion
FROM debian:jessie
MAINTAINER foo@example.com
RUN apt-get update
RUN apt-get install -y curl
RUN curl -o - https://repo.saltstack.com/apt/debian/8/amd64/latest/SALTSTACK-GPG-KEY.pub |
apt-key add -
@darach
darach / instructions.md
Last active February 13, 2016 22:37
Pony on the Raspberry Pi v2

Instructions

The following instructions assume a debian jessie based distribution

0. Prerequisites

Install dependent tools and libraries

$ sudo apt-get update
@darach
darach / f.pony
Created November 14, 2015 20:30
ref -> val
actor Main
new create(env : Env) =>
var a : Array[String] ref = [ "a", "b", "c" ]
var b : Array[String] trn = recover Array[String] end
b.push("foo") ; b.push("bar") ; b.push("baz")
for i in a.values() do
b.push(i)
end
let c : Array[String] val = consume b
for i in c.values() do
@darach
darach / ex1.pony
Created November 11, 2015 00:30
Random pony examples
use "collections"
actor Main
fun pass[A : Any #read](ln: A): List[A] =>
List[A].push(consume ln)
new create(env : Env) =>
try
env.out.print("Got: " + pass[String]("hello")(0) as String)
end
@darach
darach / fony.sh
Last active February 15, 2021 20:36
Example showing how to compile pony executables via LLVM and clang from LLVM IR produced by 'ponyc -rir ...'
#!/bin/sh
LLVM_HOME=/usr/local/Cellar/llvm/3.6.2/bin
PONY_HOME=/path/to/pony/repo
PONY_LIBS=${PONY_HOME}/build/debug
TARGET_ARCH=x86-64
OUT_LL="$1.ll"
OUT_BC="$1.bc"
OUT_S="$1.s"
@darach
darach / keybase.md
Last active September 22, 2015 15:32
keybase.md

Keybase proof

I hereby claim:

  • I am darach on github.
  • I am darach (https://keybase.io/darach) on keybase.
  • I have a public key whose fingerprint is 164C B8BB DD67 02B3 394D 2F22 340E 536C BA3A D0C5

To claim this, I am signing this object:

@darach
darach / simple2.erl
Created March 24, 2015 12:21
Escript to show that how to have more than one histogram active at one time
#!/usr/bin/env escript
%%! -sname hdr_histogram_simple -pa ebin
%% H1
%% Memory Size 90184
%% Total Count 100
%% H2
%% Memory Size 90184
%% Total Count 1000
%% Done!