This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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/") | |
;; -------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '[email protected]', 'password' | |
# Get the user data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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)])) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"flag" // command line option parser | |
) | |
var omitNewline = flag.Bool("n", false, "don't print final newline") | |
const ( |
OlderNewer