Skip to content

Instantly share code, notes, and snippets.

// Michael Detmold
//A program that draws a box fractal
import org.learninggroovy.graphicswindow.GraphicsWindow
import java.awt.*
window = GraphicsWindow.getBlankWindow(700,700)
def ss = 5,dims = 670
def sx =ss,sy =ss
ite = 7
@himerzi
himerzi / HTMLSpider.groovy
Created September 15, 2011 15:46
HMTL Link constructor
/*
*Michael Detmold Groovy Coursework 1. November 2010.
*This program will fetch a web page and then construct an index of all the other pages the web page links to. It can do this for several layers of linking.
*/
address = "http://www.google.com"//this is the base address to start building the list of links from
levels = 2 //this is how many levels of linking withing the base website the program should go.
// '/' DENOTES A REGULAR EXPRESSION
@himerzi
himerzi / michael-what-a-G.node.js
Created August 6, 2012 09:12
A super-fast, asynchronous I/O, scalable, robust and event-driven, web-optimised, single-purpose, server.
var express = require('express');
var app = express.createServer(express.logger());
app.get('/', function(request, response) {
response.send('Hello World!');
});
var port = process.env.PORT || 5000;
app.listen(port, function() {
@himerzi
himerzi / core.clj
Last active December 27, 2015 12:39
Clojure Session 1 Exercise
(ns d1.core (:gen-class))
(use 'clojure.java.io)
;;To run these examples:
;; lein repl
;; user=> (require 'd1.core)
;; to call main
;; user=> (d1.core/-main)
(defn n-random
"I return a vector of N random numbers"
[n]
(defproject weather "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-http "0.7.7"]])
(defn weather-find [something]
(let [ response (http/get (str weather-api "find")
{:query-params {:q something}
:as :json})]
(:body response)))
(defn get-london []
(weather-find "London"))
;; This is broken and I don't understand why
@himerzi
himerzi / core.clj
Last active December 28, 2015 16:39
weather homework exercises
(ns weather.core
(:require [clj-http.client :as http]))
;; utility Functions
(def weather-api
"http://api.openweathermap.org/data/2.5/")
(defn weather-find [something]
(let [ response (http/get (str weather-api "find")
{:query-params {:q something}
:as :json})]
@himerzi
himerzi / ef.clj
Last active December 28, 2015 18:39
Different E.F. marketing thingies.
(cond
(>= ambition 90) (apply-to entrepreneurFirst)
(>= ambition 80) "something else"
(>= ambition 70) "something else"
(>= ambition 60) "etc..."
:else "F")
(case careerPath
"Founder" (apply-to entrepreneurFirst)
"Banker" (#Something else?#))
@himerzi
himerzi / efv2.clj
Last active December 29, 2015 02:29
ef apply v2
(filter #(and (= (:technical-ability %) "high")
(= (% :ambition) "extraordinary"))
[{:student true :ambition "extraordinary" :technical-ability "high"}
{:student true :ambition "average" :technical-ability "minimal"}])
;;;;; OR THIS ;;;;;
(def applicants
[{:student true :ambition "extraordinary" :technical-ability "high"}
We shall not cease from exploration
And the end of all our exploring
Will be to arrive where we started
And know the place for the first time.