Skip to content

Instantly share code, notes, and snippets.

View Integralist's full-sized avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / 1. README.md
Last active November 10, 2024 14:12
[Bitwise Operations in Go] #go #golang #bitwise #bit

Bitwise Operations in Go

In the below Go file we use bitwise operators to manipulate individual flags (on/off switches) in a single integer, where each bit position represents a different status.

Visualising Bits

In case you need a reminder of a what bit alignment and shifting look like:

example of bits in a byte

@Integralist
Integralist / server.log
Created November 4, 2024 06:38
Fastly Code Test Asset
11 02 08:24:01 "GET /index.html" 400 152
11 02 08:24:03 "POST /api/login" 201 98
11 02 08:24:05 "GET /images/logo.png" 404 134
11 02 08:24:07 "DELETE /api/resource/123" 204 65
11 02 08:24:09 "PUT /api/item" 400 189
11 02 08:24:10 "PATCH /api/user/profile" 200 102
11 02 08:24:12 "GET /products" 400 115
11 02 08:24:14 "POST /api/order" 201 177
11 02 08:24:16 "GET /about" 200 98
11 02 08:24:18 "DELETE /api/cart/1" 200 145
@Integralist
Integralist / Go Concurrency.md
Last active November 4, 2024 07:44
[Go concurrency] #go #golang #concurrency
@Integralist
Integralist / README.md
Last active October 22, 2024 15:18
[Custom wireless battery alerts for mouse and keyboard] #macos #automator #notifications #battery

Note

The whole reason I bothered doing this is because I hate it when macOS notifies me that my mouse is "critically" low on charge, as it forces me to have to stop work for charging my mouse. I'd prefer to know at around 50% charge so I can continue working but stick my mouse on charge when I go for lunch or finish my day.

Start by writing an AppleScript file that is essentially just a wrapper around a bash script...

do shell script "
# Get the battery percentage for the Magic Mouse
mouseBattery=$(ioreg -c AppleDeviceManagementHIDEventService -r | grep -i '\"Product\" = \"Magic Mouse\"' -A 20 | grep '\"BatteryPercent\" =' | awk '{print $NF}')
@Integralist
Integralist / 1. README.md
Last active October 18, 2024 11:43
[Custom DNS resolution in Golang] #go #golang #dns
$ go run main.go

Querying root server 198.41.0.4 for TLD com...
Selected TLD server: g.gtld-servers.net.
Resolved TLD server IP: 192.42.93.30
Querying TLD server 192.42.93.30 for domain coca-cola.com...
Selected authoritative server: ns4-09.azure-dns.info.
Resolved authoritative server IP: 208.84.5.9
Querying authoritative server 208.84.5.9 for domain coca-cola.com...
@Integralist
Integralist / 1. codesign.sh
Last active October 17, 2024 14:29
[Codesign a Go test binary that listens on network and needs to accept incoming network connections] #codesign #localdev #go #golang
# 0. Have a binary to codesign.
# NOTE: I use `if os.Getenv("SKIP_FTP") != "" { t.Skip("...") }` to allow skipping the test when running the full test suite.
go test -c -o ./path/to/package/test_binary ./path/to/package
# 1. Create self-signed private key and certificate
# IMPORTANT: The `-addext` flags are essential for codesigning purposes.
openssl req -new -x509 -days 365 -nodes \
-keyout ExampleTestBinaryCodeSigning.key -out ExampleTestBinaryCodeSigning.crt \
@Integralist
Integralist / OpenSSL Essentials.md
Last active October 8, 2024 10:50
[OpenSSL Essentials: Working with SSL Certificates, Private Keys and CSRs] #openssl #ssl #tls #certs #csr

https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrs

OpenSSL Essentials: Working with SSL Certificates, Private Keys and CSRs

OpenSSL is a versatile command line tool that can be used for a large variety of tasks related to Public Key Infrastructure (PKI) and HTTPS (HTTP over TLS).

Certificate Signing Requests (CSRs)

If you would like to obtain an SSL certificate from a commercial certificate authority (CA), you must generate a certificate signing request (CSR). A CSR consists mainly of the public key of a key pair, and some additional information. Both of these components are inserted into the certificate when it is signed.

@Integralist
Integralist / proxy.go
Created September 20, 2024 09:36
[local SSH tunnel using google cloud] #go #golang #ssh #tunnel
// Package main is the entrypoint to the proxy CLI program.
package main
import (
"bytes"
"context"
"errors"
"flag"
"fmt"
"io"
@Integralist
Integralist / dependencies.yaml
Created September 12, 2024 07:15
[GitHub Actions update app dependencies daily] #ci #gha #github #actions #cron #go #golang
name: Update Dependencies and Run Tests
on:
# Schedule to run at 9am UTC every day
schedule:
- cron: '0 9 * * *'
# Allow manual trigger via GitHub UI
workflow_dispatch:
@Integralist
Integralist / What is a SKU.md
Created September 4, 2024 15:57
[What is a SKU] #sku

SKU stands for stock-keeping unit.

It is mostly the unit used by Salesforce, and all other business systems to 'sell' and invoice for products/features we sell

It can take up to a quarter or more to get a SKU.

You can't sell something for $$ without a SKU.

Monetization engineering often won't get started on any work without a SKU/product description in Salesforce.