Skip to content

Instantly share code, notes, and snippets.

View viebel's full-sized avatar

Yehonathan Sharvit viebel

View GitHub Profile
@stuarthalloway
stuarthalloway / clojure_spec_missing_piece.clj
Created March 17, 2017 01:11
Clojure spec's missing piece
;; clojure.spec's missing piece, work in progress
;; this is only halfway done, somebody else will need to do the other 95%
(require
'[clojure.spec :as s]
'[clojure.spec.test :as test])
(defn naive-english-explain
"Copy and paste this into your app. Figure out what it does by
trying it in production."
@bzg
bzg / gist:5f9a952208cf8d35220a41a8ff857faa
Created December 6, 2016 18:09
Org-mode + KLIPSE to demo Clojure code
#+html_head_extra: <link rel="stylesheet" type="text/css" href="https://storage.googleapis.com/app.klipse.tech/css/codemirror.css" />
Some Clojure code:
#+BEGIN_SRC clojure
(map inc '(1 2 3))
#+END_SRC
That's it.
(defn neighbors
([size yx] (neighbors [[0 0] [1 1] [-1 -1] [-1 1] [1 -1] [-1 0] [1 0] [0 -1] [0 1]] size yx))
([deltas size yx]
(filter (fn [new-yx]
(every? #(< -1 % size) new-yx))
(map #(vec (map + yx %))
deltas))))
(defn density [matrix y x]
(let [neighbors (map #(get-in matrix %) (neighbors (count matrix) [y x]))
@bhauman
bhauman / compiler-options-schema.clj
Last active August 8, 2017 21:19
A Schema for ClojureScript Options
(ns cljs.compiler-options-schema
(:require
[clojure.spec :as s]
[clojure.string :as string]
;; for initial dev
[clojure.test :refer [deftest is testing]]))
(defn non-blank-string? [x] (and (string? x) (not (string/blank? x))))
(defonce ^:private registry-ref (atom {}))
@westc
westc / limitEval.js
Created March 16, 2016 22:08
Use web workers to limit the amount of time that an eval can run.
function limitEval(code, fnOnStop, opt_timeoutInMS) {
var id = Math.random() + 1,
blob = new Blob(
['onmessage=function(a){a=a.data;postMessage({i:a.i+1});postMessage({r:eval.call(this,a.c),i:a.i})};'],
{ type:'text/javascript' }
),
myWorker = new Worker(URL.createObjectURL(blob));
function onDone() {
URL.revokeObjectURL(blob);
@shaunlebron
shaunlebron / 00-input.cljs
Last active June 18, 2016 16:37
protocol implementation in cljs
;; dummy protocol
(defprotocol IFoo
(foo [this]))
;; dummy cljs type
(deftype Bar [])
;; extending a cljs type
(extend-type Bar
IFoo (foo [this] (println "Hello from IFoo.foo for Bar")))
@patrickhammond
patrickhammond / android_instructions.md
Last active March 29, 2024 20:14
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

@halgari
halgari / gist:4136116
Created November 23, 2012 15:26 — forked from AlexBaranosky/gist:4134522
doseq-indexed
;; Example:
;; (doseq-indexed idx [name names]
;; (println (str idx ". " name)
(defmacro doseq-indexed-functional [index-sym [item-sym coll] & body]
`(doseq [[~item-sym ~index-sym]
(map vector ~coll (range))]
~@body))