Skip to content

Instantly share code, notes, and snippets.

View lantiga's full-sized avatar

Luca Antiga lantiga

View GitHub Profile
@honza
honza / Rocket.hs
Last active August 29, 2015 13:56
BSD/MIT licensed
-- This is a Haskell implementation of aphyr's
-- "Clojure from the ground up - modeling"
--
-- http://aphyr.com/posts/312-clojure-from-the-ground-up-modeling
--
-- Compile this with:
--
-- $ ghc -O Rocket.hs
import GHC.Exts
@cemerick
cemerick / gist:3657912
Created September 6, 2012 16:07
#{Ring, Compojure}-friendly shoreleave-remote backend
;;; this is now in a library: https://github.com/cemerick/shoreleave-remote-ring
(ns ^{:doc "Server-side RPC support for use with shoreleave (and maybe fetch?).
Mostly copied from https://github.com/shoreleave/shoreleave-remote-noir;
changed to eliminate the noir-isms..."}
cemerick.cljs.rpc)
(def default-remote-uri "/_fetch")
(def remotes (atom {}))
@swannodette
swannodette / boom.clj
Created November 27, 2012 23:45
path_constraint.clj
;; using defc from core.logic master
;; guarantee that a path of keys does not occur in map x,
;; note that the body of a defc is in fact just regular
;; Clojure code
(defc not-pathc [x path]
(= (get-in x path :not-found) :not-found))
(comment

Array abstraction in Clojure

Few days ago Mike Anderson wrote [a proposal][mike] for a generic matrix API in Clojure which could compete with NumPy. I wanted to write a similar post for months, but was reluctant to start. This problem is very dear to me. Basically, it is a matter if I can use Clojure for most of my work, or it remains a toy language for me. Thanks to Mike for bringing the question up. Though, I have a different vision of how we should approach arrays and matrices in Clojure.

(ns speed-test.core
;; Original Java Source
(:import LCS))
(set! *warn-on-reflection* true)
(defn time-it [num-trials f]
(loop [sum-ms 0 trials-left num-trials]
(let [start (System/currentTimeMillis)]
(f)
@cgrand
cgrand / comprehensions.clj
Created May 24, 2013 14:06
Comprehension framework, upon which are (re)implemented, for, doseq, reducible/foldable for and reduce-based doseq
;; I wrote this in the Eurostar on my way back from the last lambdanext.eu clojure course.
(ns comprehensions
(:refer-clojure :exclude [for doseq])
(:require [clojure.core.reducers :as r]))
;; borrowed from clojure.core
(defmacro ^{:private true} assert-args
[& pairs]
`(do (when-not ~(first pairs)
@grncdr
grncdr / not-exactly-thread-first.js
Last active January 3, 2016 02:08
This acts sort of like a thread first. Instead of actually modifying the arguments list, I implicitly assign the result of each line in the body to `$_` then you can use `$_` in the body to refer to the result of the last line.
macro thread {
case { $name ($args (,) ...) { $body ... } } => {
var result = makeIdent('$_', #{$name})
return withSyntax($$_ = [result]) {
console.log('here')
return #{
(function () {
var $$_ = arguments.length > 1 ? [].slice.call(arguments) : arguments[0];
thread_body $$_ $body ...;
return $$_
@ferventcoder
ferventcoder / InstallVagrantWindowsPluginFromSource.ps1
Last active November 19, 2016 04:40
Install Vagrant-Windows plugin from source
# WINDOWS
# =======
# This assumes you already have chocolatey installed:
# From cmd.exe:
# @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
# From powershell:
# iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
#
# This assumes you have vagrant already installed:
# cinst vagrant
@wellcaffeinated
wellcaffeinated / asm-helpers.js
Last active December 22, 2016 22:45
Helper module for creating collections of objects that store their properties inside typed arrays. Useful for managing objects that will be used by asm.js modules. Code by Jasper Palfree (http://wellcaffeinated.net) License: MIT See comments for usage examples. See this blog post for explanation: http://wellcaffeinated.net/articles/2013/04/16/pl…
/**
* asm-helpers.js
* A simple helper module for managing memory allocation of
* collections of objects, particularly for use in asm.js code
*
* Copyright (c) 2013 Jasper Palfree <jasper@wellcaffeinated.net>
* Licensed MIT
*/
(function (root, factory) {
if (typeof exports === 'object') {
@rnewson
rnewson / gist:2387973
Created April 14, 2012 21:31
CouchDB Future Feature List - Round 2
A list of features that we want to see in CouchDB. Needs to be voted on so that it can become a priority queue.
User Facing Features
====================
1. Conflicts are the rule, not the exception
All previous versions of CouchDB hide conflicts by default (selecting
an arbitrary but consistent winning revision). Expert users can find
and resolve conflicts.