Skip to content

Instantly share code, notes, and snippets.

@fogus
fogus / currying.js
Created September 7, 2012 12:30 — forked from puffnfresh/currying.js
Support for both curried and uncurried application in functional JavaScript
function curry(f) {
return function(x) {
var g = f.bind(this, x);
if(g.length == 0) return g();
if(arguments.length > 1) return curry(g).apply(this, [].slice.call(arguments, 1));
return curry(g);
};
}
var sum = curry(function(x, y) {
@murtaza52
murtaza52 / config.clj
Created August 30, 2012 13:27
Pallet config file
(defpallet
;; you can specify global data in the :environment key here
;;
:environment {
:algorithms
{:lift-fn pallet.core/parallel-lift
:converge-fn
pallet.core/parallel-adjust-node-counts}}
:admin-user
{:username "ubuntu"
@bryanwoods
bryanwoods / app.cljs
Created August 17, 2012 21:55
More ClojureScript for Engibeering...
; Proper namespaces
(ns app-utils)
; JavaScript interop
(defn -alert [message]
(js/alert message))
(defn -log [message]
(.log js/console message))
Vagrant::Config.run do |config|
config.vm.box = "omnios"
config.vm.box_url = "http://omnios.omniti.com/media/omnios-latest.box"
config.vm.provision :shell do |shell|
shell.inline = <<-EOH.gsub(/^ {6}/, '')
cp -R /opt/omni/lib/ruby/gems/1.9/* /opt/omni/lib/ruby/gems/1.9.1
for ruby_binary in chef-client knife ohai shef erubis
do
ln -sf /opt/omni/lib/ruby/gems/1.9.1/bin/${ruby_binary} /opt/omni/bin/${ruby_binary}
@swannodette
swannodette / gist:3217582
Created July 31, 2012 14:52
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@martintrojer
martintrojer / queries.clj
Created July 16, 2012 12:16
Datomic queries in core.logic
(ns queries
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:use [datomic.api :only [q]]))
(defn query [rule xs]
(let [prule (prep rule)]
(map #(binding-map* prule (prep %)) xs)))
;; ---
@ayosec
ayosec / content.md
Created July 16, 2012 10:13
Why Lisp macros are cool, a Perl perspective
@jsmorph
jsmorph / logicrels-lucene.clj
Created July 6, 2012 14:01
Lucenalog: Datalog interface to Lucene in 10 lines
(ns lucenalog.core
"Lucenalog = Datalog interface to Lucene in 10 lines.
Simple but powerful.
Use
(db/add (index) {:a \"foo\" :b \"bar\"})
to index a map with Lucene. Then you can use the relation
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@andsens
andsens / bootstrap_homeshick.sh
Last active December 13, 2024 17:55
Script that can set up an entire user account with homeshick automatically
#!/bin/bash -ex
# Paste this into ssh
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex
# When forking, you can get the URL from the raw (<>) button.
### Set some command variables depending on whether we are root or not ###
# This assumes you use a debian derivate, replace with yum, pacman etc.
aptget='sudo apt-get'
chsh='sudo chsh'