Skip to content

Instantly share code, notes, and snippets.

View Ciaran0's full-sized avatar

Ciaran O'Connor Ciaran0

View GitHub Profile
@revmischa
revmischa / zodMiddleware.ts
Created January 5, 2024 00:47
Zod + middy + AWS lambda API Gateway
import middy, { MiddlewareObj } from '@middy/core'
import httpErrorHandler from '@middy/http-error-handler'
import httpHeaderNormalizer from '@middy/http-header-normalizer'
import httpJsonBodyParser from '@middy/http-json-body-parser'
import { APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2, Handler } from 'aws-lambda'
import { zodValidator } from 'middy-zod-validator'
import { ZodSchema, z, infer as ZInfer } from 'zod'
import { isHttpError } from 'http-errors'
@ralph089
ralph089 / .wakeup
Last active February 17, 2024 09:56
Restarts Bluetooth Module on Mac OS X. You can use the script as shortcut to restart Bluetooth on demand or you can use it with "SleepWatcher" to automatically restart Bluetooth on wakeup (See README.md). I created it, because my Logitech Bluetooth Mouse doesn't stay connected after sleep-mode, so i had to manually re-pair my mouse.
#!/bin/bash
#
# Restart Bluetooth Module on Mac OS X
#
# Requires Blueutil to be installed: http://brewformulas.org/blueutil
BT="/usr/local/bin/blueutil"
log() {
echo "$@"
@AdamBrouwersHarries
AdamBrouwersHarries / LeftRecursionElimination
Created May 13, 2013 19:23
Eliminating left recursion from example
To begin with, the wikipedia left recursion algorithm is much eaiser to read: http://en.wikipedia.org/wiki/Left_recursion#Removing_indirect_left_recursion
So, we have the non-terminals A_1, and A_2:
A_1 -> A_2a | b
A_2 -> A_1c | ab
let's step through the algorithm:
i = 1
j = 1