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
/* REXX *** */
/* echo the input parameters */
PARSE ARG parms
nargs = WORDS(parms)
Say 'There are 'nargs' parameters'
DO i = 1 to nargs
Say Right(i,4)'=>'WORD(parms,i)
End i
Exit 0
fibonacci(n: ZZ): ZZ requires { n >= 0 } =
if n < 2 then n else fibonacci(n-1) + fibonacci(n-2) end
#!/usr/local/bin/perl
#
# create a series of directories
#
if ($#ARGV != 2) {
print "usage: mkdirs base start stop\n";
exit;
}
$base = $ARGV[0];
with Gnat.Io; use Gnat.Io;
procedure Arr1 is
A: array(1..5) of Integer; -- Array subscripts 1 to 5.
I: Integer;
begin
-- Read 'em in.
for I in 1..5 loop
Put("> ");
Get(A(I));
end loop;
@tormaroe
tormaroe / SI-prefix.clj
Created April 3, 2011 17:40
A test-driven implementation of conversion of numbers to and from SI-prefix in Clojure
(ns si_prefix.core
(:use clojure.test
clojure.contrib.generic.math-functions))
(def factors
(zipmap [:y :z :a :f :p :n :u :m :k :M :G :T :P :E :Z :Y]
(map (partial pow 1000)
(filter (complement zero?)
(range -8 9)))))
@tormaroe
tormaroe / formatting.clj
Created April 7, 2011 19:09
This script produces some samples of how to use formatting
;; This script will generate a formatting demo
;; Call it with a filename to dump demo to file
(ns demo.formatting
(:use [clojure.contrib.duck-streams :only [with-out-writer]]
[clojure.string :only [join]])
(:import java.util.Date))
(defn print-demo-code [fmt & args]
(printf "%-50s ;=> %s%n"
class Stack_calc(object):
'''Stack calulator'''
def __init__(self):
self.item = []
self.calculate =
{'+' : lambda: self.item.append(self.item.pop() + self.item.pop()),
'-' : lambda: self.item.append(self.item.pop() - self.item.pop()),
'*' : lambda: self.item.append(self.item.pop() * self.item.pop()),
'/' : lambda: self.item.append(self.item.pop() / self.item.pop())}
@tormaroe
tormaroe / Form1.cs
Created July 4, 2011 16:00
Oscilloscope user control (WinForms)
// JUST A TEST FORM WITH TWO SCOPE CONTROLS AND SOME RANDOM DATA
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
@tormaroe
tormaroe / mywebapp_stats.rb
Created September 20, 2011 18:15
A logfile stats aggregator hack
unless ARGV.length == 2
raise <<EOF
Usage: mywebapp_stats.rb folder filepattern
Example: mywebapp_stats.rb . AccountWeb.log*
EOF
end
@tormaroe
tormaroe / betterave.rb
Created December 13, 2011 14:42
Betterave interpreter
#!/usr/bin/ruby
#
# Betterave -- Programmation fonctionnelle obscure
#
class Source
attr_reader :index, :stuff
def initialize(stuff)