Skip to content

Instantly share code, notes, and snippets.

View priyatam's full-sized avatar

Priyatam Mudi priyatam

View GitHub Profile
@elben
elben / understanding-transducers.clj
Last active February 14, 2021 10:55
Understanding Transducers. See README below.
(ns my-transducers.core
(:require [clojure.core.async :as async]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Understanding Transducers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This is the source code for the blog post Understanding Transducers, found
;; here: http://elbenshira.com/blog/understanding-transducers
;;
@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).
@sander
sander / index.html
Created August 10, 2014 23:54
p5.js in ClojureScript
<!doctype html>
<style>body { padding: 0; }</style>
<script src='https://cdn.jsdelivr.net/p5.js/0.3.2/p5.min.js'></script>
<script src='out/goog/base.js'></script>
<script src='myproject.js'></script>
<script>goog.require('myproject.core')</script>
(require '[schema.core :as s])
(require '[schema.coerce :as coerce])
(require '[schema.utils :as utils])
(defn filter-schema-keys
[m schema-keys extra-keys-walker]
(reduce-kv (fn [m k v]
(if (or (contains? schema-keys k)
(and extra-keys-walker
(not (utils/error? (extra-keys-walker k)))))
// JVM sizing options
-server -Xms40g -Xmx40g -XX:MaxDirectMemorySize=4096m -XX:PermSize=256m -XX:MaxPermSize=256m
// Young generation options
-XX:NewSize=6g -XX:MaxNewSize=6g -XX:+UseParNewGC -XX:MaxTenuringThreshold=2 -XX:SurvivorRatio=8 -XX:+UnlockDiagnosticVMOptions -XX:ParGCCardsPerStrideChunk=32768
// Old generation options
-XX:+UseConcMarkSweepGC -XX:CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -XX:+CMSClassUnloadingEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseCMSInitiatingOccupancyOnly
// Other options
-XX:+AlwaysPreTouch -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:-OmitStackTraceInFastThrow
(scss->clj "/Users/noprompt/git/yui/pure/src/grids/css/grids-core.css"
'pure.grids)
;; =>
((ns
pure.grids
(:require [garden.stylesheet] [garden.units] [garden.def]))
(garden.def/defstyles
grids
[".pure-g"
{:letter-spacing "-0.31em"}
@ftrain
ftrain / rhymes.clj
Last active July 14, 2023 22:20
Annotated rhyming dictionary
;; This is at: https://gist.github.com/8655399
;; So we want a rhyming dictionary in Clojure. Jack Rusher put up
;; this code here:
;;
;; https://gist.github.com/jackrusher/8640437
;;
;; I'm going to study this code and learn as I go.
;;
;; First I put it in a namespace.
@jrslepak
jrslepak / inference.rkt
Last active May 24, 2017 19:04
Type inference in Typed Racket
#lang typed/racket
;;; Typed Racket version of Martin Grabmü̈ller's "Algorithm W Step by Step"
;;; http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.65.7733
;;; This is my first use of Typed Racket. I am looking to change this from
;;; following Haskell idiom to following Racket idiom.
;; An expression is a variable, a literal, an application,
@pangloss
pangloss / xn.test.cljs
Last active January 23, 2020 05:45
ClojureScript XHR with core.async.
(ns xn.test
(:require-macros [cljs.core.async.macros :refer [go alts!]]
(:require [xn.core :as xn]
[xn.util :as u]
[cljs.core.async :refer [<! take!]]
[xn.xhr :refer [request-body request-records chain-req]]))
(def sample-app
(reify
xn/Application
@Chouser
Chouser / externs_for_cljs.clj
Created June 17, 2013 13:44
Generate an externs.js file for arbitrary JS libraries for use in advanced Google Closure compilation, based on the ClojureScript code that uses the libraries.
(ns n01se.externs-for-cljs
(:require [clojure.java.io :as io]
[cljs.compiler :as comp]
[cljs.analyzer :as ana]))
(defn read-file [file]
(let [eof (Object.)]
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
(vec (take-while #(not= % eof)
(repeatedly #(read stream false eof)))))))