Skip to content

Instantly share code, notes, and snippets.

View mathiasschopmans's full-sized avatar

Mathias Schopmans mathiasschopmans

View GitHub Profile
@mathiasschopmans
mathiasschopmans / README.md
Last active January 8, 2025 14:09
Resolving Playwright Issues with Node.js 23.6.0 and Type Stripping

Resolving Playwright Issues with Node.js 23.6.0 and Type Stripping

This morning, my local Node.js version was automatically updated to 23.6.0 via Homebrew. While the update itself seemed harmless at first, it led to some mysterious errors when using Playwright with a TypeScript configuration:

(node:27126) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
SyntaxError: The requested module '@playwright/experimental-ct-react' does not provide an export named 'PlaywrightTestConfig'
SyntaxError: The requested module '@playwright/experimental-ct-react' does not provide an export named 'PlaywrightTestConfig'
@mathiasschopmans
mathiasschopmans / debounce.ts
Created November 13, 2024 14:09
Async TypeScript helpers
/**
* Creates a debounced version of an asynchronous function that delays the execution
* of the function until after `wait` milliseconds have elapsed since the last time it was invoked.
*
* @template Args - The argument types of the function being debounced.
* @template R - The return type of the function being debounced.
*
* @param {(...args: Args) => Promise<R>} func - The asynchronous function to debounce.
* @param {number} [wait=150] - The number of milliseconds to delay; defaults to 150ms.
* @returns {(...args: Args) => Promise<R>} - A debounced version of the function that returns a promise.
@mathiasschopmans
mathiasschopmans / commit-msg
Last active October 7, 2024 09:15
Git commit hook using bash to validate the commit message against conventional commits
#!/bin/bash
# Get the commit message
commit_msg=$(cat $1)
# Define a regex pattern to match the conventional commit message format
pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z]+\))?!?: .+$'
# Test if the commit message matches the pattern
if ! [[ $commit_msg =~ $pattern ]]; then
@mathiasschopmans
mathiasschopmans / pluckRecursive.ts
Created January 2, 2023 12:49
pluck recursive attribute with native methods
export function pluckRecursive(input: any, prop: string, collect = []) {
collect = collect || [];
if (!input) return collect;
if (Array.isArray(input)) {
input.forEach(function (value) {
pluckRecursive(value, prop, collect);
})
} else if (typeof input === 'object') {
@mathiasschopmans
mathiasschopmans / workflow.yml
Created July 30, 2021 08:14
GitHub Action to test, build, push & deploy PHP based application
name: CI
on:
push:
branches-ignore:
- 'dependabot/**'
tags:
- 'v*'
pull_request:
branches-ignore:
@mathiasschopmans
mathiasschopmans / ObjectSize.php
Created December 4, 2016 13:52
Sort various (clothing) sizes in an array
<?php
class ObjectSize {
protected static $sizes = [
'xxxxl',
'xxxl',
'xxl',
'xl',
'l',
@mathiasschopmans
mathiasschopmans / hue-api.md
Last active February 8, 2020 18:44
HUE Remote-API summary + buildlamp script
@mathiasschopmans
mathiasschopmans / capybara.rb
Created May 4, 2015 13:07
Ignore Capybara SSL verification (https errors) and add Capybara Screenshot functionality
Capybara.register_driver :webkit_ignore_ssl do |app|
Capybara::Webkit::Driver.new(app).tap {|d| d.browser.ignore_ssl_errors }
end
Capybara::Screenshot.register_driver(:webkit_ignore_ssl) do |driver, path|
driver.save_screenshot(path)
end
Capybara.javascript_driver = :webkit_ignore_ssl
Capybara.default_driver = :webkit_ignore_ssl
@mathiasschopmans
mathiasschopmans / neopixelring.ino
Created March 4, 2015 18:46
neopixel ring demo
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.
@mathiasschopmans
mathiasschopmans / _formhelper.jade
Last active September 9, 2015 08:01
Jade form-helpers. Can be used with bootstrap
mixin input(label, options)
- var defaults = {"tag":"input", "type":"text", "labelClass":"form-label", "name":sanitize(label), "placeholder":null, "value":null, "id":sanitize(label).substring(0, 10) + "-" + randomString(), "tabindex":null}
- var input = extend({}, defaults, {"label":label, "required":attributes.required}, options, attributes)
- var baseClass = input.type == "hidden" ? null : "form-control"
- delete attributes.required
if input.placeholder === true
- input.placeholder = label
if input.type == "hidden"