Skip to content

Instantly share code, notes, and snippets.

Norbert Wójtowicz pithyless

Block or report user

Report or block pithyless

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
@pithyless
pithyless / README.md
Last active Apr 6, 2018
Pedestal sync vs async error-handling
View README.md

I expected the async error to be handled by the error-handler interceptor (i.e. [OK] Handling error.).

❯ clj -m dev

Do some work...
[OK] Got a response.
{:async :ok, :sync :ok}
@pithyless
pithyless / datomic-mysql-bootstrap.sql
Created Apr 3, 2018 — forked from favila/datomic-mysql-bootstrap.sql
Better MySQL bootstrap setup for datomic's datomic_kvs table
View datomic-mysql-bootstrap.sql
-- Optimized MYSQL schema for datomic
-- Unfortunately the bin/sql/mysql-*.sql bootstrapping files for datomic are not
-- very good, and can actually cause failures if not adjusted.
-- One symptom of this is the following error:
-- SQL Error (1071): Specified key was too long; max key length is 767 bytes.
-- Reported here: https://support.cognitect.com/entries/28462168-MySQL-Caveats
-- This is caused by the default collation for the `id` column possibly being
View background.clj
(ns background
(:require [clojure.tools.logging :as log])
(:import [java.util.concurrent]))
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool)))
(defn background
"Calls the fn passed in a thread from a thread pool, returning immediately.
Unlike future, background does not swallow exceptions."
[f]
@pithyless
pithyless / doctest.clj
Created Jan 4, 2018
Test executable docstrings à la Python's doctest.
View doctest.clj
(ns sursolid.fribble.doctest
"Test executable docstrings à la Python's doctest.
Inspired by Python's doctest, this namespace provides tools to
turn your regular docstrings into REPL sessions that will be
run and checked via your regular testing suite.
## Formatting the docstring
@pithyless
pithyless / doo-bug.md
Last active Nov 11, 2016
CLJS lein-doo not flushing correctly?
View doo-bug.md

Running lein node test once (but also happens in auto watch-mode).

10 items map - OK

(deftest foo-test
  (is (= 'foo
         (reduce #(assoc %1 %2 inc) {} (range 10)))))
@pithyless
pithyless / latency.markdown
Created Apr 6, 2016 — forked from iaintshine/latency.markdown
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs
View core.cljs
(ns freactive-datascript.core
(:require [datascript :as d]
[datascript.core :as dc]
[clojure.data :as data]
[freactive.core :as f :refer [IReactive
*invalidate-rx*
*trace-capture*]]))
;;; Playground ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
View reagent_datascript2.cljs
;;; Use experimental fork of DataScript from https://github.com/allgress/datascript to handle undo and per-query subscriptions
(ns reagent-test.core
(:require [reagent.core :as reagent :refer [atom]]
[datascript :as d]
[cljs-uuid-utils :as uuid]))
(enable-console-print!)
(defn bind
([conn q]
@pithyless
pithyless / todo
Created Dec 16, 2014
Reagent quickstart
View todo
1. Get lein
lein - http://leiningen.org/
2. `lein new reagent <awesome-project>`
3. Some changes to project.clj from last night's talk:
:dependencies [[org.clojure/clojure "1.7.0-alpha4"]
[org.clojure/clojurescript "0.0-2371"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[reagent "0.4.3"]
@pithyless
pithyless / check_for_n1_queries.rb
Last active May 5, 2016
Helper to check for N+1 queries in rspec
View check_for_n1_queries.rb
require 'method_struct'
class CheckForN1Queries < MethodStruct.new(:generator, :operation, :debug)
IGNORED_SQL = [
/^SHOW/, /^EXPLAIN/, /^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/,
/^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/,
/^RELEASE SAVEPOINT/, /^SHOW max_identifier_length/
]
def call
You can’t perform that action at this time.