Skip to content

Instantly share code, notes, and snippets.

View cecilemuller's full-sized avatar

Cecile Muller cecilemuller

View GitHub Profile
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active December 4, 2025 10:03
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@cecilemuller
cecilemuller / copyToClipboard.ts
Created September 24, 2025 15:41
Node utils (Windows)
import { spawn } from "node:child_process";
// Copies text to the Windows clipboard
export function copyToClipboard(text: string) {
spawn("clip").stdin.end(text);
}
@cecilemuller
cecilemuller / example.ts
Last active September 4, 2025 00:56
Typescript: augment Custom Elements registry
// Exposes a Web Component that is registered using:
// customElements.define("x-example", ExampleElement)
declare global {
interface CustomElementRegistry {
get(name: "x-example"): typeof ExampleElement | undefined;
}
}
// No need to import the type or typecast the constructor anymore,
// Intellisense recognizes its properties and methods
@cecilemuller
cecilemuller / tsconfig.dts.json
Last active September 1, 2025 08:38
Typescript 5.9+ Config
{
// Config for emitting .d.ts files
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "esnext",
"module": "nodenext",
"moduleDetection": "force",
"newLine": "LF",
"strict": true,
"noFallthroughCasesInSwitch": true,
@cecilemuller
cecilemuller / get_combinations.php
Created February 1, 2013 03:13
PHP: Get all combinations of multiple arrays (preserves keys)
<?php
function get_combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_value) {
$tmp[] = array_merge($result_item, array($property => $property_value));
}
@cecilemuller
cecilemuller / example.yml
Created October 20, 2020 01:49
Run Docker Compose + in Github Action
name: Test
on:
push:
branches:
- main
- features/**
- dependabot/**
pull_request:
branches:
@cecilemuller
cecilemuller / launch.json
Last active April 4, 2025 13:08
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
@cecilemuller
cecilemuller / plugin.ts
Last active January 28, 2025 16:37
Vite Plugin: emit an asset using `emitFile` and `configureServer`
import type { PluginOption } from "vite";
export function plugin(): PluginOption {
return [
{
apply: "serve",
name: "example-serve",
configureServer(server) {
server.middlewares.use("/subfolder/example.txt", (_req, res) => {
res.appendHeader("Content-Type", "text/plain");
@cecilemuller
cecilemuller / plugin.ts
Last active January 28, 2025 16:21
Vite Plugin: apply Prettier to HTML output using `transformIndexHtml`
import type { PluginOption } from "vite";
import { format } from "prettier";
export function plugin(): PluginOption {
return {
name: "example",
transformIndexHtml: async (html) => format(html, {
// https://prettier.io/docs/en/options.html
parser: "html",
htmlWhitespaceSensitivity: "ignore"
@cecilemuller
cecilemuller / plugin.ts
Last active January 28, 2025 14:46
Vite Plugin: configureServer
import type { PluginOption } from "vite";
export function plugin(): PluginOption {
return {
name: "example",
configureServer(server) {
// Log all requests
server.middlewares.use((req, _res, next) => {
console.log(req.url); // full path
next();