Skip to content

Instantly share code, notes, and snippets.

@rodneyrehm
rodneyrehm / output.html
Created August 12, 2016 09:37
markdown-it-adjust-heading-levels
<!-- { firstLevel: 3 } -->
<h3>First <em>Level</em> headline</h3>
<p>first level content</p>
<h4>Second Level headline alpha</h4>
<p>second level content alpha</p>
<h5>Third Level headline alpha</h5>
<p>third level content alpha</p>
<h4>Second Level headline bravo</h4>
<p>second level content bravo</p>
@ianaya89
ianaya89 / custom-readable-stream.js
Last active November 14, 2021 11:01
Custom readable stream with node js
/* Implementation */
var stream = require('stream');
// Create the custom stream
function Num(options) {
// Inherit properties
stream.Readable.call(this, options);
this._start = 0;
this._end = 100;
@katowulf
katowulf / 1_query_timestamp.js
Last active September 21, 2023 20:28
Get only new items from Firebase
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP)
// pros: fast and done server-side (less bandwidth, faster response), simple
// cons: a few bytes on each record for the timestamp
var ref = new Firebase(...);
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) {
console.log('new record', snap.key());
});
@conorbuck
conorbuck / angle-between-points.js
Created May 5, 2012 22:51
JavaScript: Find the angle between two points
var p1 = {
x: 20,
y: 20
};
var p2 = {
x: 40,
y: 40
};