Skip to content

Instantly share code, notes, and snippets.

Avatar

Yehonathan Sharvit viebel

View GitHub Profile
View clojure_spec_missing_piece.clj
;; 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 Dec 6, 2016
Org-mode + KLIPSE to demo Clojure code
View gist:5f9a952208cf8d35220a41a8ff857faa
#+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.
View drunken-walk.clj
(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 Aug 8, 2017
A Schema for ClojureScript Options
View compiler-options-schema.clj
(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 Mar 16, 2016
Use web workers to limit the amount of time that an eval can run.
View limitEval.js
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 Jun 18, 2016
protocol implementation in cljs
View 00-input.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 Aug 7, 2020
Easily setup an Android development environment on a Mac
View android_instructions.md

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)"
View gist:4136116
;; 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))
You can’t perform that action at this time.