Skip to content

Instantly share code, notes, and snippets.

@michiakig
michiakig / three.cljs
Created August 19, 2011 20:53
three.js demo in ClojureScript
(ns three.demo)
(def camera (THREE.Camera. 75 (/ window/innerWidth
window/innerHeight) 1 10000))
(set! (.z (.position camera)) 1000)
(def scene (THREE.Scene.))
(def geometry (THREE.CubeGeometry. 200 200 200))
(def obj (js/Object.))
(set! (.color obj) 0xff0000)
(set! (.wireframe obj) true)
(def material (THREE.MeshBasicMaterial. obj))
@alandipert
alandipert / kahn.clj
Last active June 24, 2023 17:59
Kahn's topological sort in Clojure
;; Copyright (c) Alan Dipert. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; 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.
(ns alandipert.kahn
(:require [clojure.set :refer [difference union intersection]]))
@hyone
hyone / gist:1621163
Created January 16, 2012 14:39
Parallel download images from a picture site
;; (defproject parallel-download "1.0.0-SNAPSHOT"
;; :description "FIXME: write description"
;; :dependencies [[org.clojure/clojure "1.3.0"]
;; [clj-http "0.2.7"]
;; [enlive "1.0.0-SNAPSHOT"]]
;; :dev-dependencies [[swank-clojure "1.3.4"]]
;; :main parallel-download.core)
(ns parallel-download.core
(:use [clojure.string :only (join split)]
@semperos
semperos / clojure-deftype-scaffolding.clj
Created October 4, 2012 18:16
Clojure Scaffolding for deftype (Christophe Grand) - Show which methods a class implements and for which interfaces
;; Big thanks to Christophe Grand - https://groups.google.com/d/msg/clojure/L1GiqSyQVVg/m-WJogaqU8sJ
(defn scaffold [iface]
(doseq [[iface methods] (->> iface .getMethods
(map #(vector (.getName (.getDeclaringClass %))
(symbol (.getName %))
(count (.getParameterTypes %))))
(group-by first))]
(println (str " " iface))
(doseq [[_ name argcount] methods]
(println
(ns async-test.throttle.core
(:require [cljs.core.async :refer [chan close!o sliding-buffer]]
[clojure.string :as string])
(:require-macros
[cljs.core.async.macros :as m :refer [go alts!]]))
(def c (chan (sliding-buffer 1)))
(def loc-div (.getElementById js/document "location"))
(.addEventListener js/window "mousemove"
@justinhj
justinhj / clojure-heap.clj
Last active September 30, 2019 03:02
A binary queue and heap sort in Clojure
;;; An implementation of a binary heap in Clojure
;;; This is an algorithm used for efficiently taking the
;;; largest value from a collection. Commonly used to implement
;;; a priority queue
;;; The heap itself is stored as a vector. For convenience with
;;; array indexing the first element is set to nil and not used
;;; I wrote this as a learning experience not to be used to land
;;; jet aircraft or manage a nuclear reactor.
;;; Should be reasonably efficient though.
@gsoltis
gsoltis / rx.firebase.js
Last active May 6, 2024 03:17
Quick Firebase / RxJS binding prototype
(function () {
var makeCallback = function(eventType, observer) {
if (eventType === 'value') {
return function(snap) {
observer.onNext(snap);
};
} else {
return function(snap, prevName) {
// Wrap into an object, since we can only pass one argument through.
observer.onNext({snapshot: snap, prevName: prevName});
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active May 7, 2024 13:07
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@Chort409
Chort409 / gist:eb46f4d95261d9af51e9
Created November 26, 2014 03:33
Sql like join in clojure
(ns sql-like-join
(:require [clojure.set :refer [difference
intersection
union]]))
(defn inner-join
[left-keys right-keys]
(intersection (set left-keys) (set right-keys)))
(defn outer-join