Skip to content

Instantly share code, notes, and snippets.

Henri Tuhola cheery

Block or report user

Report or block cheery

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cheery
cheery / interaction_combinators.py
Created Mar 28, 2019
Interaction combinators
View interaction_combinators.py
# -*- encoding: utf-8 -*-
# Implements symmetric interaction combinators
# I took some ideas from Victor Maia's projects.
# Bunch of cells form an interaction net.
# It's a half-edge graph.
class Cell:
def __init__(self, kind):
self.ports = (Port(self), Port(self), Port(self))
self.kind = kind # 'era', 'con', 'fan'
@cheery
cheery / Makefile
Created Feb 11, 2019
Easy method for drawing pixel graphics on rv8 rv-jit.
View Makefile
SDL2_CFLAGS = $(shell pkg-config sdl2 --cflags)
SDL2_LIBS = $(shell pkg-config sdl2 --libs)
CFLAGS = $(SDL2_CFLAGS)
LIBS = $(SDL2_LIBS) -lm
.PHONY: all
all: main maze
run: all
View Makefile
# There was a bug in the riscv toolchain preventing use of --oformat binary.
# Use of objcopy is a workaround for it.
noise: noise.elf
riscv64-unknown-elf-objcopy -O binary $^ $@
chmod +x $@
noise.elf: listing.s
riscv64-unknown-elf-gcc -nostartfiles $^ -o $@
@cheery
cheery / Makefile
Created Feb 6, 2019
Tiny executables in RISC-V.
View Makefile
tiny: listing.elf
riscv64-unknown-elf-objcopy -O binary $^ $@
chmod +x $@
listing.elf: listing.s
riscv64-unknown-elf-gcc -nostartfiles $^ -o $@
@cheery
cheery / silly-slide
Created Feb 5, 2019
C128 assembly program
View silly-slide
. 1800 LDX #$00 # This clears the SID memory
LDA #$00
STA $D400,X
INX
CPX #$29
BNE $1804
. 180C LDX #$0F # Set master volume
STX $D418
LDX #$4F # Set attack/decay
@cheery
cheery / markup.wp
Created Dec 9, 2018
a minimal 'binary' markup language
View markup.wp
 + title  Markup-file under vim editing 
Text can still remain mostly plain text
with suitable adjustments,
even if the some of the characters
between pre]0x00 - 0x20[ range was
re-purposed for different use.
The pathwp.vim -script is a demonstration piece
and not intended for practical use.
@cheery
cheery / chess.pl
Created Nov 23, 2018
TAU prolog chess model (23.11.2018)
View chess.pl
% Written for TAU prolog.
:- use_module(library(lists)).
chess(doh, End) :-
initial_board(InitialBoard),
move(InitialBoard, black, XX),
move(XX, white, YY),
move(YY, black, End).
% Pawn movements.
@cheery
cheery / APL.py
Created Jul 18, 2018
Multidimensional matrices, Iverson notation inspired.
View APL.py
# -*- coding: utf-8 -*-
import operator
import itertools
def main():
shape = [3, 3, 2]
values = [1, 3, 3, 3, 1, 3, 3, 3, 1, 2, 2, 2, 4, 2, 2, 4, 4, 2]
a = numeric([1,2,3,4,5])
print a
@cheery
cheery / maildir.coffee
Last active Apr 13, 2018
I wonder what's wrong with this.
View maildir.coffee
fs = require 'fs'
os = require 'os'
exports.hook_rcpt = (next, connection, params) ->
rcpt = params[0]
rcpt_to = rcpt.address().toLowerCase()
mail = this.config.get('mail.ini')
connection.loginfo("hook_rcpt running through")
if mail.accounts and mail.accounts[rcpt_to]?
@cheery
cheery / result.c
Created Apr 12, 2018
A small demo on using C macros
View result.c
# 1 "symtab_demo.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "symtab_demo.c"
You can’t perform that action at this time.