Skip to content

Instantly share code, notes, and snippets.

Torgeir Thoresen torgeir

Block or report user

Report or block torgeir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yelouafi
yelouafi / algebraic-effects-series-4.md
Last active Nov 13, 2019
Implementing Algebraic Effects and Handlers
View algebraic-effects-series-4.md

Algebraic Effects in JavaScript part 4 - Implementing Algebraic Effects and Handlers

This is the final part of a series about Algebraic Effects and Handlers.

So we've come to the core topic. The reality is that we've already covered most of it in the previous parts. Especially, in the third part, where we saw delimited continuations at work.

@yelouafi
yelouafi / multishot-callcc.js
Created Sep 21, 2018
multi shot continuations
View multishot-callcc.js
function isGenerator(x) {
return x != null && typeof x.next === "function"
}
function isFrame(x) {
return x != null && x._type_ === 'call_frame'
}
function call(genFunc, ...args) {
View Infrastructure.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
View flow-intro.md

Table of Contents

  1. Basic syntax
  2. Flow Examples
  3. Advanced features
  4. Using with existing libraries (flow-typed and libdefs)
  5. Tooling
  6. Try

1. Basics

@jstepien
jstepien / reduce-and-gc.clj
Last active Mar 6, 2017
reduce-and-gc.clj
View reduce-and-gc.clj
;; Let's experiment with Clojure 1.8.0 running with a relatively small heap
;; of 10MB. To avoid any extra dependencies, we'll start it as follows:
;;
;; java -Xmx10m -jar clojure-1.8.0.jar
;;
;; Copy following expressions into your REPL one by one.
;;
;; Let's take a small number, for instance one million.
(def small-num (* 1000 1000))
@torgeir
torgeir / clipboard-utils.clj
Last active Mar 1, 2017 — forked from Folcon/clipboard-utils.clj
Just a quick clipboard slip/slurp I put together because I didn't find anything similar, don't know if it's useful for anyone but found it invaluable when getting large strings being returned from the repl and sticking the result in an editor for more car
View clipboard-utils.clj
(defn get-clipboard []
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit)))
(defn slurp-clipboard []
(if-let [contents (.getContents (get-clipboard) nil)]
(.getTransferData contents java.awt.datatransfer.DataFlavor/stringFlavor)))
(defn spit-clipboard [text]
(.setContents (get-clipboard) (java.awt.datatransfer.StringSelection. text) nil))
@smat
smat / Luke1.kt
Last active Dec 9, 2016
Julekalender 2016
View Luke1.kt
import java.lang.Math.floor
import java.lang.Math.log10
import java.util.stream.Stream
fun main(args: Array<String>) {
Stream.iterate(6, { it + 10 } )
.filter { swapFirstAndLastDigit(it) == 4 * it }
.findFirst()
.map { println(it) }
}
View letsencrypt.md

Let's Encrypt with nginx + auto renewal

Let's Encrypt is a new, free, automated, and open Certificate Authority.

Find out more out Let's Encrypt, and how you can use in the Let's Encrypt documentation.

This file will guide you through the minimum things you need to set up Let's Encrypt on your nginx webserver.

View Tutorial.fsx
// This sample will guide you through elements of the F# language.
//
// *******************************************************************************************************
// To execute the code in F# Interactive, highlight a section of code and press Alt-Enter or right-click
// and select "Execute in Interactive". You can open the F# Interactive Window from the "View" menu.
// *******************************************************************************************************
//
// For more about F#, see:
// http://fsharp.org
//
@gaearon
gaearon / slim-redux.js
Last active Nov 15, 2019
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
View slim-redux.js
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
You can’t perform that action at this time.