Skip to content

Instantly share code, notes, and snippets.

View justrhysism's full-sized avatar

Rhys Lloyd justrhysism

View GitHub Profile
@justrhysism
justrhysism / fetch-pretender.js
Created February 27, 2017 07:08
Fetch Pretender Browserified
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
window.Pretender = require('fetch-pretender');
},{"fetch-pretender":2}],2:[function(require,module,exports){
(function (global){
/* jshint -W097 */
'use strict';
var RouteRecognizer = require('route-recognizer');
var FakeXMLHttpRequest = require('xhr-pretender');
var createFetch = require('fetchme');
@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
{
@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 / 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 / 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 / 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 / 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 / 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) {
// 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 / 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>