Skip to content

Instantly share code, notes, and snippets.

View nyteshade's full-sized avatar

Brielle Harrison nyteshade

View GitHub Profile
@nyteshade
nyteshade / api.js
Created January 25, 2024 21:09
Snowflake JavaScript API (Jan 25, 2024)
[
AggregateError: function {
constructor, name, message,
},
Array: function {
length, constructor, at, concat, copyWithin, fill, find, findIndex,
lastIndexOf, pop, push, reverse, shift, unshift, slice, sort, splice,
includes, indexOf, join, keys, entries, values, forEach, filter, flat,
flatMap, map, every, some, reduce, reduceRight, toLocaleString, toString,
@nyteshade
nyteshade / sgr.js
Last active October 10, 2024 06:56
Select Graphic Rendition (SGR)
/**
* Applies Select Graphic Rendition (SGR) parameters to a given message for
* styling in terminal environments. This function allows for the dynamic
* styling of text output using ANSI escape codes. It supports a variety of
* modes such as color, brightness, and text decorations like bold or underline.
*
* @param {string} message The message to be styled.
* @param {...string} useModes A series of strings representing the desired
* styling modes. Modes can include colors (e.g., 'red', 'blue'), brightness
* ('bright'), foreground/background ('fg', 'bg'), and text decorations
@nyteshade
nyteshade / function.sh
Last active February 16, 2024 01:51
Read macos `mdls` content as JSON or nicely printed in terminal
convertFonts() {
if [[ ${#} -lt 1 ]]; then
echo "Usage: convertFonts <startDir> <outDir> [rename]"
echo "where"
echo " outDir - if missing, this is the same as startDir"
echo "\n\x1b[3mIf rename is \x1b[1mtrue\x1b[22m, old file name is mv'ed to the new name"
echo "otherwise a copy is made and the original is untouched.\x1b[23m"
else
startDir="${1:-.}"
outDir="${startDir}"
@nyteshade
nyteshade / carrier_string.js
Last active March 7, 2024 19:54
CarrierString
/**
* Creates a `CarrierString` by attaching additional properties to a string.
* This function allows for the creation of a string that carries extra data in a type-safe way.
*
* @param string The base string to which properties will be attached.
* @param key The key of the property to attach, or an object with multiple properties.
* @param value The value associated with the key, if `key` is not an object.
* @returns A new `CarrierString` with the attached properties.
*
* @example
(function() {
const HTML = new Proxy(
class HTML {
static create(
name,
content,
style = {},
attributes = {},
webComponentName = undefined,
useDocument = undefined,
@nyteshade
nyteshade / Simple Export.js
Created April 20, 2024 00:42
Simple snippet of JavaScript to make exporting vanilla javascript easier
function ship(code) {
const _ne = Object.entries(code)
.reduce((a, [k,v]) => ({ ...a, [k]:v }), {});
const { defaults = {} } = code;
const [_den, _de] = Object.entries(defaults)?.[0];
if (typeof module !== 'undefined' && module.exports) {
module.exports = _ne || {};
}
else if (_den && _de) { globalThis[_den] = _de; }
}
@nyteshade
nyteshade / HTML.js
Last active April 20, 2024 05:41
ParamParser and HTML
function ship(code) {
const _ne = Object.entries(code)
.reduce((a, [k,v]) => ({ ...a, [k]:v }), {});
const { defaults = {} } = code;
const [_den, _de] = Object.entries(defaults)?.[0];
if (typeof module !== 'undefined' && module.exports) {
module.exports = _ne || {};
}
else if (_den && _de) { globalThis[_den] = _de; }
}
@nyteshade
nyteshade / settings.json
Created July 8, 2024 13:27
APC+ Visual Studio Code Settings
{
"apc.electron": {
"frame": false,
"trafficLightPosition": {"x": 7, "y": 5},
"titleBarStyle": "hidden",
},
"apc.listRow": {
"fontSize": 18
},
@nyteshade
nyteshade / volinfo.sh
Created September 4, 2024 02:15
diskutil volume info
#!/bin/sh
function volInfo() {
# Flags for verbose output
local verbose=false
# Process optional parameters
while (( "$#" )); do
case "$1" in
--show-name | --verbose | -v | -s)
@nyteshade
nyteshade / dynamic_dates.sql
Created September 10, 2024 20:28
Dynamic Dates in Snowflake
-- Step 1: Create the table without generated columns
create or replace table dates (
timestamp_column TIMESTAMP_NTZ PRIMARY KEY
);
-- Create a join table
create or replace table memorable_dates (
id integer autoincrement,
date timestamp_ntz,