Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / foo.clj
Created June 7, 2013 07:02
A quick example of some text handling techniques for Clojure
(defn to-float [x]
(when x (Float/parseFloat x)))
(defn to-int [x]
(when x (Integer/parseInt x)))
(defn process-data [data]
(let [field-format (array-map :id to-int
:name identity
:score to-float)]
@cemerick
cemerick / gist:5457242
Last active April 20, 2024 19:51
Using language-detection from Clojure
; using https://code.google.com/p/language-detection/
; i.e. [com.cybozu.labs/langdetect "1.1-20120112"]
(require '[clojure.java.io :as io])
(->> #{"af" "ar" "bg" "bn" "cs" "da" "de" "el" "en" "es" "et" "fa" "fi" "fr" "gu"
"he" "hi" "hr" "hu" "id" "it" "ja" "kn" "ko" "lt" "lv" "mk" "ml" "mr" "ne"
"nl" "no" "pa" "pl" "pt" "ro" "ru" "sk" "sl" "so" "sq" "sv" "sw" "ta" "te"
"th" "tl" "tr" "uk" "ur" "vi" "zh-cn" "zh-tw"}
(map (partial str "profiles/"))
@sachac
sachac / emacsconf2013-sacha.org
Created March 31, 2013 00:04
Source code for my Emacs conference talk

Comments? sacha@sachachua.com

  • Emacs learning curve?

Meta information

Assumptions

  • Mix of Emacs geeks skewed towards people who’ve been using this for a while (after all, takes a certain commitment to come all the way to an Emacs conference!)

Outcomes

@avescodes
avescodes / Editing Clojure with Emacs
Last active July 5, 2022 13:32
Get started editing Clojure in Emacs with this basic config.
Check out README.md to get started editing Clojure with Emacs.
@errordeveloper
errordeveloper / Unicorn_and_Upstart.md
Last active February 9, 2022 09:21
Upstart config for a Rails app using Unicorn HTTP server

Using Unicorn with Upstart

This configuration works with Upstart on Ubuntu 12.04 LTS

The reason why it needs to be done this way (i.e. with the pre-start and post-stop stanzas), is because Upstart is unable to track whever Unicorn master process re-execs itself on hot deploys. One can use it without hot-deploys and run Unicorn in foreground also, it then only needs one exec stanza.

This presumes you are not using RVM, so no voodoo dances.

@DamienCassou
DamienCassou / update-emacs-ppa.sh
Last active February 20, 2016 21:26
Emacs-snapshot and emacs24 build script for Ubuntu PPA
#! /usr/bin/env bash
# Author: Damien Cassou
#
# This is the script I use to build Emacs packages for Ubuntu. These
# packages are uploaded to
# https://launchpad.net/~cassou/+archive/emacs/. Each package is
# either build from a Debian package or from
# http://emacs.naquadah.org/.
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@martintrojer
martintrojer / mandelbrot-ascii.clj
Last active September 30, 2015 23:18
Mandelbrot set
(defn c+ [[re1 im1] [re2 im2]] [(+ re1 re2) (+ im1 im2)])
(defn c* [[re1 im1] [re2 im2]]
[(- (* re1 re2) (* im1 im2)) (+ (* re1 im2) (* im1 re2))])
(defn c2 [c] (c* c c))
(defn |c| [[re im]] (Math/sqrt (+ (* re re) (* im im))))
(defn get-mandel-set [im-range re-range max-iter]
(for [im im-range
re re-range
:let [c [re im]]]
(ns recursive-tricks.recursive-tricks)
(defn uuid [] (str (java.util.UUID/randomUUID)))
(defn tail-recursive [f]
(let [state (ref {:func f :first-call true :continue (uuid)})]
(fn [& args]
(let [cont (:continue @state)]
(if (:first-call @state)
(let [fnc (:func @state)]
@seanlilmateus
seanlilmateus / gist:1386468
Created November 22, 2011 18:34
Macruby Face Detection in Mac OS X Lion
framework 'Cocoa'
framework 'QuartzCore'
class NSColor
def toCGColor
colorRGB = self.colorUsingColorSpaceName NSCalibratedRGBColorSpace
components = Array.new(4){Pointer.new(:double)}
colorRGB.getRed components[0], green:components[1], blue:components[2], alpha:components[3]