This file contains 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
from django.core.exceptions import ValidationError | |
from django.db.models import Field, CharField | |
__all__ = ['MultiColumnField'] | |
try: | |
from hashlib import md5 | |
except ImportError: | |
from md5 import new as md5 |
This file contains 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
// Clean up all those invasive and ugly utm_ parameters, so you can paste a url. | |
// (will reload the page, be warned) | |
(function(){ | |
var qs = window.location.search.slice(1).split('&'), | |
newqs = []; | |
for (var i = 0; i < qs.length; i++) { | |
if (qs[i].slice(0,4)!='utm_') { | |
newqs.push(qs[i]); | |
} | |
} |
This file contains 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
(def views | |
{:some-view SomeView | |
:another-view AnotherView}) | |
(def factories | |
(map om/factory (vals views))) | |
(defui Router | |
static om/Ident | |
(ident [this {:keys [route]}] |
This file contains 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
(defmacro defspec-test | |
([name sym-or-syms] `(defspec-test ~name ~sym-or-syms nil)) | |
([name sym-or-syms opts] | |
(when t/*load-tests* | |
`(def ~(vary-meta name assoc :test `(fn [] | |
(let [check-results# (clojure.spec.test/check ~sym-or-syms ~opts) | |
checks-passed?# (every? nil? (map :failure check-results#))] | |
(if checks-passed?# | |
(t/do-report {:type :pass | |
:message (str "Generative tests pass for " |
This file contains 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 utils.re-frame | |
(:require [cljs.compiler :as cljsc])) | |
(defn- anonymous-function-declaration? [form] | |
(and (list? form) | |
(= 'fn (first form)) | |
(vector? (second form)))) | |
(defn- query-id->js-fn-name [query-id] | |
(let [ns-part (when-let [ns-part (namespace query-id)] |
This file contains 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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains 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
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "AWS CloudFormation sample template that contains a single Lambda function behind an API Gateway", | |
"Resources": { | |
"GreetingLambda": { | |
"Type": "AWS::Lambda::Function", | |
"Properties": { |
This file contains 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 error-boundary.error-boundary | |
(:require [reagent.core :as r] | |
[reagent.impl.component :as comp] | |
[reagent.impl.util :as util] | |
[goog.object :as gobj])) | |
;; (c) 2016 Paulus Esterhazy | |
;; | |
;; License: MIT |
This file contains 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
(defn contextual-eval [ctx expr] | |
(eval | |
`(let [~@(mapcat (fn [[k v]] [k `'~v]) ctx)] | |
~expr))) | |
(defmacro local-context [] | |
(let [symbols (keys &env)] | |
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols))) | |
(defn readr [prompt exit-code] | |
(let [input (clojure.main/repl-read prompt exit-code)] | |
(if (= input ::tl) |
This file contains 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
(defn base64-decode | |
"Utility function over the Java 8 base64 decoder" | |
[to-decode] | |
(String. (.decode (Base64/getDecoder) ^String to-decode))) | |
(defn string->edn | |
"Parse JSON from a string returning an edn map, otherwise nil" | |
[string] | |
(when-let [edn (json/decode string true)] | |
(when (map? edn) |
OlderNewer