Skip to content

Instantly share code, notes, and snippets.

View TracyGJG's full-sized avatar

TGJ Gilmore TracyGJG

  • Somerset, UK
View GitHub Profile
@ZacharyL2
ZacharyL2 / deep-clone.js
Last active April 11, 2022 10:11
Deep copy
const deepClone = (obj, map = new WeakMap()) => {
if (obj instanceof Date) return new Date(obj);
if (obj instanceof RegExp) return new RegExp(obj);
if (map.has(obj)) {
return map.get(obj);
}
const allDesc = Object.getOwnPropertyDescriptors(obj);
const cloneObj = Object.create(Object.getPrototypeOf(obj), allDesc);
@chrisurf
chrisurf / ascii-art-characters.md
Last active November 21, 2025 10:41
ASCII art characters for creating diagrams

ASCII art characters for creating diagrams

Single line characters

ASCII code Character Description
191 Box drawing character single line upper right corner
192 Box drawing character single line lower left corner
193 Box drawing character single line horizontal and up
194 Box drawing character single line horizontal down
@bradtraversy
bradtraversy / state_capitals.json
Created April 27, 2019 12:24
JSON array of states and capitals
[
{
"abbr": "AL",
"name": "Alabama",
"capital": "Montgomery",
"lat": "32.361538",
"long": "-86.279118"
},
{
"abbr": "AK",
@fnky
fnky / ANSI.md
Last active November 23, 2025 05:36
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@NWCalvank
NWCalvank / fp.js
Created April 29, 2018 15:34
Transducers Explained | JavaScript
module.exports = {
compose,
concat,
};
function apply(x, f) {
return f(x);
}
function compose(...funcs) {

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps.

  1. What is a parser?
  2. and, what is a parser combinator?

So first question: What is parser?

@wojteklu
wojteklu / clean_code.md
Last active November 22, 2025 16:22
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@Avaq
Avaq / combinators.js
Last active November 5, 2025 22:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@paulirish
paulirish / bling.js
Last active September 13, 2025 12:13
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };