Skip to content

Instantly share code, notes, and snippets.

View lantrix's full-sized avatar
:octocat:
always coding and merging

Ted B lantrix

:octocat:
always coding and merging
View GitHub Profile
@lantrix
lantrix / refresh-music-selection.scpt
Created July 3, 2023 12:00 — forked from Kautenja/refresh-music-selection.scpt
An applescript to refresh the metadata of a selection in the Apple Music application (with progress bar)
tell application "Music"
-- get the selection
set theSongs to selection
end tell
-- setup the progress bar
set theSongCount to length of theSongs
set progress total steps to theSongCount
set progress completed steps to 0
set progress description to "Refreshing Songs..."
# Backend
# You should always check the release notes/changelog in case there are config deprecations, special update steps, etc.
# https://gitlab.com/soapbox-pub/rebased/-/blob/main/CHANGELOG.md
cd /opt/pleroma/
sudo -Hu pleroma bash -i
git pull #on main branch
MIX_ENV=prod mix deps.get # pulls in any new dependencies
exit # back to user
sudo systemctl stop pleroma.service
sudo -Hu postgres pg_dump -d pleroma --format=custom -f /tmp/pleroma.pgdump
@lantrix
lantrix / token.sh
Last active November 13, 2022 09:32
Generate a JWT from a GitHub App for REST API access by your App
# Install JWT Creator https://github.com/trstringer/jwt-creator
go install github.com/trstringer/jwt-creator@latest
# Download GitHub App Private Key as $HOME/app.pem
# https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#generating-a-private-key
# Generate public key from GitHub App Private Key
openssl rsa -in "$HOME/app.pem" -pubout -out "$HOME/app.pub"
# Generate JWT
@lantrix
lantrix / README.md
Last active July 4, 2023 06:12
If you have unsigned commits on a branch, you can re-sign them with your GPG uploaded key. Requires GH CLI, gpg installed.

The base branch requires all commits to be signed If you need to setup GPG, you can read our helpful guide.

Then once you have:

  • gpg installed
  • GitHub CLI installed (optional but useful)
  • a key generated for your Name and email, in this example: Lantrix myemail@mydomain.com
  • your gpg public key uploaded to GitHub
  • You can rebase and re-sign all the commits and force push the branch as a potential solution.
@lantrix
lantrix / 21-struct-methods.go
Last active August 22, 2022 08:26
How to use interfaces in golang from https://www.youtube.com/watch?v=lh_Uv2imp14
package main
import "fmt"
type Box struct {
name string
colors []int
age int
}
@lantrix
lantrix / Dockerfile.distroless
Created June 21, 2021 06:25
Compile and run a simple C Hello World app using Docker scratch & Distroless
FROM ubuntu:latest as builder
WORKDIR /build
ADD . /build
RUN apt-get update && apt-get -y install build-essential
RUN gcc -o hello -static -nostartfiles hello.c
# Now copy it into our base image.
FROM gcr.io/distroless/static-debian10

Invoke using Python with pyenv

Requires Python 2.7.x

Using pyenv and the pyenv-virtualenv plugin means you can install the required python version (2.7.x) and packages will not be installed in your global packages, but rather locally in a virtual environment.

cd data_loaders
pyenv local
pyenv -m venv .data
@lantrix
lantrix / dendrite
Created January 31, 2021 13:46
Matrix server dendrite rc.d script for OpenBSD
#!/bin/ksh
daemon="/usr/local/bin/dendrite-monolith-server"
rc_reload=NO
rc_bg=YES
. /etc/rc.d/rc.subr
pexp="/usr/local/bin/dendrite"
@lantrix
lantrix / brew-downgrade.sh
Last active May 10, 2023 08:04
Install an older version with Brew as @ Jan 2021
# remove latest
brew uninstall terraform
# create a local tap for old version - The brew tap-new <org>/<repo> does not have to be an actual repo.
brew tap-new lantrix/an-older-terraform
#extract old version forumla
brew extract --version 0.13.5 terraform lantrix/an-older-terraform
# Install old formula
@lantrix
lantrix / ec2.tf
Created December 24, 2020 11:11
Terraform instance
provider "aws" {
region = "ap-southeast-2"
}
data "aws_ssm_parameter" "ami" {
name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs"
}
resource "aws_instance" "test-terraform" {
instance_type = "t2.nano"
ami = data.aws_ssm_parameter.ami.value
}