Skip to content

Instantly share code, notes, and snippets.

View lantiga's full-sized avatar

Luca Antiga lantiga

View GitHub Profile
@lantiga
lantiga / gist:288267
Created January 27, 2010 23:20
Python NSNotificationCenter implementation
# Copyright (c) 2010, Luca Antiga, Orobix Srl.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
@lantiga
lantiga / let-map.clj
Last active October 11, 2015 17:58
let-map macro (creating a map using a let form) and map-let (using a map to establish local bindings in a let form)
(defmacro let-map
"Takes a binding form (as in let) and returns a map of (keywordized)
binding names and bound values. It allows to construct a map sequentially.
Usage:
(let-map [a 1 b (+ a 1)])
=> {:a 1 :b 2}"
[kv]
(let [ks (map keyword (take-nth 2 kv))]
`(let [~@kv]
(into {} (map vec (partition 2 (interleave '~ks (take-nth 2 ~kv))))))))
@lantiga
lantiga / archimedes-test.project.clj
Last active May 24, 2016 19:38
Working setup and sample Clojure code for Archimedes and Ogre (http://clojurewerkz.org/) on OrientDB 1.3 (http://orientdb.org/) via Blueprints (https://github.com/tinkerpop/blueprints/wiki).
(defproject archimedes-test "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[com.orientechnologies/orient-commons "1.3.0"]
[com.orientechnologies/orientdb-core "1.3.0"]
[com.tinkerpop.blueprints/blueprints-orient-graph "2.3.0"]
[clojurewerkz/ogre "2.3.0.1"]
@lantiga
lantiga / core.clj
Created January 12, 2014 00:12
asyncatom
(ns asyncatom.core
(:require [clojure.core.async :refer [chan go <! >! <!!]])
(:refer-clojure :exclude [atom swap! reset! compare-and-set! deref]))
(defn atom [v]
(let [c (chan)]
(go
(loop [v v]
(let [[cmd oc & args] (<! c)
v (condp = cmd
@lantiga
lantiga / react_ki
Last active August 29, 2015 13:56
ki port of the official React tutorial: http://facebook.github.io/react/docs/tutorial.html. See ki at https://github.com/lantiga/ki.
ki -o react_ki.out.js react_ki.js
@lantiga
lantiga / state.ki.js
Last active July 21, 2019 23:07
State management in ki (http://ki-lang.org)
ki macro (export $name $val)
(js exports.$name = $val)
ki require core
// Ported from https://github.com/clojure/clojurescript/blob/master/src/cljs/clojure/data.cljs
ki (ns diff
@lantiga
lantiga / core.clj
Last active August 29, 2015 14:10
Naive pure rule engine
(ns carla.core
(:require [clojure.math.combinatorics :as combo]))
(defn- fact-matches? [fact match]
(= match (select-keys fact (keys match))))
(defn make-rules [] [])
(defn make-session [] {:facts #{}})
### Keybase proof
I hereby claim:
* I am lantiga on github.
* I am lantiga (https://keybase.io/lantiga) on keybase.
* I have a public key whose fingerprint is C364 40F7 E6D0 2B02 AF9C FC34 BE4B 71AA 57A8 4B6A
To claim this, I am signing this object:
@lantiga
lantiga / vmtk.rb
Created June 10, 2017 14:18
Brew formula for vmtk 1.3.2
class Vmtk < Formula
desc "The Vascular Modeling Toolkit"
homepage "http://www.vmtk.org"
url "https://github.com/vmtk/vmtk/archive/v1.3.2.tar.gz"
version "1.3.2"
sha256 "2632a74341605bd3ddd97971fad70941329e77a112f9363bc5053a1e2ba7c30e"
head "https://github.com/vmtk/vmtk.git"
revision 1
# bottle do
@lantiga
lantiga / tracing_blocks.py
Created September 11, 2017 22:21
PyTorch namespaces tests
import torch
import torch.nn as nn
from torch.autograd import Variable
from graphviz import Digraph
def name(node, annotation=None):
kind = node.kind()