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
;; 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.
*/
@tommyettinger
tommyettinger / diff.clj
Last active August 29, 2015 14:06 — forked from dagda1/diff.clj
(defn diff [l1 l2]
(let [a (group-by identity l1)
b (group-by identity l2)]
(mapcat #(repeat
(-
(count (second %))
(count (get b (key %))))
(key %))
a)))
@tommyettinger
tommyettinger / core.clj
Last active August 29, 2015 14:06
Working Simplex Noise shader with play-clj
(ns pixmappery.core
(:require [play-clj.core :refer :all]
[play-clj.entities :as e]
[play-clj.g2d :refer :all]
[play-clj.ui :refer :all])
(:import [com.badlogic.gdx.graphics.g2d Batch SpriteBatch]
[com.badlogic.gdx.graphics.glutils ShaderProgram]))
(defn vert [] "attribute vec4 a_position;
attribute vec4 a_color;
@tommyettinger
tommyettinger / AndroidMiniFormatter.java
Created February 24, 2015 01:43
MiniFormatter: formats some printf-style format strings on GWT
public class AndroidMiniFormatter implements MiniFormatter {
public static String format(final String formatString, final Object... args) {
return String.format(formatString, args);
}
}
1
stack: [1] //data, integer 1
1 +
stack: [(+ 1 _)] //curried function that will await an argument and add 1 to it
1 + 2
stack: [3] //argument has been supplied to an awaiting function, function is evaluated
//with full set of args
1 + 2 *
stack: [(* 3 _)] //another curried function that will await an argument and multiply it by 3
1 + 2 * [#
@tommyettinger
tommyettinger / dungeon.txt
Created October 29, 2015 05:54
Big Dungeon.
┌───────────────┐
┌─┘ . . . . . . . └─┐
┌───┬───┐ ┌─────┐ ┌───┐ ┌─────┐ │ . . . . . . . . . │
┌───────┘ ~ │ . └─┬─┘ . . └─┐ ┌───────────┘ . └─────┘ . . └───┐ │ . . . . . . . . . │
┌─┘ ~ ~ ~ ~ ~ , . . │ . .
@tommyettinger
tommyettinger / dungeon.txt
Last active October 29, 2015 06:41
More Dungeon.
┌───────────────────────────┐
┌─┘ . . . . . . . . . . ^ . . └─┐ ┌───┐ ┌─────────────────┐
│ . . . . . . . . . . . . . . . │ ┌───────┘ . └───────┐ │ . . . . . . . . │
└─┐ . . . . . . . . . ^ . . . ┌─┘ ┌─┘ . . . . . . . . . └─┐ │ . . . . . . . . │
@tommyettinger
tommyettinger / layer-dungeon.txt
Created November 3, 2015 07:13
Multi-Layer Dungeon
┌───────┬───────────────────────┐ ┌───────────────────────┐
┌─┘ . . . │ . . . . . . . . . . . └─┐ │ . . . . > . . . . . . │
│ . . . . . . . . . . . . . . . . . └─┐ │ . . . . . . . . . . . │
│ . . . . . . . . . . . . . . . . . > │ │ . . . . . . . . . . . │