Skip to content

Instantly share code, notes, and snippets.

@Peeja
Peeja / rerender.cljs
Created September 9, 2016 23:00
What it appears to take to re-render the React tree when Figwheel reloads.
;; Re-render when Figwheel reloads.
(gevents/listen js/document.body
"figwheel.js-reload"
(fn []
(let [root-component (om-next/app-root (compassus/get-reconciler a))]
(letfn [(js-vals [o]
(map #(aget o %) (js-keys o)))
;; Finds the children of a React internal instance of a component.
;; That could be a single _renderedComponent or several
;; _renderedChildren.
@michiel
michiel / transducer-rxjs-ramda.js
Created February 22, 2016 15:52
transducer in es6 with ramda and rxjs
const Rx = require('rx');
const R = require('ramda');
const seq = Rx.Observable.range(1, 10);
const isEven = (x) => x % 2 === 0;
const add1 = (x) => x + 1;
const transducer = R.compose(
R.map(add1),
@clohr
clohr / transducer.js
Last active April 4, 2016 05:22
Transducers with Ramda and RxJS
var Rx = require('rx');
var R = require('ramda');
var seq = Rx.Observable.range(1, 10);
var isEven = function isEven(x) { return x % 2 === 0; };
var add1 = function add1(x) { return x + 1; };
var transducer = R.compose(R.map(add1), R.filter(isEven));
var source = seq.transduce(transducer);
@MoOx
MoOx / .travis.yml
Last active May 12, 2016 01:16
Run tap/tape tests using saucelabs
language: node_js
node_js:
- iojs
env:
global:
# https://docs.saucelabs.com/ci-integrations/travis-ci/
# SAUCE_USERNAME
- secure: Daa...
@justinclayton
justinclayton / add-dns-record.sh
Created July 15, 2015 22:04
CLI to add DNS Records in Route53
#!/bin/bash -eo pipefail
## Allows for creation of "Basic" DNS records in a Route53 hosted zone
function main() {
record_name=$1
record_value=$2
[[ -z $record_name ]] && echo "record_name is: $record_name" && exit 1
[[ -z $record_value ]] && echo "record_value is: $record_value" && exit 1
@taylorSando
taylorSando / datomic-rules.clj
Created June 5, 2014 01:15
Datomic recursion using rules
(defn recursive-rule
"A recursive rule for establishing prototype inheritance/isa relationship.
Can specify a maximum depth to travel, or none if there are no restrictinos.
rule The name of the rule
e The entity
a The attribute
v The value
Should be creating the rule like: (recursive-rule 'isa '?e '?a '?v)
Then within a query, can refer to it like this:
(isa ?e :thing/isa ?v) "
@jberkus
jberkus / gist:6b1bcaf7724dfc2a54f3
Last active January 7, 2024 21:26
Finding Unused Indexes
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@billmei
billmei / countries.html
Last active November 19, 2021 17:33
Option select list of countries and country codes
<select>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua and Barbuda</option>
@insin
insin / contactform.js
Last active January 9, 2024 05:27
React contact form example
/** @jsx React.DOM */
var STATES = [
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI',
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS',
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR',
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'
]
var Example = React.createClass({
(defn debounce
([c ms] (debounce (chan) c ms))
([c' c ms]
(go
(loop [start nil loc (<! c)]
(if (nil? start)
(do
(>! c' loc)
(recur (js/Date.) nil))
(let [loc (<! c)]