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 / euler1_dialect.r
Created December 19, 2011 13:14
A dialecting/DSL sample in Rebol
REBOL [
Title: "Euler1 dialecting example"
Author: "Torbjørn Marø"
Home: http://blog.kjempekjekt.com
Date: 19-Dec-2011
Purpose: {
This script demonstrates how to use the built in parse
functionality of Rebol to create an internal DSL.
This particular DSL lets you create sums that are the
@tormaroe
tormaroe / preformat.rb
Last active December 10, 2015 05:18
Small script that modifies the content of the clipboard by HTML encoding dangerous characters and wraps i in a <pre>-tag. Used when blogging source code.
=begin
TO INSTALL DEPENDENCIES
-----------------------
gem install ffi <-- For Windows users
gem install clipboard
=end
HTML_CODES = {
"&" => "&amp;",
">" => "&gt;",
@tormaroe
tormaroe / Logalert.rb
Last active August 16, 2018 20:08
A very simple DSL for monitoring log files that I'm working on.
require './parser'
require './nodes_eval'
class Runtime
def initialize
@file = "test.log"
end
def loglines
@lines = File.readlines(@file)
@lines.each_with_index do |line, index|
@tormaroe
tormaroe / make.rb
Created March 28, 2013 06:16
A small script to parse a text file and produce output for Wordle.
# Encoding: UTF-8
Encoding.default_external = "UTF-8"
require 'benchmark'
BLACKLIST = %w(på og er om fra med i to det å
ditt til ved fra for av en din
du at vi har vil nå det som dere
kan vår så)
@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));
};
@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 / 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 / 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 / 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 / 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)