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 / 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 / mehkee96damieng.json
Created March 11, 2023 01:54
My Mehkee 96 custom map
{
"version": 1,
"notes": "",
"documentation": "\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n",
"keyboard": "mehkee96",
"keymap": "mehkee96_layout_mine",
"layout": "LAYOUT",
"layers": [
[
"KC_ESC",
@damieng
damieng / BinarySubset.cs
Created February 3, 2023 15:31
Find matching binary parts of a file regardless of offset
namespace BinarySubset
{
internal class Program
{
static void Main(string[] args)
{
const int minBytes = 15;
const int minUniques = 5;
var uniqueBytes = new bool[256];
@damieng
damieng / slack-invite-process.py
Created February 3, 2023 15:27
Process Slack Invite JSON
#!/usr/bin/env python3
from collections import defaultdict
from json import loads
from sys import argv, stdin
from pprint import pprint
inviters = defaultdict(list)
for invite in loads(stdin.read()):
inviters[invite['invitedBy']].append(invite['user'])