Skip to content

Instantly share code, notes, and snippets.

View joekunin's full-sized avatar

Joseph Kunin joekunin

View GitHub Profile
@michiakig
michiakig / ants.clj
Created July 19, 2011 22:37
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;dimensions of square world
@j05h
j05h / earthporn.rb
Created October 26, 2011 16:14
Download the imgur.com images from reddpics.com; Great for wallpapers/screensavers
#!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
def download path, site
url = "http://reddpics.com/moreimages/#{site}/#{path}"
agent = Mechanize.new
page = agent.get url
page.links_with(:href => /i.imgur.com/).map(&:href).uniq.each do |img|
@stonegao
stonegao / evolvefn.clj
Created November 3, 2011 03:22 — forked from lspector/evolvefn.clj
Clojure code for a simple genetic programming system, for demonstration purposes.
(ns evolvefn) ;; Lee Spector (lspector@hampshire.edu) 20111018
;; This code defines and runs a genetic programming system on the problem
;; of finding a function that fits a particular set of [x y] pairs.
;; The aim here is mostly to demonstrate how genetic programming can be
;; implemented in Clojure simply and clearly, and several things are
;; done in somewhat inefficient and/or non-standard ways. But this should
;; provide a reasonable starting point for developing more efficient/
;; standard/capable systems.
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@owainlewis
owainlewis / graph.clj
Created November 1, 2012 13:47
Clojure graph algorithms
(ns graph.core)
;; Graph algorithms
;; Simple adjacency list using maps
(def weighted-graph
{:A {:B 0, :C 0 }, :B { :C 0 }, :C {} })
;; a --> b
@rm-hull
rm-hull / penrose-tiling.cljs
Last active July 5, 2016 19:48
A Penrose tiling is a non-periodic tiling generated by an aperiodic set of prototiles. Penrose tilings are named after mathematician and physicist Roger Penrose who investigated these sets in the 1970s. This gist describes the tiling in terms of a rewriting grammar (an 'L-system') and renders using a turtle (https://github.com/rm-hull/turtle) on…
(ns lindenmayer-systems.demo
(:use [turtle.core :only [draw!]]
[turtle.renderer.vector :only [->svg]]
[turtle.renderer.canvas :only [->canvas]]
[enchilada :only [ctx canvas svg]]
[dommy.core :only [set-html! insert-after! replace! hide! show!]]
[jayq.core :only [show]])
(:use-macros [dommy.macros :only [sel1]]))
(def L '(:left 36))
@allgress
allgress / reagent_datascript.cljs
Last active February 16, 2023 21:16
Test use of DataScript for state management of Reagent views.
(ns reagent-test.core
(:require [reagent.core :as reagent :refer [atom]]
[datascript :as d]
[cljs-uuid-utils :as uuid]))
(enable-console-print!)
(defn bind
([conn q]
(bind conn q (atom nil)))
@john2x
john2x / 00_destructuring.md
Last active June 6, 2024 13:40
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@daveliepmann
daveliepmann / localstorage.cljs
Created September 23, 2014 08:23
HTML5 localStorage utility functions for ClojureScript. I find it makes for cleaner code when I wrap the native JS.
(ns localstorage)
(defn set-item!
"Set `key' in browser's localStorage to `val`."
[key val]
(.setItem (.-localStorage js/window) key val))
(defn get-item
"Returns value of `key' from browser's localStorage."
[key]
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active April 21, 2024 03:30
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront