Skip to content

Instantly share code, notes, and snippets.

View ericandrewlewis's full-sized avatar

Eric Lewis ericandrewlewis

View GitHub Profile

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 / gist:cd95f926a86dab93c22375a863539f9e
Last active December 20, 2018 23:15
Waveforms and timbre "article" outline

Thanks for offering to look at this! Any feedback you have is appreciated.

I've been making snack-sized articles that run code, and considering writing one for introductory synthesizer concepts of oscillator waveforms and timbre.

The Web Audio API is super cool. I've been playing around with it, mostly with the nice and "declarative" wrapping library Tone.js.

I'm planning on using it to include visualizations and offer readers a synth they can play with in the zxcvbn neighborhood of their keyboard.

Some things in my mind:

  • This is an opportunity to make a really different experience rather than a straight-reading article, and I'm not sure my plan is weird enough yet.
@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 / nginx-application-router.conf
Last active November 21, 2021 08:53
NGINX application router
# Borrowed some configuration from
# https://github.com/h5bp/server-configs-nginx/blob/master/nginx.conf
# Default: nobody nobody
user nginx;
# Sets the worker threads to the number of CPU cores available in the system for best performance.
# Should be > the number of CPU cores.
# Maximum number of connections = worker_processes * worker_connections
# Default: 1
@ericandrewlewis
ericandrewlewis / noip2.service
Last active May 17, 2021 03:08 — forked from NathanGiesbrecht/noip2.service
Systemd Service file for no-ip.com dynamic ip updater
# Simple No-ip.com Dynamic DNS Updater
#
# 1) Install DUC (Dynamic Update Client) and create the configuration file
# as described on noip website https://my.noip.com/#!/dynamic-dns/duc
# 2) Copy this file noip2.service to /etc/systemd/system/
# 3) Execute `sudo systemctl enable noip2`
# 4) Execute `sudo systemctl start noip2`
[Unit]
Description=No-ip.com Dynamic Update Client
@ericandrewlewis
ericandrewlewis / index.md
Last active January 27, 2019 00:47
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 July 16, 2017 14:28
Say When: Recursing Promises In JavaScript

Say When: Recursing Promises In JavaScript

Imagine there's an API that outputs ten items in a single request. You want to get all the items from this API, and you're gonna use JavaScript and promises. The problem is, you don't know if there's 2 pages of data or 200.

You can't do this well with a common .then() chain, because you don't know how many requests you'll need:

makeRequest()
  .then(makeRequest)
  .then(makeRequest)
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="square-1"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Cookie Monster's Cookie Dough Recipe</title>
</head>
<body>
<h1>Cookie Monster's Cookie Dough Recipe</h1>
<p><img src="http://i4.manchestereveningnews.co.uk/incoming/article10580003.ece/ALTERNATES/s615/JS47622759.jpg"></p>
<blockquote>"You may have only seen me eating cookies but sometimes I make them too!" - Cookie Monster</blockquote>
<h2>Ingredients</h2>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Shoyu Ramen Recipe</h1>
<img src="http://www.kobayashinoodle.com/wp/wp-content/uploads/2011/06/QuickShoyuRamen.jpg">
<blockquote>"My first bowl of ramen was like my first bowl of cereal, all over again" — Neil Young</blockquote>
<p>Shoyu Ramen is a popular soup-based meal in Japan. </p>