Skip to content

Instantly share code, notes, and snippets.

Most remember Pieter Hintjens for his messaging protocols. I don't know anything about that,
but I credit him with rekindling my love of programming in general, Lisp and functional programming
in one fell swoop about 17 years ago.
He did this by writing 'Libero', a mid-90's C program that took an ASCII diagram of a state machine
and produced code that ran that machine in a remarkable number of languages including 'sh', 'python',
'C' and many more. Some of them are listed on the original page (https://imatix-legacy.github.io/libero/).
I discovered in the early 00's and it fascinated me because was a unique combination of code generation
and what is now called purely functional programming.
@deech
deech / recordupdate.hs
Last active January 30, 2021 00:35
Record Update with RecordWildCards
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns#-}
data C = C { c::[Int] } deriving Show
data B = B { b::Bool, c::C } deriving Show
data A = A { a::String, b::B } deriving Show
mkA = A "hello world" (B True (C [1,2,3]))
(datatype is-prime
if (is-prime? N)
N : number;
==============
N : prime;)
(define is-prime?
X -> (prime* X (/ X 2) 2) where (number? X)
_ -> false)
@deech
deech / compiletimefizzbuzz.nim
Created June 7, 2019 23:10
Compile Time FizzBuzz In Nim
import math
proc fizzbuzz(n: int) {.compileTime.} =
for i in 1 .. n:
let
by3 = (i mod 3) == 0
by5 = (i mod 5) == 0
if (by3 and by5): echo "FizzBuzz"
elif by3: echo "Fizz"
elif by5: echo "Buzz"
else: echo $i
@deech
deech / binarytrees.nim
Created March 13, 2019 20:58
Binary tree benchmark [Nim]
import threadpool, strformat, os, strutils, math
type
Tree = ref object
left: Tree
right: Tree
proc deepCopy[T](x: var T, y: T) =
x = y
proc check(t: Tree): int32 =
pthread_setschedparam failed: Operation not permitted
This VM uses a separate heartbeat thread to update its internal clock
and handle events. For best operation, this thread should run at a
higher priority, however the VM was unable to change the priority. The
effect is that heavily loaded systems may experience some latency
issues. If this occurs, please create the appropriate configuration
file in /etc/security/limits.d/ as shown below:
cat <<END | sudo tee /etc/security/limits.d/pharo.conf
* hard rtprio 2
3/home/deech/Pharo/vms/70-x64/lib/pharo/5.0-201806281256/pharo
Pharo VM version: 5.0-201806281256 Thu Jun 28 13:04:44 UTC 2018 gcc 4.8 [Production Spur 64-bit VM]
Built from: CoInterpreter VMMaker.oscog-eem.2401 uuid: 29232e0e-c9e3-41d8-ae75-519db862e02c Jun 28 2018
With: StackToRegisterMappingCogit VMMaker.oscog-eem.2401 uuid: 29232e0e-c9e3-41d8-ae75-519db862e02c Jun 28 2018
Revision: VM: 201806281256 https://github.com/OpenSmalltalk/opensmalltalk-vm.git Date: Thu Jun 28 14:56:30 2018 CommitHash: a8a1dc1 Plugins: 201806281256 https://github.com/OpenSmalltalk/opensmalltalk-vm.git
Build host: Linux travis-job-46342785-b1c1-4811-8c3c-9b2a88ae7ecc 4.4.0-101-generic #124~14.04.1-Ubuntu SMP Fri Nov 10 19:05:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
plugin path: [default: /home/deech/Pharo/vms/70-x64/lib/pharo/5.0-201806281256/]
C stack backtrace & registers:
@deech
deech / D Compile time TCO
Created July 7, 2017 20:53
D Compile Time TCO
import std.stdio;
double factorial (double i)
{
if (i == 1) {
return 1;
}
else {
return (i * factorial(i - 1));
}
curl -X PUT -H "Content-Type: application/x-tar" -H "Content-Encoding: gzip" --data-binary @"packagename-packageversion-docs.tar.gz" "https://usernae:password@hackage.haskell.org/package/packagename-packageversion/docs"
diff --git a/c-src/Fl_C.h b/c-src/Fl_C.h
index 963bc04..9485c6c 100644
--- a/c-src/Fl_C.h
+++ b/c-src/Fl_C.h
@@ -257,6 +257,7 @@ EXPORT {
FL_EXPORT_C(void ,Fl_release_widget_pointer)(fl_Widget w);
FL_EXPORT_C(void ,Fl_clear_widget_pointer)(fl_Widget w);
FL_EXPORT_C(void ,Fl_clear_widget_pointer)(fl_Widget w);
+#if FL_API_VERSION == 10304
FL_EXPORT_C(void ,Fl_set_box_color)(Fl_Color c);