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 / todo
Created December 16, 2014 12:44
Reagent quickstart
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 12:57
Helper to check for N+1 queries in rspec
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
@pithyless
pithyless / spec_helper.rb
Last active August 29, 2015 13:58
Every time I'm copy+pasting some spec_helper.rb basics.
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.order = "random"
config.fail_fast = true
config.filter_run :focus
config.filter_run_including :focused => true
config.run_all_when_everything_filtered = true
config.alias_example_to :fit, :focused => true
@pithyless
pithyless / integer.rb
Created March 24, 2014 10:50
Ruby Integer::MAX and Integer::MIN
class Integer
N_BYTES = [42].pack('i').size
N_BITS = N_BYTES * 16
MAX = 2 ** (N_BITS - 2) - 1
MIN = -MAX - 1
end
p Integer::MAX #=> 4611686018427387903
p Integer::MAX.class #=> Fixnum
p (Integer::MAX + 1).class #=> Bignum
@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 / equalable.rb
Created April 12, 2013 18:56
Equalable ruby mixin.
module Equalable
def ==(o)
o.class == self.class && o.equality_state == equality_state
end
alias_method :eql?, :==
def hash
equality_state.hash
end
end
@pithyless
pithyless / Gemfile
Created November 12, 2012 14:52
Configuration required to setup newrelic-moped
group :production, :acceptance do
gem 'rpm_contrib'
gem 'newrelic-moped' # https://github.com/joinwire/newrelic-moped
gem 'newrelic_rpm'
end
@pithyless
pithyless / char_converter.rb
Created September 5, 2012 16:00
Rails middleware to encode characters and avoid exploding controllers
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
SANITIZE_ENV_KEYS = [
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225
"HTTP_REFERER",
"PATH_INFO",
@pithyless
pithyless / gist:3428884
Created August 22, 2012 20:06
OSX Mountain Lion - Install Notes
# Don't write to Disk on Sleep
sudo pmset -a hibernatemode 0
# Install Developer Tools (no XCode)
# https://developer.apple.com/downloads/index.action#
# Install DropBox
# Install 1Password
# Install Homebrew