Skip to content

Instantly share code, notes, and snippets.

Eric Lewis ericandrewlewis

Block or report user

Report or block ericandrewlewis

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
View gist:1619017504caf75a9ddbf6ec03731417

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 Dec 20, 2018
Waveforms and timbre "article" outline
View gist:cd95f926a86dab93c22375a863539f9e

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 Jan 20, 2019
Set up an Ubuntu Web Server on an Intel Nuc, steps and code snippets
View index.md
View nginx-application-router.conf
# 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 Dec 10, 2018 — forked from NathanGiesbrecht/noip2.service
Systemd Service file for no-ip.com dynamic ip updater
View noip2.service
# 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 Jan 27, 2019
Scroll to the rock bottom of a website
View index.md

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 Jul 16, 2017
Say When: Recursing Promises In JavaScript
View index.md

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)
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="square-1"></div>
</body>
</html>
View index.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>
View index.html
<!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>
You can’t perform that action at this time.