Skip to content

Instantly share code, notes, and snippets.

View tommyettinger's full-sized avatar
⚙️
Keeping the commit streak alive

Tommy Ettinger tommyettinger

⚙️
Keeping the commit streak alive
View GitHub Profile
@tommyettinger
tommyettinger / core.clj
Last active December 9, 2015 21:48
Dice roller for SW:EotE's weird dice. Put project.clj in the project's root folder, put core.clj in src/dicer/ relative to that root, run `lein deps`, then `lein run`.
(ns dicer.core
(:use seesaw.core
[clojure.string :only [join trim split]]
dicer.prob)
(:import org.pushingpixels.substance.api.SubstanceLookAndFeel
)
(:import org.pushingpixels.substance.api.SubstanceConstants$FocusKind)
(:gen-class))
(native!)
(def queen
[:range :no :range :no :range
:no :range :range :range :no
:range :range :self :range :range
:no :range :range :range :no
:range :no :range :no :range
])
@tommyettinger
tommyettinger / colors.clj
Created October 8, 2013 00:25
Color constants in Clojure.
;; Redistributable under the Apache License
;; Authors: Eben Howard and Tommy Ettinger
;;"Alice Blue"
(def alice-blue 0xf0f8ff)
;;"Alizarin"
(def alizarin 0xE32636)
;;"Aloewood"
(def aloewood 0x6A432D)
;;"Aloewood Brown"
(ns opal.dbpedia
(:use [clojure.tools.logging :only [log]])
(:require [clojure.java.io :as io])
(:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser]
[org.neo4j.graphdb Label]
[org.neo4j.index.lucene.unsafe.batchinsert LuceneBatchInserterIndexProvider]
[org.neo4j.unsafe.batchinsert BatchInserters]
[org.neo4j.graphdb DynamicRelationshipType]))
;; PARSING METHODS
;; This code needs to be removed
;; (def open (atom {}))
(defn dijkstra
([a]
(do (dijkstra a (find-walls a) (find-lowest a))))
([a closed open-cells]
(let [open (transient open-cells)]
(while (not (empty? open))
(let [newly-open (transient {})]
{
"nil": {
"description": "Nothingness (from tiles.yml)",
"glyph": " ",
"day_color": {
"between": [
"black",
"black"
],
"mix": [
@tommyettinger
tommyettinger / DungeonTest.java
Last active January 2, 2016 22:09
Sample output of a herringbone wang tile dungeon generator.
import squid.squidgrid.map.HerringboneDungeon;
public class DungeonTest
{
public static void main(String[] args)
{
HerringboneDungeon hbd = new HerringboneDungeon(80,20);
System.out.println(hbd);
}
(defn multiple-trials [m n]
( loop [m m acc []]
(if (> m 0)
(recur (dec m) (conj acc (compute-winnings-for-a-trial n)))
acc)))
;; Usage instructions: lein run fontname.ttf 16 0x000000
;; change fontname.ttf to a font file's name, 16 to the font size you want, and 0x000000 to a color in RGB format.
(ns fontstuff.core
(:use [clojure.string :only [join trim split]])
(:import [java.awt Font Graphics2D RenderingHints Color Rectangle Shape FontMetrics]
[java.awt.font FontRenderContext GlyphVector TextLayout]
[java.awt.image BufferedImage]
[java.awt.geom Rectangle2D]
[java.io File]
[javax.imageio ImageIO])
@tommyettinger
tommyettinger / CustomViewport.scala
Created August 2, 2014 05:53
Viewport that should only stretch in integer increments, but doesn't
package commanders.unite.utils
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.utils.viewport.Viewport
;
/**
* Created by Tommy Ettinger on 8/1/2014.
*/