Skip to content

Instantly share code, notes, and snippets.

View tormaroe's full-sized avatar
💭
Doing some Go and then som JavaScript at the moment

Torbjørn Marø tormaroe

💭
Doing some Go and then som JavaScript at the moment
View GitHub Profile
@tormaroe
tormaroe / maze1.lisp
Last active March 12, 2017 09:39
Maze experiments with common lisp and processing.js, part I (garbled)
(dolist (x '(:hunchentoot :cl-who :parenscript :cl-fad))
(ql:quickload x))
(defpackage "EXPERIMENTS"
(:use "COMMON-LISP" "HUNCHENTOOT" "CL-WHO" "PARENSCRIPT" "CL-FAD"))
(in-package "EXPERIMENTS")
@tormaroe
tormaroe / fpl.lisp
Created May 17, 2016 21:06
Fantasy Premiere League fetch players
(defun fetch-and-spit-player (idx)
(let ((path (format nil "C:\\temp\\fpl\\~A.json" idx)))
(with-open-file (fs path :direction :output
:if-exists :overwrite
:if-does-not-exist :create)
(format t "Output: ~A~%" path)
(format fs (flexi-streams:octets-to-string
(drakma:http-request
(format nil "http://fantasy.premierleague.com/web/api/elements/~A/" idx))
:external-format :UTF-8)))))
@tormaroe
tormaroe / foo.lisp
Last active March 23, 2016 23:38
CL Redis DOB metrics test data
(ql:quickload :cl-redis)
(redis:connect :port 7777)
(red:select 9)
(defvar *start* 201603231200)
(defvar *end* 201603231259)
(defvar *bu-names* '(
@tormaroe
tormaroe / roman-calc.lisp
Created January 29, 2016 23:37
Add roman numerals in Common Lisp
(defun mapcn (chars nums string)
(loop as char across string
as i = (position char chars)
collect (and i (nth i nums))))
(defun parse-roman (R)
(loop with nums = (mapcn "IVXLCDM" '(1 5 10 50 100 500 1000) R)
as (A B) on nums if A sum (if (and B (< A B)) (- A) A)))
(defun +roman (&rest rx)
@tormaroe
tormaroe / sms.lisp
Created November 18, 2015 06:59
A simple Common Lisp package to send text using LINK Mobility SMS gateway.
(in-package :cl-user)
(defpackage :sms
(:documentation
"A simple package to send SMS using LINK Mobility")
(:use :cl)
(:import-from :drakma :http-request)
(:import-from :cl-who :with-html-output-to-string :str :esc)
(:export :<gateway>
:send-sms))
(in-package :sms)
@tormaroe
tormaroe / 1_reverse-game.rkt
Last active August 29, 2015 14:18
A simple game of skill, implemented in Racket and C#
#lang racket
;; Author: Torbjørn Marø
;; Inspired by Peter Sessions REVERSE game
;; as published in 'BASIC Computer Games' (1978)
;; http://www.atariarchives.org/basicgames/showpage.php?page=135
(displayln "Welcome to REVERSE -- A Game of Skill! ")
(newline)
(displayln "To win, all you have to do is arrange a list ")
@tormaroe
tormaroe / gamekata-kinema.csm
Created March 24, 2014 21:22
My implementation in Scheme of the game Kinema, that was published in BASIC Computer Games in 1978.
(use srfi-13 extras)
(printf #<<EOF
KINEMA
Adaption of BASIC computer game from 1978
EOF
)
@tormaroe
tormaroe / gamekata-word.csm
Created March 23, 2014 01:00
My implementation in Scheme of the game Word, that was published in BASIC Computer Games in 1978.
(use srfi-13 extras)
(define header #<<EOF
--------------------------------------------------------------------
WORD
Adaption of original game in BASIC by Charles Reid of Lexington High
School, Massachusetts. Scheme version by Torbjørn Marø, 2014.
--------------------------------------------------------------------
I am thinking of a word -- you guess it. I will give you clues to
@tormaroe
tormaroe / README.md
Created December 20, 2013 23:36
XMASLANG, a small programming language I created for my xmas calendar competition 2013.

To run this you need node and the PEG.js module installed.

To create the parser.js file, run:

pegjs grammar.peg parser.js

Now to compile the xmaslang source, run:

node parser.js program.xmas > programm.js
@tormaroe
tormaroe / xmas-secret.js
Created December 9, 2013 20:16
A very simple cryptography JavaScript module created for my xmas calendar 2013.
var encryption = function() {
// Works with ASCII chars from 32 (space)
// to 248 (å).
var shiftCharCode = function(code, shift) {
if (shift < 0) shift += (248 - 32 + 1)
return 32 + (((code - 32) + shift) % (248 - 32 + 1));
};