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
(comment "
SpeedNotes Clojure script, by Torbjørn Marø.
Version 1.1 - 2010.08.18
Clojure version 1.1 (w/Contrib)
======================================================================
Always have it running in a console window to quickly note down stuff
you need to remember - thoughts and ideas you don't want to loose,
but don't want to steal focus away from what you are currently doing
either.
@tormaroe
tormaroe / intouch.clj
Created November 23, 2010 14:44
Simple client implemented in clojure demonstrating how to use the PSWinCom Intouch REST API.
(ns intouch
(:use clojure.contrib.json)
(:require [clojure.contrib.http.agent :as http]
[clojure.contrib.base64 :as b64 ]))
;; Configuration ------------------------------------------------------------------
(def username "user@domain")
(def password "password")
(def base-url "http://intouchapi.pswin.com/1/")
;; --------------------------------------------------------------------------------
require 'net/http'
require 'json'
# Set up the request
uri = URI.parse 'http://intouchapi.pswin.com/1/user'
http = Net::HTTP.new uri.host, uri.port
req = Net::HTTP::Get.new uri.request_uri
req.basic_auth 'user@domain.com', 'password'
# Get the user data
(ns turing.core)
(comments "The turing machine runs on a table of rules defined by 5-tuples,
implemented here as maps with the following format:"
{ :tape value ; Given cell under head has value
:state value ; And machine state has value
:write value ; Then write value in cell
:move value ; Move head according to value (:left :right :no)
:set-state value }) ; And set new machine state to value
;; a program saying hello to the world
(use '[clojure.string :only (join)])
(def a (partial subs (slurp *file*)))
(def b #(a % (+ % 5)))
(print (join ", " [(b 20) (b 33)]))
import java.io.*;
class MyFirstProgram {
/** Print a hello message */
public static void main(String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String name = "Instructor";
System.out.print("Give your name: ");
try {
name = in.readLine();
}
@tormaroe
tormaroe / gcd.c
Created March 9, 2011 12:48
Greatest Common Devisor implementation from the Linux source code
#include <linux/kernel.h>
#include <linux/gcd.h>
#include <linux/module.h>
/* Greatest common divisor */
unsigned long gcd(unsigned long a, unsigned long b)
{
unsigned long r;
if (a < b)
PROGRAM CALCULATE
!
! Program to calculate the sum of up to n values of x**3
! where negative values are ignored.
!
IMPLICIT NONE
INTEGER I,N
REAL SUM,X,Y
READ(*,*) N
SUM=0
$ SET SOURCEFORMAT"FREE"
IDENTIFICATION DIVISION.
PROGRAM-ID. Multiplier.
AUTHOR. Michael Coughlan.
* Example program using ACCEPT, DISPLAY and MULTIPLY to
* get two single digit numbers from the user and multiply them together
DATA DIVISION.
WORKING-STORAGE SECTION.
package main
import (
"os"
"flag" // command line option parser
)
var omitNewline = flag.Bool("n", false, "don't print final newline")
const (