Skip to content

Instantly share code, notes, and snippets.

View stathissideris's full-sized avatar

Stathis Sideris stathissideris

  • London
View GitHub Profile
@stathissideris
stathissideris / gist:3705914
Created September 12, 2012 10:51 — forked from Chouser/gist:3687532
Lazy seq as event subscription mechanism
;; Here is a spike of a lightweight in-process pubsub mechanism that allows pure ;; functional consumers, both blocking and asynchronous.
;; This defines the event stream, in this case just a series of numbers,
;; a new one produced each second
(defn timer []
(lazy-seq
(do
(Thread/sleep 1000)
(cons (System/nanoTime) (timer)))))
@matthutchinson
matthutchinson / fnotify.pl
Created August 21, 2010 10:47
Irssi fnotify
# todo: grap topic changes
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = '0.0.3';
%IRSSI = (
authors => 'Thorsten Leemhuis',
contact => 'fedora@leemhuis.info',
@dkozma
dkozma / inspect.clj
Last active August 13, 2017 22:38
Clojure->Chrome Inspector
(ns inspect
(:require [cheshire.core :refer [generate-string]]
[clojure.java.io :as io])
(:import (java.net Socket)
(def host "localhost")
(def port 9000)
(defn cinspect [data]
(with-open [sock (Socket. host port)
@gfredericks
gfredericks / bijections.clj
Created March 19, 2018 17:07
Half a draft of bijections in clojure
(ns user.bijections
(:refer-clojure :exclude [-> comp update])
(:require [clojure.core :as core]
[clojure.set :as set])
(:import (java.util UUID)))
;;
;; Motivation:
;;
;; - avoid the edge cases inherent in allowing multiple
@Deraen
Deraen / spec-coercion.clj
Created June 14, 2016 15:47
Clojure.spec coercion test
(ns spec-test.core
(:require [clojure.spec :as s]))
(defn x-integer? [x]
(if (integer? x)
x
(if (string? x)
(try
(integer/parseint x)
(catch exception e
@Risto-Stevcev
Risto-Stevcev / spectest.cljs
Last active October 31, 2019 18:53
Some functions to help integrate clojure.spec.test/check with cljs.test/deftest
(ns foo-test
(:require [cljs.spec :as s]
[cljs.spec.test :as stest]
[clojure.pprint :as pprint]
[cljs.test :refer-macros [deftest is]]))
;; Sample function and a function spec
(defn fooo [i] (+ i 20))
(s/fdef fooo
@bhauman
bhauman / README.md
Last active December 3, 2019 16:43
ClojureScript minimal dev and prod setup.

Recent improvements to the ClojureScript compiler have greatly simplified setting up development versus production outputs.

This example uses Figwheel as something that you want to exclude for production, but the pattern is general.

With this simple setup you only need one html file/view and it will work for developement and production.

@kennyjwilli
kennyjwilli / defspec-test.clj
Created November 5, 2016 01:37
clojure.spec.test integration with clojure.test
(defmacro defspec-test
([name sym-or-syms] `(defspec-test ~name ~sym-or-syms nil))
([name sym-or-syms opts]
(when t/*load-tests*
`(def ~(vary-meta name assoc :test `(fn []
(let [check-results# (clojure.spec.test/check ~sym-or-syms ~opts)
checks-passed?# (every? nil? (map :failure check-results#))]
(if checks-passed?#
(t/do-report {:type :pass
:message (str "Generative tests pass for "
@stuarthalloway
stuarthalloway / gist:2645453
Created May 9, 2012 15:22
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")
@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)))