Skip to content

Instantly share code, notes, and snippets.

const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer std.debug.assert(gpa.deinit());
const allocator = &gpa.allocator;
const num_threads = std.math.max(1, (std.Thread.getCpuCount() catch 1) / 2);
const epolls = try allocator.alloc(std.os.fd_t, num_threads);
defer allocator.free(epolls);
@ptaoussanis
ptaoussanis / transducers.clj
Last active December 17, 2021 13:54
Quick recap/commentary: Clojure transducers
(comment ; Fun with transducers, v2
;; Still haven't found a brief + approachable overview of Clojure 1.7's new
;; transducers in the particular way I would have preferred myself - so here goes:
;;;; Definitions
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as:
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation
;; (The `[]` arity is actually optional; it's only used when calling
;; `reduce` w/o an init-accumulator).
@philandstuff
philandstuff / euroclojure2014.org
Last active February 19, 2024 05:12
Euroclojure 2014

EuroClojure 2014, Krakow

Fergal Byrne, Clortex: Machine Intelligence based on Jeff Hawkins’ HTM Theory

  • @fergbyrne
  • HTM = Hierarchical Temporal Memory
  • Slides

big data

  • big data is like teenage sex
    • noone knows how to do it
    • everyone thinks everyone else is doing it
@bmabey
bmabey / challenge.clj
Last active August 29, 2015 13:57
async challenge from Philipp Haller's presenation http://www.infoq.com/presentations/rx-async using clojure's core.async
(ns challenge
" via http://www.infoq.com/presentations/rx-async
Two input streams with the following values:
stream1: 7, 1, 0, 2, 3, 1, ...
stream2: 0, 7, 0, 4, 6, 5, ...
Task:
Create a new output stream that
• yields, for each value of stream1, the sum of the previous 3
• values of stream1,except if the sum is greater than some threshold in
which case the next value of stream2 should be subtracted.
;;;; Super top secret talk stuff nobody should ever see. Shhh.
(in-ns 'user)
(defmacro bench [& body]
`((re-find #"\"(.*)\"" (with-out-str (time (do ~@body)))) 1))
*ns*
(require 'clojure.walk)
@teropa
teropa / resources.md
Last active December 4, 2020 05:42
Clojure Resources

Tutorials