Skip to content

Instantly share code, notes, and snippets.

@Rich-Harris
Rich-Harris / service-workers.md
Last active January 28, 2025 15:01
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@TheGreatSageEqualToHeaven
TheGreatSageEqualToHeaven / Lua51AllOpcodeCases.lua
Last active January 28, 2025 15:00
Lua 5.1 Opcode Case Test File
-- load
local math = math -- GETGLOBAL
local newproxy = newproxy -- GETGLOBAL
local ipairs = ipairs -- GETGLOBAL
local floor = math.floor -- GETTABLE KST(C)
local pi = math.pi -- GETTABLE KST(C)
local _nil = nil -- LOADNIL B -> C (1)
local _true = true -- LOADBOOL B(1)
local _false = false -- LOADBOOL B(0)
@TheGreatSageEqualToHeaven
TheGreatSageEqualToHeaven / LuauAllOpcodes.luau
Last active January 28, 2025 15:00
Hellborn abomination
-- LOP_BREAK, LOP_COVERAGE and LOP_NOP aren't possible without the C API
-- Vector constants are supported but need to be commented in and need the ctor renamed
-- LOADKX and JUMPX support can be commented out
---------------------------------------------------------------------------------------
-- PREPVARARGS
local a = "hello world"; -- LOADK
a,a,a,a,a,a = nil, true, false, 1, 9e9, function() --[[ RETURN ]] end; -- LOADNIL, LOADB 1, LOADB 0, LOADN 1, LOADK 9e9, DUPCLOSURE (no captures)
FUNC_GLOBAL = newproxy; -- GETIMPORT, SETGLOBAL
local t = { }; -- NEWTABLE 1 1
local function stub() -- NEWCLOSURE (ref, val, ref captures)
@TheGreatSageEqualToHeaven
TheGreatSageEqualToHeaven / LuaVersion.lua
Created March 28, 2024 01:35
Runtime Lua version detection without _VERSION
local function luaVersion()
local f = function()
return function() end
end
if 0xffffffffffffffffffffffffffffffffffffffffffffff == 2 ^ 64 then
return "Luau"
end
if ({nil,[1] = true})[1] then
@TheGreatSageEqualToHeaven
TheGreatSageEqualToHeaven / LuauOptimizeLevel.lua
Created March 28, 2024 01:34
Getting the Luau optimize level at runtime safely
local function getOptimizeLevel()
local function dupclosure()
return function() end
end
local O0 = dupclosure() ~= dupclosure()
local function inlinefunction()
return debug.info(1, "f")
end

Learning Plan for Design Patterns and Principles of Good Design

These learning resources primarily focus on programming using Good Design Principles and Design Patterns

  • There is an emphasis on learning using PHP, although most patterns are universal to every object orientated language.
@Pen-y-Fan
Pen-y-Fan / Test Driven Development (TDD) Learning Plan.md
Last active January 28, 2025 14:58
Test Driven Development (TDD)

Learning Plan for Test Driven Development (TDD)

These learning resources primarily focus on Test Driven Development (TDD).

  • There is an emphasis on learning using PHP, Laravel and PHPUnit.
  • All these resources are free (at the time of writing)
@DanShaders
DanShaders / sink-eq6.conf
Last active January 28, 2025 14:57
PipeWire Equalizer Settings for Dell XPS 15 (2023)
# 6 band sink equalizer
#
# Copy this file into a conf.d/ directory such as
# ~/.config/pipewire/filter-chain.conf.d/
#
context.modules = [
{ name = libpipewire-module-filter-chain
args = {
node.description = "Internal Speakers Equalizer Sink"
media.name = "Internal Speakers Equalizer Sink"
@letsautomatenet
letsautomatenet / ESPHome YAML Template - ESP32.yaml
Created January 13, 2024 18:32
ESPHome YAML Template - ESP32
### START - Update this section with relevant details ###
substitutions:
device_name: "device-name-here"
friendly_name: Device Name Here
board_type: esp32dev
framework: esp-idf # arduino or esp-idf (recommended for ESP32)
# ESPHome API used by Home Assistant, etc

Windows 10 - Using Git Bash With TMUX

Why Not Use WSL?

I tried the WSL and it isn't quite seamless enough for me. I ran in to problems when editing in VSCode and having watchers on my files (ng serve, dotnet watch run, etc.). In addition, I kept running in to problems that only manifest themselves when running in WSL. For example, this issue with doing production builds and the terser plugin has made many a developer rage-quit on using WSL. Just figuring out that it was an issue with the WSL took a lot of time.

That terser plugin issue was never resolved and I ended up having to keep a git bash window open in addition to my WSL console window so I could do production builds. To make matters worse, my npm packages were platform-dependent so I couldn't use the same project folder. So, my procedure was: commit whatever changes to test branch, push to repo, git pull on my "windows" project folder, and do a production build there