Skip to content

Instantly share code, notes, and snippets.

View jhyland87's full-sized avatar

J jhyland87

View GitHub Profile
@MrChocolatine
MrChocolatine / TS - More precise return type method Date#toISOString.d.ts
Last active June 3, 2025 07:09
TypeScript – How to accurately type dates in ISO 8601 format
// In TS, interfaces are "open" and can be extended
interface Date {
/**
* Give a more precise return type to the method `toISOString()`:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
*/
toISOString(): TDateISO;
}
type TYear = `${number}${number}${number}${number}`;
@av01d
av01d / ColorSteps.js
Last active February 27, 2024 15:42
Javascript calculate color steps (gradient) between two colors
const ColorSteps = (() => {
/**
* Convert any color string to an [r,g,b,a] array.
* @author Arjan Haverkamp (arjan-at-avoid-dot-org)
* @param {string} color Any color. F.e.: 'red', '#f0f', '#ff00ff', 'rgb(x,y,x)', 'rgba(r,g,b,a)', 'hsl(180, 50%, 50%)'
* @returns {array} [r,g,b,a] array. Caution: returns [0,0,0,0] for invalid color.
* @see https://gist.github.com/av01d/8f068dd43447b475dec4aad0a6107288
*/
const colorValues = color => {
@MrChocolatine
MrChocolatine / TS – Collection of utility types.d.ts
Last active May 10, 2025 03:45 — forked from ClickerMonkey/types.ts
TypeScript – Collection of utility types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@vladbabii
vladbabii / klipper_printer_gcode_incremental_macro.cfg
Created December 8, 2019 13:57
klipper printer gcode incremental macro
#
# set start/end with gcode:
#
# SET_GCODE_VARIABLE MACRO=incremental_settings VARIABLE=start VALUE=2
# SET_GCODE_VARIABLE MACRO=incremental_settings VARIABLE=now VALUE=2
# SET_GCODE_VARIABLE MACRO=incremental_settings VARIABLE=end VALUE=5
#
# if you set now on each toolchange, if it runs out, the next tool will be used
#
# then run gcode:
@yassineaboukir
yassineaboukir / List of API endpoints & objects
Last active June 17, 2025 18:56
A list of 3203 common API endpoints and objects designed for fuzzing.
0
00
01
02
03
1
1.0
10
100
1000
@scokmen
scokmen / HttpStatusCode.ts
Created April 25, 2017 11:10
Typescript Http Status Codes Enum
"use strict";
/**
* Hypertext Transfer Protocol (HTTP) response status codes.
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
*/
enum HttpStatusCode {
/**
* The server has received the request headers and the client should proceed to send the request body