Skip to content

Instantly share code, notes, and snippets.

View n8jadams's full-sized avatar

Nate Adams n8jadams

View GitHub Profile
@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 / execAndPipeOutput.php
Last active February 9, 2021 21:18
Execute a command and pipe its output to stdout (echo it) as it's recieved, rather than wait for the command to finish executing
<?php
function execAndPipeOutput($cmd)
{
echo PHP_EOL;
$proc = proc_open($cmd, [['pipe','r'],['pipe','w'],['pipe','w']], $pipes);
while(($line = fgets($pipes[1])) !== false) {
fwrite(STDOUT, $line);
}
while(($line = fgets($pipes[2])) !== false) {
@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;
@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);
*