lda #1 ; A = 1
adc #1 ; A = 2
ldx #5 ; X = 5
stx $01 ; memory address $01 = 5
adc $01 ; A = 7
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]); |
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.
All the steps and code snippets from my tutorial series Set up an Ubuntu Web Server on an Intel NUC
Get an Ubuntu image for your NUC
apt update -y & apt upgrade -y
# 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 |
# 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 |
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 =
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> |