Skip to content

Instantly share code, notes, and snippets.

View alystair's full-sized avatar
enjoying tea and breaking browsers 💣

Lorin Halpert alystair

enjoying tea and breaking browsers 💣
View GitHub Profile
@alystair
alystair / punctuationFirst.js
Last active March 6, 2021 00:16
Punctuation-first style (comma first style)
function foo() {
const target = document.getElementById('menu')
, debugTarget = document.getElementById('debugMenu')
, roles = document.body.classList;
return randomBool
? someFunction()
: someOtherFunction();
}
let obj = {
@alystair
alystair / enterOverride.js
Created March 12, 2020 06:47
Override enter key on longer forms and move to next input (not quite finished)
document.addEventListener('keydown', function () {
// Prevent enter key from submitting form if they are large
if (event.keyCode === 13 && event.target.nodeName !== 'TEXTAREA') {
let form = event.target.closest('form');
if (form && form.children.length > 10) { // Only large forms
event.preventDefault();
// If only one could just send a simulated tab key event to shift to next active field...
let startingNode = event.target.nextElementSibling || event.target.parentElement.nextElementSibling; // will break if final?
let foundStart = false;
function onlyInputs(node) {
@alystair
alystair / nextInputOnEnter.js
Created March 10, 2020 23:03
Avoid submitting a form and focus next available input in a form on enter key
document.addEventListener('keydown', function(){
if (event.keyCode === 13 && event.target.nodeName !== 'TEXTAREA') {
let form = event.target.closest('form');
if (form) {
event.preventDefault();
let startingNode = event.target.nextElementSibling || event.target.parentElement.nextElementSibling; // will break if final?
let foundStart = false;
function onlyInputs(node) {
if (!foundStart && node !== startingNode) return NodeFilter.FILTER_REJECT;
else foundStart = true;

Keybase proof

I hereby claim:

  • I am alystair on github.
  • I am alystair (https://keybase.io/alystair) on keybase.
  • I have a public key ASBDakt1VSL4TSfxaPzVwVxnQFdmH1nptCZ_ZWBcSzIobAo

To claim this, I am signing this object:

@alystair
alystair / stormybeach.sh
Created May 17, 2018 17:07
Terminal artwork
#!/bin/bash
echo "A pinprick within a pinprick in the infinite fabric of space. @Lorin"
#Background Colors
E=$(tput sgr0); R=$(tput setab 1); G=$(tput setab 2); Y=$(tput setab 3);
B=$(tput setab 4); M=$(tput setab 5); C=$(tput setab 6); W=$(tput setab 7);
function e() { echo -e "$E"; }
function x() { echo -n "$E "; }
function r() { echo -n "$R "; }
function g() { echo -n "$G "; }
function y() { echo -n "$Y "; }
@alystair
alystair / reddit_dota2.css
Last active August 4, 2017 01:20
/r/dota2 css optimization
ORIGINAL (2226)
.side .usertext a[href*="#mm-up"]{background:url("//b.thumbs.redditmedia.com/4nDuMWPyQnsE3-lIadr7QvCceQyZ7OEQm_D5J3u_aCk.png") 275px -106px no-repeat #202125}.side .usertext a[href*="#mm-down"]{background:url("//b.thumbs.redditmedia.com/4nDuMWPyQnsE3-lIadr7QvCceQyZ7OEQm_D5J3u_aCk.png") 275px -140px no-repeat #202125}.side .usertext a[href*="#irc"]{background:url("//b.thumbs.redditmedia.com/4nDuMWPyQnsE3-lIadr7QvCceQyZ7OEQm_D5J3u_aCk.png") 275px -175px no-repeat #202125}.side .usertext a[href*="#gathers"]{background:url("//b.thumbs.redditmedia.com/4nDuMWPyQnsE3-lIadr7QvCceQyZ7OEQm_D5J3u_aCk.png") 275px -420px no-repeat #202125}.side .usertext a[href*="#vods"]{background:url("//b.thumbs.redditmedia.com/4nDuMWPyQnsE3-lIadr7QvCceQyZ7OEQm_D5J3u_aCk.png") 275px -209px no-repeat #202125}.side .usertext a[href*="#demos"]{background:url("//b.thumbs.redditmedia.com/4nDuMWPyQnsE3-lIadr7QvCceQyZ7OEQm_D5J3u_aCk.png") 275px -244px no-repeat #202125}.side .usertext a[href*="#recruitcs"]{background:url("//b.
@alystair
alystair / AudioDiscovery.md
Last active April 22, 2018 20:00
Spec suggestions re: audio capabilities

Audio capabilities discovery

I'm unsure if this is something that would be part of WhatWG or W3C spec. Advice would be appreciated to move this forward.

We should be able to know if the computer is currently muting audio or has no working audio outputs. This allows us to programatically deal with the following types of situations:

  • Users has audio based disabilities
  • Users with disabled / no audio hardware
  • User has muted audio output temporarily
@alystair
alystair / lastFM-output_bug.xml
Created May 29, 2012 00:40
Last.FM API Bug (now playing does not pull album urls at times)
<?xml version="1.0" encoding="utf-8"?>
<lfm status="ok">
<recenttracks user="Alystair" page="1" perPage="2" totalPages="70928" total="141856" >
<track nowplaying="true">
<artist mbid="158c6b17-a00a-4624-9ae0-d614d5dd0d52">Aphex Twin</artist>
<name>Ventolin [Carharrack Mix]</name>
<streamable>0</streamable>
<mbid></mbid>
<album mbid=""></album>
@alystair
alystair / gist:1637641
Created January 19, 2012 03:43
Nodejitsu Achievements

Standard Achievements

  • Woah, I know Kung Fu.
    Read all Jitsu help pages
  • With a little help from my friends
    Deploy a project with 5 NPM modules
  • Enterprise Ready
    Deploy a project with 15 NPM modules
  • Momento
    Utilize the Snapshots function 25 times
  • The Long Haul
    Keep a deployment stable and operational for 6 months
  • If At First You Don't Succeed...
    Update and restart an instance 5 consecutive times within an hour
  • Heart Attack
    Stop a deployment that's under heavy network traffic
  • Greybeard
    Use the 'user whoami' jistu command
  • We Can Fix It In Post Restart a single deployment 25 times