This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local C = terralib.includecstring [[ | |
#include <stdio.h> | |
]] | |
function makeAdder(x) | |
print("makeAdder(" .. x .. ")") | |
return terra(y : int) | |
return x + y | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Base | |
{ | |
public virtual string Method() | |
{ | |
return "base method"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; manual | |
(def fuel (atom 10)) | |
(loop [] | |
(when (zero? (swap! fuel dec)) | |
(fail "out of fuel!")) | |
(recur)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Handlers. | |
;; Approximates effect handlers without unwinding the stack. | |
;; Captures thread bindings so as to avoid "open recursion" between handlers. | |
;; Also binds `super` to bubble effect up to the next handler. | |
(def ^:dynamic super) | |
(defn bind-handler [var f] | |
(let [bindings (assoc (get-thread-bindings) #'super @var)] | |
(fn [& args] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Signal<T> { | |
private _promise: Promise<T>; | |
private _resolve: (x: T) => void; | |
constructor() { | |
this._makePromise(); | |
} | |
_makePromise() { | |
this._promise = new Promise((resolve, reject) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Base = { | |
x: number, | |
}; | |
type Derived = Base & { | |
y: number, | |
}; | |
let to = <T>(x: T): T => x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let steps = [[0, t => t * 2], [0.5, t => t * 5]]; | |
let x; | |
for (let i = 0; i < steps.length; i++) { | |
let [k, f] = steps[i]; | |
if (k <= t) { | |
x = f(t); | |
break; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Step 1) Produce a build with :advanced optimizations. Tell me the size of the .js file. | |
;; Step 2) Run `gzip` on your output .js file and tell me the size of the .js.gz file. | |
;; Step 3) Apply this monkey patch: | |
(in-ns 'cljs.closure) | |
(import '[com.google.javascript.jscomp VariableRenamingPolicy PropertyRenamingPolicy]) | |
(def wrapped-set-options set-options) | |
(defn set-options [opts ^CompilerOptions compiler-options] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns blah | |
(:require [com.walmartlabs.lacinia.schema :as schema] | |
[com.walmartlabs.lacinia.util :refer [attach-resolvers]] | |
[com.walmartlabs.lacinia :as lacinia])) | |
(defn batch [ctx id] | |
(prn 'batch id) | |
(swap! (::loader ctx) | |
(fn [loader] | |
(if (contains? (:cache loader) id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mvt | |
// See https://www.mapbox.com/vector-tiles/specification/ | |
// and https://github.com/mapbox/vector-tile-spec/tree/master/2.1 | |
// Zero value is ready to use. | |
type GeomBuffer struct { | |
geom []uint32 | |
begun bool // True if a command sequence has begun. | |
start int // Index of the command header. | |
count uint32 // Number of commands written so far in this sequence. |