Skip to content

Instantly share code, notes, and snippets.

View zaherg's full-sized avatar
🎯
Focusing

Zaher Ghaibeh zaherg

🎯
Focusing
View GitHub Profile
@zaherg
zaherg / firewall.sh
Created October 30, 2024 13:56 — forked from andrasbacsai/firewall.sh
Update a Hetzner Firewall rule with your IP address
#!/bin/bash
# Script to update a firewall rule in a Hetzner Firewall with your current IP address.
# Good if you would like to restrict SSH access only for your current IP address (secure).
#################
# WARNING: This script will overwrite all rules in the firewall rules, so make sure you
# added all the required rules.
# I use a separate firewall rule just for SSH access.
#################
@zaherg
zaherg / set-up-persistent-storage-for-K3s.md
Created October 19, 2024 09:27 — forked from ericboehs/set-up-persistent-storage-for-K3s.md
Set up persistent storage for K3s (via USB drive)

Set up persistent storage for K3s (via USB drive)

  1. Get root: ssh pi-k3s-master.local -t sudo su
  2. Find your disk via fdisk -l (e.g. /dev/sda1)
  3. Erase drive by repartitioning: mkfs.ext4 /dev/sda1
  4. Mount drive:
    mkdir /mnt/pi-k3s-storage
    chown -R ericboehs:ericboehs /mnt/pi-k3s-storage
    mount /dev/sda1 /mnt/pi-k3s-storage
    

Playground Comment Worker

This simple playground.yml creates a comment that opens a WordPress Playground and installs the plugin from the current repository. The current iteration only works with plugins that do not require a build step.

Playground test comment in action

CORS issues

Because GitHub doesn't send the right CORS headers for zip files to be able to install them in a Playground, you need a reverse proxy to bypass the CORS restrictions. The Worker below in worker.js can be used as a Cloudflare worker that

@zaherg
zaherg / README.md
Created April 26, 2024 08:01 — forked from kettanaito/README.md
Chromium on Vercel (serveless)

Chromium on Vercel (serverless)

This is an up-to-date guide on running Chromium in Vercel serverless functions in 2022. What you will read below is the result of two days of research, debugging, 100+ failed deployments, and a little bit of stress.

Getting started

Step 1: Install dependencies

Use chrome-aws-lambda that comes with Chromium pre-configured to run in serverless, and puppeteer-core due to the smaller size of Chromium distributive.

@zaherg
zaherg / node-typescript-esm.md
Created April 12, 2024 16:13 — forked from khalidx/node-typescript-esm.md
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@zaherg
zaherg / compose.yml
Created April 12, 2024 16:13 — forked from benuski/compose.yml
changedetection.io and browserless v2 docker compose
version: '3.2'
services:
changedetection:
image: ghcr.io/dgtlmoon/changedetection.io:latest
container_name: changedetection
hostname: changedetection
volumes:
- changedetection-data:/datastore
environment:
@zaherg
zaherg / Default.sublime-theme
Created July 28, 2023 13:01 — forked from anonymous/Default.sublime-theme
Sublime Text 2 Default theme file
[
{
"class": "label_control",
"color": [255, 255, 255],
"shadow_color": [24, 24, 24],
"shadow_offset": [0, -1]
},
{
"class": "button_control",
"content_margin": [6, 5, 6, 6],
@zaherg
zaherg / S3.php
Created June 25, 2023 19:41 — forked from marcoarment/S3.php
A simple PHP class to perform basic operations against Amazon S3 and compatible services.
<?php
/*
A simple PHP class to perform basic operations against Amazon S3 and compatible
services. Requires modern PHP (7+, probably) with curl, dom, and iconv modules.
Copyright 2022 Marco Arment. Released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@zaherg
zaherg / dnsovertls.md
Created March 12, 2023 05:33 — forked from uraimo/dnsovertls.md
Configure your Mac to use DNS over TLS
@zaherg
zaherg / Middleware-CSP.php
Created December 25, 2022 16:25 — forked from valorin/.env.example
CSP Middleware - the simple CSP middleware I use across all of my projects.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\Str;
/**
* Simple Content Security Policy middleware.