Skip to content

Instantly share code, notes, and snippets.

@Howard3
Howard3 / reverse_slice.go
Created February 4, 2024 04:12
sample reverse slice
package main
import (
"slices"
)
const ToReverse = "Hello World!"
const iterations = 10_000_000
func main() {
@Howard3
Howard3 / README.md
Last active July 5, 2024 08:17
Postgres - fix sequences after importing data

This script is designed to help reset all sequences in a PostgreSQL database to their correct values based on existing data in the tables.

Purpose

In PostgreSQL, sequences are used to auto-increment integer columns in tables. These sequences need to have their "last value" accurately set to avoid conflicts when inserting new rows into the table. This can become an issue, for example, when data is imported into the database and the sequences are not updated accordingly, leading to unique constraint

How it Works

The script works by iterating over each table in the current schema of the PostgreSQL database. For each table, it dynamically looks up the associated sequence and the column that the sequence is used for. It then finds the maximum value in that column and sets the "last value" of the sequence to this maximum value.

@Howard3
Howard3 / typeahead_result.gohtml
Created May 11, 2023 15:09
HTMX/AlpineJS TypeAhead.
{{define "content"}}
<div id="results">
{{if or .Notice .Error}}
{{if .Error}}
<div
class="alert flex rounded-lg border border-error px-4 py-4 text-error sm:px-5"
>
{{.Error}}
</div>
{{else}}
@Howard3
Howard3 / gh_us_nav_packages.js
Last active May 10, 2023 12:26
github_nav_packages_tab userscript
// ==UserScript==
// @name Github Packages Tab
// @description Adds a Packages tab to Github repository navigation bar.
// @version 1
// @grant none
// @match https://github.com/*
// @license MIT
// @author Howard D. Lince III
// @supportURL https://twitter.com/HowardL3
// @namespace https://github.com/howard3
@Howard3
Howard3 / github_copy_tag_button.js
Last active May 3, 2023 01:20
userscript - Github: Add "Copy" button next to package tags
// ==UserScript==
// @name GitHub Docker Image Tag Copy Button
// @description Adds a "copy" icon next to each Docker image tag on GitHub pages that list published Docker images.
// @version 2
// @match https://github.com/*
// @grant GM_setClipboard
// @require https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js
// @license MIT
// @author Howard D. Lince III
// @supportURL https://twitter.com/HowardL3
@Howard3
Howard3 / myriade-hashrate-checker.go
Last active June 2, 2021 03:59
Check your recent hashrate, throw an error if it's low.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
)