Skip to content

Instantly share code, notes, and snippets.

Nate Adams n8jadams

Block or report user

Report or block n8jadams

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@n8jadams
n8jadams / execAndEchoRealtime.php
Created Oct 11, 2019
Execute and Echo Command line tools in Real Time (PHP)
View execAndEchoRealtime.php
<?php
// $cmd is something you execute in your command line
function execAndEchoRealtime($cmd)
{
echo PHP_EOL;
$proc = proc_open($cmd, [['pipe','r'],['pipe','w'],['pipe','w']], $pipes);
while(($line = fgets($pipes[1])) !== false) {
fwrite(STDOUT, $line);
@n8jadams
n8jadams / focusAndOpenKeyboard.js
Last active Oct 11, 2019
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.
View focusAndOpenKeyboard.js
/*
// 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 Oct 11, 2019
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.
View GraphQLQueryChecker.php
<?php
/**
* Instructions:
* In an Object Resolve function, use the fourth argument ($info)
*
* Example usage:
*
* $fieldInQuery = GraphQLQueryChecker::isFieldInQuery('some.nested.fieldname', $info);
*
You can’t perform that action at this time.