Skip to content

Instantly share code, notes, and snippets.

@uvtc
uvtc / gist:5110760
Created March 7, 2013 19:02
test gist for Rust code
struct Point {
x: float,
y: float,
}
enum Shape {
Circle(Point, float),
Rectangle(Point, Point),
}
@uvtc
uvtc / gist:5213415
Created March 21, 2013 14:26
quil skeleton starter standalone app
(ns my-quil-app.core
(:require [quil.core :as q])
(:gen-class))
;; `setup` is called once when we start up.
(defn setup []
(q/smooth) ;; Turn on anti-aliasing.
(q/frame-rate 1) ;; Set framerate to 1 FPS.
(q/background 200)) ;; Set the background colour to
;; a nice shade of grey.
@uvtc
uvtc / gist:5225592
Last active December 15, 2015 07:48
text with quil
(ns text-example.core
(require [quil.core :as q])
(:gen-class))
(def screen-width 640)
(def screen-height 480)
(def blue [53 108 237])
(def yellow [235 229 20])
@uvtc
uvtc / gist:5440450
Created April 23, 2013 02:49
find and count number palindromes (convert the int to a string, then see if it's the same backwards)
;; try1.clj
(require '[clojure.string :as str])
(defn count-palindromes
[max]
(let [n (atom 0)]
(doseq [i (range 10 max)]
(let [i-str (str i)
i-rstr (str/reverse i-str)]
#!/usr/bin/java -jar /home/john/opt/clojure-1.5.1/clojure-1.5.1.jar
(println "hi")
@uvtc
uvtc / gist:6894554
Created October 9, 2013 01:07
Running this via lein-exec, and also, without it.
(require 'leiningen.exec)
(leiningen.exec/deps '[[org.clojure/math.combinatorics "0.0.4"]])
(require '[clojure.math.combinatorics :as combo])
(println
(combo/combinations [1 2 3] 2))
#!/bin/bash
lein run -m clojure.main/main -i "$@"
@uvtc
uvtc / gist:6894751
Last active December 25, 2015 01:28
(def items ["florian" "fluid" "flack" "flask" "flan"])
;; Find the item that begins with "flu".
(println (first (filter (fn [s]
(re-find #"^flu" s))
items)))
@uvtc
uvtc / gist:6895758
Created October 9, 2013 03:28
using pomegranate in a script
#!/usr/bin/env lein-run
(require '[cemerick.pomegranate :as pome])
(pome/add-dependencies
:coordinates '[[org.clojure/math.combinatorics "0.0.4"]]
:repositories (merge cemerick.pomegranate.aether/maven-central
{"clojars" "http://clojars.org/repo"}))
(require '[clojure.math.combinatorics :as combo])
@uvtc
uvtc / gist:6896279
Last active December 25, 2015 01:39
decoding base64-encoded text
(require '[clojure.data.codec.base64 :as base64])
;;---------------------------------------------------
;; From <http://en.wikipedia.org/wiki/Base64>
(def input "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz
IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg
dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu
dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo
ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")