Skip to content

Instantly share code, notes, and snippets.

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

Patrick Galbraith patrickgalbraith

🏠
Working from home
View GitHub Profile
@patrickgalbraith
patrickgalbraith / jsonpath.grammar
Last active May 31, 2024 00:17
JsonPath Lezer Grammar
//
// RFC 9535 JSONPath Grammar for Lezer
//
// Parses all selectors defined in https://github.com/jsonpath-standard/jsonpath-compliance-test-suite
// Note however it is a bit looser than the grammar defined in the standard when it comes
// to allowed escape characters and certain nested path segments.
//
@top Query { JsonPathQuery }

Simple PEG.JS grammer to parse logical expressions like:

test in(1, "2") and (flag = true or test ~ "test" or price >= 100.00 and (total > 100 or total < 200))

Which will output an AST that looks like:

{
@patrickgalbraith
patrickgalbraith / hack.diff
Last active May 12, 2023 00:48 — forked from JaySmithWpg/hack.diff
Hack to load custom depth map
diff --git a/modules/processing.py b/modules/processing.py
index 24c537d..0525cfd 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -156,20 +156,41 @@ class StableDiffusionProcessing():
return image_conditioning
def depth2img_image_conditioning(self, source_image):
- # Use the AddMiDaS helper to Format our source image to suit the MiDaS model
- transformer = AddMiDaS(model_type="dpt_hybrid")
@patrickgalbraith
patrickgalbraith / k12-system-routes.md
Last active March 7, 2019 23:26
Kentico 12 routes created by `Kentico().MapRoutes()` found by decompiling
CMSPages/GetDocLink.ashx
CMSPages/Newsletters/GetEmailBrowserContent.ashx
CMSPages/GetAzureFile.aspx
CMSPages/Scheduler.ashx
CMSPages/GetMetafile.aspx
getmetafile/{fileguid}/{filename}
CMSPages/GetFile.aspx
getfile/{nodeguid}/{filename}
cms/getfile/{nodeguid}/{filename}
@patrickgalbraith
patrickgalbraith / resize-images.bat
Last active February 5, 2019 06:24
Resize all images in a folder
@echo off
cls
set "resolution=1080"
for /f "tokens=* delims=" %%G in ('dir /A-D /B *.jpg') do (
ffmpeg -y -i "%%~G" -vf "scale='min(%resolution%,iw)':min'(%resolution%,ih)':force_original_aspect_ratio=decrease" "%%~G"
)
for /f "tokens=* delims=" %%G in ('dir /A-D /B *.png') do (
@patrickgalbraith
patrickgalbraith / package-version.bat
Created January 28, 2019 23:38
Extract package.json version in Windows Batch (.bat) file
@echo off
setlocal EnableDelayedExpansion
set c=0
set version=""
for /f "tokens=1,2 delims=:, " %%a in (' find ":" ^< "package.json" ') do (
if "%%~a"=="version" (
set version=%%~b
)
@patrickgalbraith
patrickgalbraith / uint-power.cs
Created September 21, 2018 14:02
UInt32 Power Function
uint UIntPow(uint x, uint pow)
{
if (x == 0 || x == 1)
return x;
if (pow >= 32)
throw new OverflowException("Power exceeds allowed size for UInt32");
uint ret = 1;
@patrickgalbraith
patrickgalbraith / gist:6a619576bfa2067334d365824878f051
Created September 7, 2018 04:49
Recreating create_function for PHP 7.2
<?php
// WARNING - You should always ensure that the code cannot be updated
// using an anonymous function before using this
function createCallback($paramList, $code) {
$callback = create_function($paramList, $code);
return $callback;
}
@patrickgalbraith
patrickgalbraith / AutoHeightWebView.js
Last active September 19, 2018 12:05
Auto Height React Native WebView with custom link handling
/*
Copyright 2017 Patrick Galbraith
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 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
@patrickgalbraith
patrickgalbraith / AccelerometerTest2.c
Created September 16, 2017 03:50
AccelerometerTest2
const int analogPin = A0;
const int ledPin = 14;
int analogPinVal = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}