Skip to content

Instantly share code, notes, and snippets.

View PatrickJS's full-sized avatar

PatrickJS PatrickJS

View GitHub Profile
@PatrickJS
PatrickJS / deploy-ssh.sh
Created October 29, 2024 13:18 — forked from lambrospetrou/deploy-ssh.sh
Simple deployment on a VPS, Hetzner, EC2 with zero downtime. Uses Caddy and systemd.
#!/usr/bin/env bash
# Inspired from:
# - https://blog.wesleyac.com/posts/simple-deploy-script
# - https://gist.github.com/WesleyAC/b3aaa0292579158ad566c140415c875d
# - https://caddyserver.com/docs/running#using-the-service
set -e
# cd $(dirname $0)
@PatrickJS
PatrickJS / html-languages.txt
Created October 22, 2024 16:36 — forked from JamieMason/html-languages.txt
HTML lang attribute / ISO language code reference / Culture names
CULTURE SPEC.CULTURE ENGLISH NAME
--------------------------------------------------------------
Invariant Language (Invariant Country)
af af-ZA Afrikaans
af-ZA af-ZA Afrikaans (South Africa)
ar ar-SA Arabic
ar-AE ar-AE Arabic (U.A.E.)
ar-BH ar-BH Arabic (Bahrain)
ar-DZ ar-DZ Arabic (Algeria)
ar-EG ar-EG Arabic (Egypt)
# save this file in ~/.gitignore_global
# set this file as the global .gitignore
# > git config --global core.excludesFile ~/.gitignore_global
# verify by running
# > git config --global core.excludesfile
.DS_Store
._.DS_Store
**/.DS_Store
**/._.DS_Store
@PatrickJS
PatrickJS / variousCountryListFormats.js
Created September 23, 2024 00:28 — forked from incredimike/variousCountryListFormats.js
List of Countries in various Javascript data structures: Alphabetical country lists & Country data objects.
// Lists of countries with ISO 3166 codes, presented in various formats.
// Last Updated: July 30, 2020
// If you're using PHP, I suggest checking out:
// https://github.com/thephpleague/iso3166
// or Laravel: https://github.com/squirephp/squire
//
// JS developers can check out:
// https://www.npmjs.com/package/iso3166-2-db
//
@PatrickJS
PatrickJS / qwik.tsx
Created September 20, 2024 04:16
Basic Folder/File Recursive UI
import { component$, useStore, useSignal, useTask$ } from '@builder.io/qwik';
// Define the Node type
type Node = {
id: string;
name: string;
type: string;
tags: string[];
children?: Node[];
attributes?: Record<string, unknown>;
import { component$, useSignal, useVisibleTask$ } from '@builder.io/qwik';
export const ResumeBrowser = component$(() => {
const csr = useSignal(false);
// eslint-disable-next-line qwik/no-use-visible-task
useVisibleTask$(() => {
csr.value = true;
});
return csr.value ? <Slot /> : null;
});
/* Features */
// - remove cache headers for /q-data.json
export const handler = async (event, context) => {
try {
const [req, res, ctx, target] = eventNormalize(event, context); // 'ctx' is the context object
// Your business logic here
// Example of modifying the response based on URI
if (req.uri.endsWith('/q-data.json')) {
res.headers['cache-control'] = 'no-cache';
const { readable, writable } = new TransformStream();
fetch('/send?channel=123', method: 'POST',
headers: { 'Content-Type': 'text/plain' },
body: readable,
});
const response = await fetch('/receive?channel=123');
const response_readable = response.body;
const machine = useConst(() => {
return {
state: 'off',
_machine: undefined,
send: $((newState) => {
return this._machine ||= noSerialize(createMachine(this))).send(newState)
)
};
})