Skip to content

Instantly share code, notes, and snippets.

View huntie's full-sized avatar

Alex Hunt huntie

View GitHub Profile
@huntie
huntie / print.css
Created June 12, 2014 12:07
Show link addresses alongside titles in a printed webpage
@media print {
a:after {
/* Display link address for accessibility */
content: ' [' attr(href) '] ';
}
}
@huntie
huntie / add-sublime-to-terminal.md
Last active May 31, 2018 11:17
Add Sublime Text 3 as a terminal command in macOS

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

@huntie
huntie / miner.py
Last active November 10, 2015 16:22
Challenge to find permutations of words within a scrambled text file
text = open('scrambled.txt', 'r').read()
words = ['miner', 'willy', 'andre', 'jet', 'set', 'bug', 'byte']
def permute(string):
result = []
if len(string) == 1:
result = [string]
else:
for i, char in enumerate(string):
@huntie
huntie / keybase.md
Last active June 6, 2016 13:05
Keybase GitHub identity

Keybase proof

I hereby claim:

  • I am huntie on github.
  • I am huntie (https://keybase.io/huntie) on keybase.
  • I have a public key whose fingerprint is 144D 5AFF A2FB 93C3 167B 5B0C 7B78 B3A2 DCC8 FF93

To claim this, I am signing this object:

@huntie
huntie / KeyGenerateCommand.php
Last active July 19, 2016 13:13
APP_KEY generation command for Lumen, adapted from Illuminate\Foundation\Console\KeyGenerateCommand
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class KeyGenerateCommand extends Command
{
/**
* The name and signature of the console command.
@huntie
huntie / dsa-query-selector.js
Last active January 3, 2022 02:14
A simplified implementation of `document.querySelector()` and `document.querySelectorAll()`, during a workshop on data structures.
/**
* Run a callback over all children of a given element using depth-first
* traversal.
*
* @param {HTMLElement} element
* @param {Function} callback
*/
function iterateDOM(element, callback) {
const nodes = [];
@huntie
huntie / certbot.md
Last active March 1, 2018 17:42
Issue and automate renewal of SSL certificates with Let's Encrypt using Certbot

Install Certbot and register Let's Encrypt account:

add-apt-repository ppa:certbot/certbot
apt update
apt install certbot
certbot register

Issue new SSL certificates for each host:

certbot certonly --webroot -w /var/www/alexhunt.io/ -d alexhunt.io -d www.alexhunt.io

@huntie
huntie / unpack_module.py
Created May 31, 2018 10:42
A small reflection utility to access public module members as a dict
def unpack_module(module) -> dict:
"""
Return the members of an imported package or module explicitly exported
using __all__.
"""
return {k: module.__dict__[k] for k in module.__dict__.get('__all__', [])}
@huntie
huntie / graphqlresource.py
Last active October 7, 2018 10:55
Implementation of a GraphQL HTTP server for Graphene as a Falcon API resource
import falcon
from typing import Tuple
import ujson
from .graphql import schema
class GraphQLNoQueryResolved(falcon.HTTPBadRequest):
"""
An exception indicating that a GraphQL query could not be resolved from the
incoming request. This will create an HTTP 400 response when raised.
"""
@huntie
huntie / webpack.config.js
Last active March 25, 2019 10:45
Load environment settings in a JavaScript project from a base .env and optional .env.<build-mode> file, using dotenv.parse (no side-effects)
const dotenv = require('dotenv');
const fs = require('fs');
const { flowRight, partial, unary } = require('lodash');
const path = require('path');
/**
* Load the environment settings for the current mode from `.env.{mode}` merged
* with any private entries defined in `.env` if present.
*
* @param {string} mode