Skip to content

Instantly share code, notes, and snippets.

what k4/k7 k9 example result
---------------------------------------------------------------------------------
each-left a f\:b a f\:b (!3)*\:!2 (0 0;0 1;0 2)
each-right a f/:b a f/:b (!3)*/:!2 (0 0 0;0 1 2)
fold f/v f/v */6 7 42
fold w/initial a f/v a f/v 7*/11 13 1001
scan f\v f\v -\1 1 1 1 0 -1
scan w/initial a f\v a f\v 3-\1 1 1 2 1 0
@joinr
joinr / shim.clj
Last active June 20, 2019 22:42
example of a main shim namespace for clojure to avoid AOT'ing everything and allow fast starts
;;Shim class for running app without
;;aot compilation issues.
;;entrypoint for some gui.
(ns blah.main
(:gen-class :main true))
;;This is the main entry point for the app.
;;It's a good example of a shim-class, and
;;requires some arcane features to get things
;;working to avoid aot compilation of dependent
@ghadishayban
ghadishayban / retry.clj
Last active May 1, 2019 21:41
retry with completablefuture
(ns retry
(:import [java.util.function Supplier]
[java.util.concurrent CompletableFuture TimeUnit]))
(defn with-retry
"given an op wanting retries, and a strategy for backoff,
returns a CompletableFuture that can be waited on
op takes no args
A backoff strategy is a function of an exception, returning nil or a number of milliseconds to backoff"
;; differences from scheme unfold
;; even initial value is lazy
;; predicate sense reversed
;; internal state == produced value, no special mapper-fn
;; no tail-gen
(defn series
"Produces a sequence of values.
`f` is a function that given a value, returns the next value.
`continue?` is a predicate that determines whether to produce
@hcs42
hcs42 / rpc
Created July 8, 2016 15:19
A script to evaluate an expression on an Erlang node
#!/usr/bin/env escript
%%! -name rpc@127.0.0.1
%% rpc is a script that connects to the given Erlang node using RPC and
%% evaluates an expression in it.
%%
%% Examples:
%%
%% rpc mynode@127.0.0.1 mycookie 'erlang:whereis(init)'
%% rpc mynode@127.0.0.1 mycookie erlang whereis '[init]'
(ns background
(:require [clojure.tools.logging :as log])
(:import [java.util.concurrent]))
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool)))
(defn background
"Calls the fn passed in a thread from a thread pool, returning immediately.
Unlike future, background does not swallow exceptions."
[f]
@bhauman
bhauman / core.cljs
Last active August 16, 2022 12:08
Helpful patterns when developing with ClojureScript Figwheel and Express js
(ns todo-server.core
(:require
[cljs.nodejs :as nodejs]
[figwheel.client :as fw]))
(nodejs/enable-util-print!)
(defonce express (nodejs/require "express"))
(defonce serve-static (nodejs/require "serve-static"))
(defonce http (nodejs/require "http"))
@gizmaa
gizmaa / Plot_Examples.md
Last active June 10, 2024 02:44
Various Julia plotting examples using PyPlot
@stuartsierra
stuartsierra / spellcheck.clj
Created July 9, 2013 01:47
Example implementation of Norvig's Spellchecker in Clojure, using core.async
;; Example implementation of Norvig's Spellchecker in Clojure,
;; using core.async
;;
;; There are probably some bugs in this.
;;
;; Original problem: https://github.com/ericnormand/spelling-jam
;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/
;;
;; Clojure core.async introduction:
;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
@pere
pere / datapublishers.json
Created June 28, 2012 17:10
Geographic d3.js bubbles
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.