Skip to content

Instantly share code, notes, and snippets.

View damieng's full-sized avatar
🏠
Working from home

Damien Guard damieng

🏠
Working from home
View GitHub Profile
@damieng
damieng / US-Damien-Alt-Custom.klc
Created January 21, 2024 09:32
My custom US Windows keymap with right alt symbol support for pound etc.
KBD USDamAlt "US Custom Alt-Symbols"
COPYRIGHT "None"
COMPANY "None"
LOCALENAME "en-US"
LOCALEID "00000409"
@damieng
damieng / info.json
Created January 20, 2024 12:01
My Mehkee96 layout
{
"keyboard_name": "mehkee96",
"url": "",
"maintainer": "qmk",
"layouts": {
"LAYOUT": {
"layout": [
{ "label": "Esc", "x": 0, "y": 0 },
{ "label": "F1", "x": 1, "y": 0 },
{ "label": "F2", "x": 2, "y": 0 },
@damieng
damieng / aws-lambda-send-brevo-recaptcha.js
Last active November 14, 2023 15:47
AWS Lambda mail sender via Brevo with Recaptcha
/* global fetch */
export const handler = async (event, context) => {
// Validate parameters
const { firstName, lastName, email, message, token } = JSON.parse(event.body)
if (!firstName || !lastName || !email || !message || !token) {
return { statusCode: 400, body: JSON.stringify({ statusMessage: "Missing required fields" })}
}
// Validate captcha
@damieng
damieng / DSK-image-ImHex.hexpat
Last active November 6, 2023 12:51
ImHex pattern for CPC/Spectrum DSK files
#pragma author DamienG
#pragma description Amstrad CPC/PCW, Sinclair ZX Spectrum +3 disk image
#pragma endian little
fn fdcSizeToByteCount(u8 sectorSize) {
return 2 << (sectorSize + 6);
};
fn getSectorDataSize(u8 sector) {
return parent.sectorInfo[sector].sectorDataSize;
@damieng
damieng / index.ts
Created October 24, 2023 21:42
Cloudflare function for creating a PR from a form post
import { stringify } from "yaml"
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// Make sure this is a POST to /post-comment
if (request.method !== "POST" || new URL(request.url).pathname !== "/post-comment") {
return new Response("Not found", { status: 404 })
}
// We only accept form-encoded bodies
@damieng
damieng / zx-font-publish.sh
Last active October 19, 2023 14:02
ZX Spectrum font publishing
#!/bin/bash
for i in "$@"
do
echo
echo Publishing ${i}
name="${i%.*}"
zip="${name}.zip"
rm -rf "${zip}"
# Folder cleanup
@damieng
damieng / zx-font-convert.sh
Last active October 19, 2023 14:00
ZX Spectrum font conversion script
#!/bin/bash
fl5reg="HKCU\Software\FontLab\Studio 5\Directories"
for i in "$@"
do
name="${i%.*}"
echo Processing $name
mkdir -p PC
psf="PC/${name}.psf"
vfb="PC/${name}.vfb"
@damieng
damieng / form-comments-to-pr.ts
Created October 17, 2023 19:13
Cloudflare function to receive a form for blog comments and create a PR
import { stringify } from "yaml";
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
// Make sure this is a POST to /post-comment
if (
@damieng
damieng / NamingHelpers.cs
Created August 14, 2023 07:17
Camel Case and Title Case with smart word boundaries for C#
using System.Globalization;
using System.Text.RegularExpressions;
namespace MongoDB.EntityFrameworkCore;
/// <summary>
/// A variety of helper methods for creating names.
/// </summary>
public static partial class NamingHelperMethods
{
@damieng
damieng / download-with-fetch.flow.js
Last active April 13, 2023 01:17
Download a file with progress indication using just window.fetch + node (FlowType version)
// @flow
import fs from 'fs';
// Public: Download a file and store it on a file system using streaming with appropriate progress callback.
//
// * `sourceUrl` Url to download from.
// * `targetFile` File path to save to.
// * `progressCallback` Callback function that will be given a {ByteProgressCallback} object containing
// both bytesDone and percent.