Skip to content

Instantly share code, notes, and snippets.

;;; 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 / core.cljs
Last active August 29, 2015 14:20 — forked from luxbock/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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@pithyless
pithyless / template.html
Created January 1, 2012 13:14 — forked from steveklabnik/template.html
I always end up typing out the minimal (for me) html5 stuff. so here it is.
<!doctype html >
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<nav></nav>
</body>
</html>
@pithyless
pithyless / after.rb
Created January 1, 2012 13:17 — forked from steveklabnik/after.rb
dont load rails!
require 'active_record'
require "#{Rails.root}/app/models/user"
describe User do
it "does something sweet"
it "does something cool"
end
@pithyless
pithyless / group_of_thingies.rb
Created February 8, 2012 08:40 — forked from Peeja/group_of_thingies.rb
Test a block in Ruby
class GroupOfThingies
attr_accessor :thingies
# Use like this:
#
# group_of_thingies = GroupOfThingies.new
# group_of_thingies.each do |thing|
# puts "Check out this awesome thing: #{thing}!"
# end
#
@pithyless
pithyless / match_method.rb
Created February 8, 2012 08:37 — forked from avdi/match_method.rb
Defining method_missing and respond_to? in one fell swoop
# Do you ever define #method_missing and forget #respond_to? I sure
# do. It would be nice if we could do them both at the same time.
module MatchMethodMacros
def match_method(matcher, &method_body)
mod = Module.new do
define_method(:method_missing) do |method_name, *args|
if matcher === method_name.to_s
instance_exec(method_name, *args, &method_body)
else
@pithyless
pithyless / algorithm.txt
Last active December 29, 2015 00:58 — forked from adamkal/parser.py
0123 0123 0123 0123 0123 0123 0123 0123 0123 0123
1 1 _ 1 _ 1 1 _ 1 _ 1 _ 1 _ 1 _ 1 _
2 | 2 _| 2 _| 2|_| 2|_ 2|_ 2 | 2|_| 2|_| 2| |
3 | 3|_ 3 _| 3 | 3 _| 3|_| 3 | 3|_| 3 _| 3|_|
000101100
+4 +7 -5 +6
0 - 2 4 6789
@pithyless
pithyless / latency.markdown
Created April 6, 2016 10:12 — forked from iaintshine/latency.markdown
Latency numbers every programmer should know

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

@pithyless
pithyless / mac-homebrew-pyexiv2.sh
Created January 22, 2012 17:19 — forked from jpwatts/mac-homebrew-pyexiv2.sh
In which I finally get pyexiv2 working on my Mac using Homebrew and a series of disgusting hacks
#!/bin/sh
brew install python scons boost exiv2
curl -O http://launchpadlibrarian.net/83595798/pyexiv2-0.3.2.tar.bz2
tar xjvf pyexiv2-0.3.2.tar.bz2
cd pyexiv2-0.3.2
# https://answers.launchpad.net/pyexiv2/+question/140742
echo "env['FRAMEWORKS'] += ['Python']" >> src/SConscript
(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]