Skip to content

Instantly share code, notes, and snippets.

View nyteshade's full-sized avatar

Brielle Harrison nyteshade

View GitHub Profile
@nyteshade
nyteshade / combine_and_deepmerge.js
Created August 30, 2018 20:43
Deepmerge Inline
let { combine, deepmerge } = (() => {
function isMergeableObject(value) {
return isNonNullObject(value)
&& !isSpecial(value)
}
function isNonNullObject(value) {
return !!value && typeof value === 'object'
}
@nyteshade
nyteshade / setupProject.js
Last active January 27, 2019 07:04
Quick easy project setup with command line options
#!/usr/bin/env node
let spawn = require('child_process').spawn
let path = require('path')
let fs = require('fs')
// ---------------------------------------------------------------------------
// BEGIN: Setup data
// ---------------------------------------------------------------------------
@nyteshade
nyteshade / enumeration.js
Last active October 6, 2018 21:31
Enumerations in JavaScript
/**
* Creates an array with several notable properties. Given several strings,
* the array will be indexed by both name and number. Some of the notable
* properties added to the resulting array are as follows:
*
* Functions:
* ```
* data() - supplied with the index or string, any associated data objects
* will be returned. 'data()' will only exist if there is no
* such key. A synonym key __data__ will also be set.
@nyteshade
nyteshade / fnOrVal.js
Last active October 6, 2018 22:15
ObjectPath - A meta class to allow for access into a given object using a path
/**
* A function that will allow the presence of a function in the place of a
* value that can, instead generate the value. Any function supplied will
* use `this` bound to `functionOrValue()` as the `this` value for the
* supplied function; unless, of course, the supplied function is a big
* arrow function that cannot be rebound.
*
* @param {Function|mixed} fnOrVal either a function or value
* @param {Array<mixed>} args an array of input that will be passed to any
* supplied function and ignored otherwise
@nyteshade
nyteshade / Stacktrace
Created March 17, 2019 22:38
AOS4.1 Debug via QEmu
U-Boot 2010.06.05 (Jul 08 2018 - 22:45:33)
CPU: AMCC PowerPC 460EX Rev. B at 1150 MHz (PLB=230 OPB=115 EBC=115)
No Security/Kasumi support
Bootstrap Option A - Boot ROM Location EBC (8 bits)
Internal PCI arbiter disabled
32 kB I-Cache 32 kB D-Cache
Board: Sam460ex, PCIe 4x + SATA-2
I2C: ready
DRAM: 512 MiB (ECC not enabled, 460 MHz, CL0)
@nyteshade
nyteshade / NicePS1 + Zsh.sh
Last active January 17, 2021 08:31
ZSH Prompt (might require OhMyZsh)
terse_git_prompt_info () {
local ref
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]
then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
echo "(%{\x1b[31m%}${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}
export PS1=$'
@nyteshade
nyteshade / dict.playground.swift
Created September 26, 2019 06:04
Example of Dictionary for Configuration
import UIKit
enum ConfigType {
case primaryFont(UIFont)
case secondaryFont(UIFont)
case tertiaryFont(UIFont)
case primaryLabelColor(UIColor)
case secondaryLabelColor(UIColor)
case tertiaryLabelColor(UIColor)
@nyteshade
nyteshade / ViNCEdThemes.js
Last active January 5, 2021 03:08
ViNCEdThemes
/*
Small sample script designed to use JavaScript, with Chrome, to pull the actual
RGB values out of the sample theme images located in the iTerm2 Color Schemes repo
https://github.com/mbadolato/iTerm2-Color-Schemes
To use, navigate to the page above, copy this entire file to the clipboard, open
the developer console (Ctrl-Shift-i and select console, like Command-Shift-i on
macs) and paste the contents into that window.
For the most part, theme image file names are the theme name in snake case, such
@nyteshade
nyteshade / MyHttpHandler.java
Last active April 7, 2022 18:41
Java 6 WebServer
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.Map;
import java.util.regex.Pattern;
import javax.sound.sampled.SourceDataLine;
import java.util.regex.Matcher;
@nyteshade
nyteshade / yesno
Created March 26, 2022 05:38
YesNo Shell Command
#!/bin/bash
if [[ "--help" = "$1" ]]; then
printf "Usage: ${0} [Message] [Yes] [No] [Yy]\n"
printf " Message - Defaults to \"Are you sure? \"\n"
printf " (notice the space at the end)\n"
printf " Yes - Positive message defaults to Yes\n"
printf " No - Negative message defaults to No\n"
printf " Yy - Letters to use for possitive message\n\n"
printf " Positive messages exit with 0, Negative\n"