Skip to content

Instantly share code, notes, and snippets.

View ericandrewlewis's full-sized avatar

Eric Lewis ericandrewlewis

View GitHub Profile

top (the UNIX process inspector) cheat sheet

This is a list of the most helpful keyboard commands I use within top.

The basics

h shows help on interactive commands. Also see the top manual page

q to quit the program.

@ericandrewlewis
ericandrewlewis / gist:59ee632d94ebd4ab50f0ba4641f061c5
Created October 15, 2024 01:38
Annual global population growth for different periods
const parseInput = input => {
const lines = input.split('\n');
const output = [];
let periodStartDate = null;
let periodStartPopulation = null;
for (let i = 0; i < lines.length; i++) {
const lineBits = lines[i].split(' ').filter(lineBit => lineBit !== '');
if (i === 0) {
periodStartDate = parseInt(lineBits[0]);
periodStartPopulation = parseInt(lineBits[1]);
@ericandrewlewis
ericandrewlewis / a.md
Last active October 9, 2024 00:31
The WordPress Customizer

The WordPress Customizer

The WordPress Customizer is an interface for drafting changes to content while previewing the changes before they are saved. This is an alternative to the "save and suprise" model of changing settings without knowing what exactly will happen.

The customizer can be accessed in the admin interface under Appearance > Customize.

A screenshot of the customizer

#19909 is the trac ticket that introduced the Customizer during the 3.4 release cycle.

@ericandrewlewis
ericandrewlewis / gist:95239573dc97c0e86714
Last active September 11, 2024 17:10
Setting up a WordPress site on AWS

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

@ericandrewlewis
ericandrewlewis / index.md
Last active September 2, 2024 13:09
Scroll to the rock bottom of a website

Scroll to the rock bottom of a website

Throw the script below in the browser's JS console.

It moves the viewport to the bottom of the page repeatedly with a delay in between. This is useful when the page loads data via infinite scroll and you want to do something with all the data.

const atPageBottom = () => {
  const scrolled = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
  const documentHeightMinusOneViewport =
@ericandrewlewis
ericandrewlewis / index.md
Last active June 6, 2024 01:43
C++ Pointer Tutorial

C++ Pointer Tutorial

Because pointers can be ugh

"Regular" variables (not pointers)

To understand a pointer, let's review "regular" variables first. If you're familiar with a programming language without pointers like JavaScript, this is what you think when you hear "variable".

When declaring a variable by identifier (or name), the variable is synonymous with its value.

This cheat sheet is only for the ca65 assembler, and probably not compatible with others

adc - Add to the accumulator

lda #1 ; A = 1
adc #1 ; A = 2
ldx #5 ; X = 5
stx $01 ; memory address $01 = 5
adc $01 ; A = 7
@ericandrewlewis
ericandrewlewis / index.md
Last active November 11, 2023 18:18
Set up an Ubuntu Web Server on an Intel Nuc, steps and code snippets
@ericandrewlewis
ericandrewlewis / LICENSE
Last active October 19, 2023 14:03
Circles on an Axis in a Static Force Layout
The MIT License (MIT)
Copyright (c) 2016 Eric Andrew Lewis
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
@ericandrewlewis
ericandrewlewis / gist:a5bc6c31b840a556a813
Last active March 18, 2022 08:46
Notes on making a keyboard

Notes on making a keyboard

Instructions for making a 60% keyboard with an abbreviated navigation cluster.

Parts & Tools

  • A keycap is the part of the key that the user touches. It is non-mechanical, it is just a piece of plastic. It sits on top of a switch.
  • A switch is the electro-mechanical component that, when compressed, makes an electronic connection.
  • Switches are wired to a controller, which aggregates keypress info and tells the target device (e.g. Macbook Pro) what to do over USB.
  • Switches sit on either a PCB or a piece of metal.
  • The PCB or piece of metal sits inside a case.