Skip to content

Instantly share code, notes, and snippets.

@kohenkatz
kohenkatz / .env
Created May 29, 2024 02:33
Laravel 10.x - Injecting the Twilio webhook validator only if we have the Auth Token configured.
# If this has a value, it enabled the validation check
TWILIO_VALIDATE_WEBHOOKS_TOKEN=
@kohenkatz
kohenkatz / main.go
Created March 12, 2023 17:58
Generate a self-signed certificate on demand for a Go server for http/2 (gRPC/connect)
package main
import (
"crypto/tls"
"net/http"
"os"
"strings"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
@kohenkatz
kohenkatz / tools.yml
Last active August 16, 2023 08:46
Opening Windows Terminal and VSCode from SmartGit
# Add these entries to your `tools.yml` to be able to right-click to open
# things in VSCode (files and folders) and Windows Terminal (folders only).
# Make sure to change `YOUR_USERNAME` in the VSCode path.
tools:
- name: Open in VSCode
fileStarter: {command: 'C:\Users\YOUR_USERNAME\AppData\Local\Programs\Microsoft VS Code\Code.exe',
parameters: '"${filePath}"'}
useForOpen: true
waitUntilFinished: false
@kohenkatz
kohenkatz / .env
Last active January 3, 2021 14:30
Using jackc/pgx to automatically send queries to the primary server
DATABASE_URL="host=db001,db002 port=5432 database=mydatabase user=myuser password=mypassword"
# The two `host` entries above are a primary and a replica in a cluster
# Change the order of the `host` entries and you will see that it always uses the primary
@kohenkatz
kohenkatz / install.xml
Created May 18, 2020 15:55
Product option prices by customer group OpenCart Extension for 3.x
<modification>
<notes><![CDATA[
This plugin is a conversion of https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=32403
to work with OpenCart 3.x in OCMOD format.
To use it, put this file into a ZIP file named "product-option-prices-by-customer-group.ocmod.zip"
(the important part is the `.ocmod.zip` extensions) and install it in your OpenCart.
YOU WILL ALSO NEED TO RUN THE FOLLOWING DATABASE COMMAND MANUALLY to create the extra column:
"ALTER TABLE product_option_value ADD COLUMN customer_group_id INT NOT NULL DEFAULT 0;"
]]></notes>
<name>Product_Option_By_Customer_Group</name>
@kohenkatz
kohenkatz / .gitlab-ci.yml
Last active May 14, 2020 20:22
Use GitLab CI to upload built Go binaries to a Nexus (raw) repository. Don't forget to define the four "UPLOAD_NEXUS_..." environment variables in the CI configuration
variables:
BIN_NAME: executable-name
ARTIFACTS_DIR: build
GO_PROJECT: example.com/go/project/module/path
GOFLAGS: -mod=readonly
GOPRIVATE: example.com/go/if/needed
GOBIN: ${CI_PROJECT_DIR}/bin
# Use this to install any binary tools needed
# and to create the output directory
@kohenkatz
kohenkatz / generate_ulid_text.sql
Created April 28, 2020 06:29
Postgres stuff for working with ULID
-- From https://github.com/geckoboard/pgulid/blob/d6187a00f66dca196cf5242588f87c3a7969df75/pgulid.sql
--
-- pgulid is based on OK Log's Go implementation of the ULID spec
--
-- https://github.com/oklog/ulid
-- https://github.com/ulid/spec
--
-- Copyright 2016 The Oklog Authors
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@kohenkatz
kohenkatz / script.js
Created May 16, 2019 01:44
UserScript to widen the Site Switcher dropdown in the Ubiquiti Unifi Controller
// ==UserScript==
// @name Widen Unifi Site Switcher
// @namespace http://tampermonkey.net/
// @version 0.1
// @description The Unifi Site Switcher defaults to 200px. We want it wider!
// @author Moshe Katz
// @match https://your.unifi.controller.domain/*
// @grant none
// ==/UserScript==
@kohenkatz
kohenkatz / phpcs.xml
Created August 8, 2018 16:16
PHPCS config for a Laravel project that uses tabs
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>PHP_CodeSniffer Standards</description>
<file>.</file>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/storage/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
@kohenkatz
kohenkatz / check_dns_dig.go
Created June 14, 2018 03:20
A nagios `check_dns` alternative that uses dig instead of nslookup
package main
import (
"bytes"
"fmt"
"os"
"os/exec"
"sort"
"strconv"
"strings"