Skip to content

Instantly share code, notes, and snippets.

View Zarel's full-sized avatar

Guangcong Luo Zarel

View GitHub Profile
@Zarel
Zarel / wat-explanation.md
Last active November 16, 2023 10:30
Understanding the JavaScript in the Wat talk

The Wat talk has been floating around for a long time:

https://www.destroyallsoftware.com/talks/wat

There are probably lots of articles explaining exactly what's going on in this video, but I'll add this to the mix, since JavaScript typecasting is actually a lot simpler than most people think.

Useful background knowledge

To understand typecasting in JavaScript, you actually only need to know three rules:

@Zarel
Zarel / smogresearch2ps
Last active December 26, 2015 07:18
Convert Smogon Research gen 6 learnset data to PS learnset data
input = $('textarea')[0].value;
// remove existing gen 6 data
for (var speciesid in BattleLearnsets) {
if (!BattleLearnsets[speciesid] || !BattleLearnsets[speciesid].learnset) continue;
var learnset = BattleLearnsets[speciesid].learnset;
for (var moveid in learnset) {
var sources = learnset[moveid];
for (var i=sources.length-1; i>=0; i--) {