Skip to content

Instantly share code, notes, and snippets.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<xsl:output method="text" encoding="utf-8" />
<xsl:strip-space elements="*"/>
<xsl:template match="ss:Row"><xsl:apply-templates select="ss:Cell" /><xsl:text>
</xsl:text>
</xsl:template>
@scottdw
scottdw / gist:26e2491e53ebc28649f5
Created September 6, 2014 09:34
Discrete fourier transform clojure and jtransforms
(ns scottdw.feip.core
(:import [java.awt Image]
[java.awt.image BufferedImage]
[org.imgscalr Scalr]
[org.jtransforms.fft DoubleFFT_2D RealFFTUtils_2D])
(:require [mikera.image.core :as img]
[mikera.image.colours :as ic]
[clojure.core.matrix :as mat]))
(defn gen-p-img []
@scottdw
scottdw / jpeg.clj
Last active December 24, 2015 14:29
Start of a clojure JPEG file decoder.
(ns scottdw.jpeg
(:import [clojure.lang Keyword]
[com.drew.imaging ImageMetadataReader]
[com.drew.metadata Directory Metadata Tag]
[java.net URI]
[java.nio ByteBuffer]
[java.nio.file Files Paths])
(:require [clojure.java.io :as io]))
(defn read-metadata [^String file-name]
(ns scottdw.mmgr.gl
(:import [javax.media.opengl DebugGL3 GL GL2 GL3 GLAutoDrawable GLCapabilities GLEventListener GLProfile]
[com.jogamp.newt NewtFactory]
[com.jogamp.newt.event WindowAdapter WindowEvent]
[com.jogamp.newt.opengl GLWindow])
(:require [clojure.java.io :as io]
[taoensso.timbre :as timbre :refer (trace debug error)]))
(defn create-shader [^GL3 gl resource type]
(let [source (slurp (io/resource resource))
(ns scottdw.plot.demo
(:import [java.util Random]
[org.jzy3d.analysis AnalysisLauncher AbstractAnalysis]
[org.jzy3d.chart Chart]
[org.jzy3d.chart.factories AWTChartComponentFactory]
[org.jzy3d.colors Color ColorMapper]
[org.jzy3d.colors.colormaps ColorMapRainbow]
[org.jzy3d.maths Coord3d Range]
[org.jzy3d.plot3d.builder Builder Mapper]
[org.jzy3d.plot3d.builder.concrete OrthonormalGrid]
(ns scottdw.image
(:import
[java.awt Color Image Dimension]
[java.awt.image BufferedImage]
[java.io File]
[javax.imageio ImageIO]
[javax.swing JFrame JPanel])
(require [scottdw.stats :as stats]))
(defn read-image [^String filename]
@scottdw
scottdw / stats.clj
Created June 20, 2012 14:07
Some helper functions in Clojure for statistics
(ns stats)
(defn mode [vs]
(let [fs (frequencies vs)]
(first (last (sort-by second fs)))))
(defn quantile
([p vs]
(let [svs (sort vs)]
(quantile p (count vs) svs (first svs) (last svs))))
(defn neighbours-fn [w h n]
(letfn [(has-w [i] (not (zero? (rem i w))))
(pos-w [i] (dec i))
(has-n [i] (>= i w))
(pos-n [i] (- i w))
(has-e [i] (not (zero? (rem (inc i) w))))
(pos-e [i] (inc i))
(has-s [i] (< i (* w (dec h))))
(pos-s [i] (+ i w))]
(let [pred-pos-m {:w [has-w pos-w]
@scottdw
scottdw / capslock-as-control.reg
Created June 28, 2011 15:45
Remap caps lock to left control
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@scottdw
scottdw / gist:605354
Created September 30, 2010 21:29
Based on http://nakkaya.com/2010/08/17/visualising-the-wikileaks-war-logs-using-clojure using http://en.wikipedia.org/wiki/File:United_Kingdom_location_map.svg 500px png. Draws a red marker (16px square) at each of the long/latitude pairs provided to the
(import
[java.awt.geom Rectangle2D$Double]
[java.awt Dimension Color]
[javax.swing JFrame JLabel]
[java.io File]
[javax.imageio ImageIO])
(defn translate-scale-fn [min max target]
(let [scale-factor (/ target (- max min))]
(fn [v]