Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View justrhysism's full-sized avatar

Rhys Lloyd justrhysism

View GitHub Profile
@justrhysism
justrhysism / catch-version-check.js
Last active June 14, 2023 05:25
Catch Version Check
const appNameMeta = document.querySelector('meta[name="cg:app:name"]');
const appVersionMeta = document.querySelector('meta[name="cg:app:version"]');
const appName = appNameMeta ? appNameMeta.content : "Unknown";
const appVersion = appVersionMeta ? appVersionMeta.content : "Unknown";
const versionOutput = `${appName} @ ${appVersion}`;
const envConfig = (() => {
const noEnvResponse = "No Env Config";
const nextData = window.__NEXT_DATA__;
if (!nextData) return noEnvResponse;
@justrhysism
justrhysism / Snazzy Darker.itermcolors
Created March 8, 2023 00:01
Slightly Darker Snazzy iTerm2 Theme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>
// Name: Fix Wallpaper
import "@johnlindquist/kit";
/**
* Ensure you have a ~/Library/Desktop/Wallpaper.jpg file ready to go.
*
* The script requires sudo access, and assumes you have TouchID connected
* to `sudo` by prepending:
* ```
@justrhysism
justrhysism / async-loops.js
Last active December 6, 2022 22:36
Async Loops Sanity Check
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const delays = [
[200, 'should show second'],
[100, 'should show first'],
[300, 'should show third']
]
async function processWithFor(array) {
for (const [ms, msg] of array) {
@justrhysism
justrhysism / macos_random_shutdown_fix.sh
Last active March 15, 2021 09:13
macOS Random Shutdown Script Hack
#!/bin/bash
echo "MacBook Random Shutdown Fix"
# Check version
macOSMajorVersion=$(sw_vers -productVersion | cut -d. -f1)
macOSMinorVersion=$(sw_vers -productVersion | cut -d. -f2)
# Script currently only supports High Sierra and later
if [ "$macOSMajorVersion" != 10 ] || [ "$macOSMinorVersion" -lt 14 ]; then
@justrhysism
justrhysism / machine.js
Last active January 20, 2021 01:16
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@justrhysism
justrhysism / cloudSettings
Last active July 18, 2019 00:51
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-07-18T00:51:46.044Z","extensionVersion":"v3.4.0"}
@justrhysism
justrhysism / pretender.js
Last active February 14, 2019 08:17
Pretender v3.0.0 (Browser Ready)
var Pretender = (function () {
'use strict';
// This is just a placeholder for the build step
var createObject = Object.create;
function createMap() {
var map = createObject(null);
map["__"] = undefined;
delete map["__"];
@justrhysism
justrhysism / index.js
Created July 31, 2017 05:51
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const padStart = require('lodash/padStart');
const dateFns = require('date-fns')
const displayValue = "44/1/1";
convertDateDisplayToDateArray = (dateDisplay) => {
return dateDisplay.split('/').reverse().map(item => padStart(item, 2, 0));
@justrhysism
justrhysism / HtmlHelperExtensions.cs
Last active January 17, 2019 15:32
C# Razor HtmlHelper Extension for Conditional Wrapping Element Tag
using System.Collections.Generic;
using System.Diagnostics;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace UI.Extensions
{
public static class HtmlHelperExtensions
{