Skip to content

Instantly share code, notes, and snippets.

View haynesgt's full-sized avatar

Gavin Haynes haynesgt

View GitHub Profile
@haynesgt
haynesgt / disable-caps.reg
Created January 26, 2024 19:00
Disable Caps Lock Windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,00,00,3a,00,00,00,00,00
@haynesgt
haynesgt / cacher.py
Created January 8, 2024 23:00
File based cacher for python scripting
import asyncio
import hashlib
import json
import os
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime
from functools import wraps
from typing import Any, Union
from pydantic import BaseModel
@haynesgt
haynesgt / gist:c73686213d816be7d39457f2268a7f8d
Created January 31, 2023 01:01
pubsub ordering key testing
from random import randint
from google.cloud.pubsub_v1 import SubscriberClient, PublisherClient
from google.cloud.pubsub_v1.types import PublisherOptions
from google.pubsub_v1.types.pubsub import (
AcknowledgeRequest,
ModifyAckDeadlineRequest,
PubsubMessage,
PullRequest,
PullResponse,
)
@haynesgt
haynesgt / app-search-cli-xxl
Created September 2, 2021 22:45
App Search CLI for super-large newline-delimited json
#!/usr/bin/env node
/**
* Install:
*
* Download this file and give it executuable persmissions
*
* Usage:
*
* Uploading documents
@haynesgt
haynesgt / elasticsearch_index_to_dsl_document.py
Last active July 28, 2021 23:41
Creates documents for elasticsearch_dsl
from inspect import isclass
import json
import sys
import elasticsearch_dsl.field
def snake_to_camel(word):
return ''.join(x.capitalize() or '_' for x in word.split('_'))
@haynesgt
haynesgt / webPrompt.js
Last active January 4, 2021 23:28
Node prompt for value via form
const http = require("http");
const url = require("url");
const open = (() => {
try { return require("open"); } catch (e) { }
})();
function webPrompt(prompt = "Value", type = "text") {
return new Promise((resolve, reject) => {
const server = http.createServer((req, res) => {
if (req.method === "GET") {
@haynesgt
haynesgt / cross-fractal.js
Created April 18, 2018 04:28
Cross Fractal
document.body.innerHTML = "";
var c = document.createElement("canvas");
document.body.appendChild(c);
c.width = c.height = 1024;
var ctx = c.getContext("2d");
var alpha = 3 / 8;
var beta = 1 - alpha;
ctx.strokeStyle = "#FF0000";
for (n = 5; n <= 10; n++) { for (i = 0; i < c.width - 1; i += 2**n) for (j = 0; j < c.height - 1; j += 2**n) { ctx.moveTo(i + 2**(n-1), j + 2**(n) * alpha); ctx.lineTo(i + 2**(n-1), j + 2**n * beta); ctx.moveTo(i + 2**(n) * alpha, j + 2**(n - 1)); ctx.lineTo(i + 2**(n) * beta, j + 2**(n - 1)); } }
ctx.stroke();
@haynesgt
haynesgt / app.js
Created February 9, 2017 01:00
Anguler 1.5.9, bridge dependency's provider with app provider
angular.module('registrations', [])
.provider('registrations', function() {
console.log('New registrationsProvider');
this.$get = function() {
console.log('Get registrations');
};
});
angular.module('app', ['registrations'])
.provider('myRegistrations', function() {