Skip to content

Instantly share code, notes, and snippets.

@gbluma
gbluma / Makefile
Created December 25, 2015 05:04
Felix integrates with MPI C++ so easy
.PHONY: test
test:
flx --pkgconfig-path+=. -c --static -o mpi mpi.flx
mpirun -np 5 mpi
@gbluma
gbluma / x11.fpc
Created December 25, 2015 03:35
X11 demo in Felix
Description: Linux X11 support
requires_dlibs: -lX11
requires_slibs: -lX11
class CT
{
class Semigroup[T,U] {
virtual fun \circ : T * T -> T;
}
class Monoid[T,U] {
inherit Semigroup[T,U];
virtual fun id : () -> T;
@gbluma
gbluma / object-algebra.flx
Last active August 29, 2015 14:23 — forked from anonymous/gist:65c37929d31fa0fceb21
An example of Object Algebras in Felix
// Title: An example of Object Algebras in Felix
// Author: Garrett Bluma
// Date: June 29, 2015
// Special thanks to Bruno Oliveira and William Cook for explaining object
// algebras, and for providing examples.
// <http://i.cs.hku.hk/~bruno/oa/>
// -----------------------------------------
// Object algebras use extension via type parameters and inheritance. Given a
# Use something easier to type as the prefix.
set -g prefix C-f
unbind C-b
bind C-f send-prefix
# Relax!
set -sg escape-time 0
set -sg repeat-time 600
# This is hilariously absurd. How many nerds use tmux on OS X every day and
// TODO: support more than just linux/osx
include "std/posix/filesystem";
// TODO: add this to std/io/textio.flx, it's missing
gen fopen_append : string -> ofile = '::std::fopen($1.c_str(), "a")';
object Repl () = {
#lang racket
(require 2htdp/batch-io) ; provides read-csv-file
(require srfi/1) ; provides reduce function
(require plot) ; provides plot function
;; helper functions
(define (sum xs) (reduce + 0 xs))
(define (square x) (* x x))
float n() {
return random(50);
}
float[] soften(float[] curve) {
for (int i=0; i<19;i++){
curve[i] = curve[i] + (curve[i]-curve[i+1])/5;
}
for (int i=19; i>0; i--){
curve[i] = curve[i] + (curve[i-1]-curve[i])/5;
@gbluma
gbluma / gist:fa6ccb968681a4f5a024
Created December 27, 2014 22:41
c code security check
egrep '[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)'
@gbluma
gbluma / DictionaryParser.flx
Created November 28, 2014 20:00
Felix Dictionary parser
class DictionaryParser {
requires package "re2";
open Regdef;
struct KeyValue {
key : string;
value : string;
}