Skip to content

Instantly share code, notes, and snippets.

@pithyless
pithyless / i18n-impl.cljs
Last active June 24, 2021 09:49 — forked from isaksky/i18n-impl.cljs
Handling translations in ClojureScript
(ns front.utilities.i18n-impl
(:require [front.i18n]))
(defn build-domain-index [text-vec]
(let [by-msgid (atom (transient {}))
by-msg (atom (transient {}))]
(doseq [{:keys [s_message s_message_id] :as text} text-vec]
(when-not (clojure.string/blank? s_message_id)
(swap! by-msgid assoc! s_message_id text))
(when-not (clojure.string/blank? s_message)
@pithyless
pithyless / ken-burns.css
Created February 18, 2012 22:56 — forked from thierryk/ken-burns.css
Ken Burns effect (styling images with panning and zooming effects)
/**
* See: http://www.css-101.org/articles/ken-burns_effect/css-transition.php
*/
/**
* Styling the container (the wrapper)
*
* position is used to make this box a containing block (it becomes a reference for its absolutely positioned children). overflow will hide part of the images moving outside of the box.
*/
@pithyless
pithyless / quality.rake
Created January 1, 2012 13:14 — forked from steveklabnik/quality.rake
My new favorite Rake task
require 'flog'
require 'flog_task'
require 'flay'
require 'flay_task'
require 'roodi'
require 'roodi_task'
FlogTask.new :flog, SOME_NUMBER_HERE, %w[app lib]
FlayTask.new :flay, OTHER_NUMBER_HERE, %w[app lib]
RoodiTask.new 'roodi', ['app/**/*.rb', 'lib/**/*.rb']
@pithyless
pithyless / datomic-mysql-bootstrap.sql
Created April 3, 2018 15:50 — forked from favila/datomic-mysql-bootstrap.sql
Better MySQL bootstrap setup for datomic's datomic_kvs table
-- 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
(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 / 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
@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 / 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 / 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