Skip to content

Instantly share code, notes, and snippets.

View n8jadams's full-sized avatar

Nate Adams n8jadams

View GitHub Profile
@n8jadams
n8jadams / extendedGlobal-extendedWindow.ts
Last active March 5, 2020 17:33
In Typescript, use the global object in Node, or the window object in the browser
/* eslint-disable @typescript-eslint/no-explicit-any */
// Nodeland
interface ExtendedGlobal extends NodeJS.Global {
someGlobalKey: string
}
export const extendedGlobal: ExtendedGlobal = global as any
// Browserland
@n8jadams
n8jadams / mac-keybindings-on-windows.ahk
Last active February 9, 2020 14:44
These Autohotkey keybindings to help make your Windows feel like a Mac.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
; Screenshot (you still have to paste it into paint or whatever)
>#+3::Send {PrintScreen};^+3
>#+4::Send {PrintScreen};^+4
<#+3::Send {PrintScreen};^+3
<#+4::Send {PrintScreen};^+4
@n8jadams
n8jadams / GraphQLQueryChecker.php
Last active October 11, 2019 14:12
GraphQLQueryChecker. A PHP Class that checks if a field is requested in the query. I've used this in production with webonyx/graphql-php v0.9.14 for more than a year.
<?php
/**
* Instructions:
* In an Object Resolve function, use the fourth argument ($info)
*
* Example usage:
*
* $fieldInQuery = GraphQLQueryChecker::isFieldInQuery('some.nested.fieldname', $info);
*
@n8jadams
n8jadams / focusAndOpenKeyboard.js
Last active October 11, 2019 14:11
Focus And Open Keyboard. This is a nice cross-browser-compatible function that will focus on an input element and open the keyboard (on mobile devices). Especially useful for modals on IOS devices.
/*
// Example usage
var myElement = document.getElementById('my-element');
var modalFadeInDuration = 300;
focusAndOpenKeyboard(myElement, modalFadeInDuration); // or without the second argument
*/
function focusAndOpenKeyboard(el, timeout) {
if(!timeout) {
timeout = 100;