Skip to content

Instantly share code, notes, and snippets.

View fmnoise's full-sized avatar
🇺🇦

fmnoise

🇺🇦
  • Yellowpay Inc
  • Norway
View GitHub Profile
@fmnoise
fmnoise / 00_destructuring.md
Created June 17, 2017 22:03 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

@fmnoise
fmnoise / debug.clj
Created July 22, 2017 21:40 — forked from ato/debug.clj
Simpler debug-repl that works with unmodified Clojure
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html
(defmacro local-bindings
"Produces a map of the names of local bindings to their values."
[]
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(declare *locals*)
(defn eval-with-locals
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
@fmnoise
fmnoise / unbind.js
Created December 27, 2017 11:17 — forked from cowboy/unbind.js
JavaScript: Function.prototype.unbind (for @jugglinmike)
Function.prototype.bind = (function(origBind) {
return function() {
var fn = origBind.apply(this, arguments);
fn.__origFn__ = this.__origFn__ || this;
return fn;
};
}(Function.prototype.bind));
Function.prototype.unbind = function() {
return this.__origFn__;

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@fmnoise
fmnoise / README.md
Created April 27, 2018 10:11 — forked from bhb/README.md
Clojure friendly mode, inspired by https://github.com/slipset/friendly
@fmnoise
fmnoise / README.md
Created April 27, 2018 10:11 — forked from bhb/README.md
Clojure friendly mode, inspired by https://github.com/slipset/friendly
@fmnoise
fmnoise / gist:60fe29ca74fb96b07a875bf579827249
Created June 9, 2018 18:12 — forked from terjesb/gist:4257641
iTerm2 emacs 24.2.1 -nw with paredit on OS X 10.8 Norwegian layout
iTerm2 emacs 24.2.1 -nw with paredit on OS X 10.8 Norwegian layout
Left Command is my Meta.
Left Alt used for inputting special characters.
Caps Lock is mapped to Control.
 > System Preferences > Keyboard > Keyboard > Special: Caps Lock: ^ Control
iTerm > Preferences > Keys: Left Command key mapped to Right Option
iTerm > Preferences > Profiles > Keys: Right option acts as: +Esc
@fmnoise
fmnoise / imgUrlToBase64Str.clj
Created June 27, 2018 20:03 — forked from miguelbermudez/imgUrlToBase64Str.clj
Image URL to Base64 String in Clojure
;; REPL ONLY
;; Require clj-http https://github.com/dakrone/clj-http/
(require '[clj-http.client :as client])
;; Import Apache Common's Base64 encoder/decoder
(import (org.apache.commons.codec.binary Base64))
(def test-file
;Image Credit Metropolitan Museum of Art
(client/get "http://images.metmuseum.org/CRDImages/ma/web-large/DP241865.jpg" {:as :byte-array}))
@fmnoise
fmnoise / cljs-graaljs.md
Created July 19, 2018 08:53 — forked from mfikes/cljs-graaljs.md
Try ClojureScript Graal.js

First, you need to install GraalVM and set things up so that the java installed with GraalVM is picked up in your path. See http://www.graalvm.org for more details.

With that in place, you can manage the Truffle languages installed.

Here you can see that I've already installed Python and Ruby:

$ gu list
ComponentId              Version             Component name