Skip to content

Instantly share code, notes, and snippets.

View roblevintennis's full-sized avatar

Rob Levin roblevintennis

View GitHub Profile
@andrew8088
andrew8088 / stringify.js
Last active August 23, 2022 07:54
A simple implementation of JSON.stringify; covers every case I could think of
function stringify(obj) {
if (typeof obj !== 'object' || obj === null || obj instanceof Array) {
return value(obj);
}
return '{' + Object.keys(obj).map(function (k) {
return (typeof obj[k] === 'function') ? null : '"' + k + '":' + value(obj[k]);
}).filter(function (i) { return i; }) + '}';
}
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@scmx
scmx / using-details-summary-github.md
Last active April 25, 2024 09:30
Using <details> <summary> expandable content on GitHub with Markdown #details #summary #markdown #gfm #html

How to use <details> <summary> expandable content on GitHub with Markdown

Firstly, what is <details> <summary>?

The HTML Details Element (<details>) creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label can be provided using the <summary> element. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details.

Example

@yapalenov
yapalenov / Pagination.ts
Last active February 1, 2022 15:06
Create pagination buttons array
class Pagination {
private readonly page: number;
private readonly pagesCount: number;
private readonly delta: number;
constructor(page: number, pagesCount: number) {
this.page = page;
this.pagesCount = pagesCount;
this.delta = 2;
}