Skip to content

Instantly share code, notes, and snippets.

View nyteshade's full-sized avatar

Brielle Harrison nyteshade

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / asArray.js
Last active August 28, 2018 21:00
Convert object with numeric keys to array, keeping order
/**
* If the value supplied is actually a number, basically finite values that
* can be parsed as floats and are not `NaN` will cause this function to
* return true
*
* @param {mixed} value any value that should be tested for numberhood
*
* @return {Boolean} true if the value is not `NaN` and can be parsed as
* a float
*/
@nyteshade
nyteshade / updateNpm.bat
Created June 18, 2018 01:00 — forked from johnmcase/updateNpm.bat
Update npm on windows
rem see https://github.com/coreybutler/nvm-windows/issues/300
@echo off
SETLOCAL EnableDelayedExpansion
if [%1] == [] (
echo Pass in the version you would like to install, or "latest" to install the latest npm version.
) else (
set wanted_version=%1
@nyteshade
nyteshade / Function.signature.js
Created April 4, 2018 20:00
A small patch to Function.prototype that helps make functions and classes a bit more self-documenting
// Patch Function.prototype to provide the signature in the REPL
Object.defineProperty(
Function.prototype,
'signature',
{
get() {
let source = this.toString()
// For classes we need to extract the signature of the
// constructor function within; so use some regular