Skip to content

Instantly share code, notes, and snippets.

View windhooked's full-sized avatar

H windhooked

View GitHub Profile
package main
import (
"crypto/ecdh"
"crypto/rand"
"crypto/sha256"
"fmt"
"io"
"os"
package plugins
import (
"context"
"encoding/json"
"fmt"
"os"
"strconv"
sqlite_vec "github.com/asg017/sqlite-vec-go-bindings/cgo"
@windhooked
windhooked / accounting.sql
Created October 21, 2023 04:04 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@windhooked
windhooked / accounting.sql
Created October 21, 2023 04:03 — forked from ak4zh/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE account_groups
(
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
name text COLLATE pg_catalog."default" NOT NULL,
account_group_id bigint,
CONSTRAINT account_types_pkey PRIMARY KEY (id),
CONSTRAINT account_groups_account_group_id_fkey FOREIGN KEY (account_group_id)
REFERENCES public.account_groups (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
@windhooked
windhooked / migration.sql
Created October 21, 2023 04:03 — forked from ak4zh/migration.sql
Double Entry Book Keeping with Journals and Voucher
CREATE TABLE public.vouchers (
id serial PRIMARY KEY,
name text NOT NULL
);
INSERT INTO vouchers
(name)
VALUES
('Sales'),
('Purchase'),
@heetbeet
heetbeet / ChatGPT.md
Created March 17, 2023 07:24
VBA test valid South African ID

USER

Tell me how to check for valid South african ID numbers. Are there checksums? It starts with yymmdd so at least you know that 009999 is an invalid start. Write a list of all things that can be considered

ASSISTANT

Valid South African ID numbers follow a specific format and contain a few checks that can be used to determine their validity. Here is a list of things you can consider when checking the validity of a South African ID number:

  1. Length: A valid South African ID number should be 13 digits long.
  2. Birthdate: The first six digits should represent the birthdate of the person in the format YYMMDD. This means that an ID number starting with "009999" would be invalid as you mentioned.
  3. Gender: The 7th to 9th digits indicate the gender of the person. A value of 0000-4999 represents a female, while 5000-9999 represents a male.
  4. Citizenship: The 10th digit represents citizenship. A value of 0 indicates a South African citizen, while 1 indicates a permanent resident.
@up1
up1 / 1.txt
Last active November 20, 2024 07:56
NATS JetStream + Go
$docker-compose up
[+] Running 1/0
⠿ Container nat-js-nat-js-1 Created 0.0s
Attaching to nat-js-nat-js-1
nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859286 [INF] Starting nats-server
nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859416 [INF] Version: 2.8.4
nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859428 [INF] Git: [66524ed]
nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859442 [INF] Name: NBYAJSZUVNQHW4VUQZC2JDJX4QPECWSQTNJSXZAYKLL3IGTOFXART7FG
nat-js-nat-js-1 | [1] 2022/07/06 11:32:04.859460 [INF] Node: a7Zbpbhh
job "fail-service" {
datacenters = ["public-services"]
type = "service"
group "fail-service" {
count = 1
task "fail-service" {
driver = "docker"
@anti1869
anti1869 / nested_struct_join.go
Created August 4, 2018 19:27
Join two structs on foreign key relation with jmoiron/sqlx (nested json object from struct)
/*
Note: I have db.MapperFunc(FromCamelCaseToUnderScore)
This will make nested json like this
{
"likes": [
{
"chat_id": 155636374,
"created": "2018-08-04T10:52:36.360217Z",
@owulveryck
owulveryck / README.md
Last active August 1, 2021 17:06
Simple linear regression with plot in go with gonum

Very simple linear regression

curl -s //www.lauradhamilton.com/data_files/cricket_chirps_versus_temperature.txt | go run main.go > output.svg
2018/06/13 19:57:59 3.3057614388773593*x+24.966014428303183