Skip to content

Instantly share code, notes, and snippets.

View eritbh's full-sized avatar

Erin eritbh

View GitHub Profile
@eritbh
eritbh / resourcemon.lua
Created November 22, 2023 02:39
computercraft thingy
View resourcemon.lua
-- Aggregates status information for all peripherals connected to networked computers.
local pretty = require("cc.pretty")
local DISPLAY_REFRESH_DELAY = 0.1
local DATA_REFRESH_DELAY = 0.1
local BROADCAST_DELAY = 0.1
-- Connect to rednet on all modems
peripheral.find("modem", rednet.open)
View README.md

awaitButton.ts

A sample interaction awaiter that specifically only cares about button interactions with globally unique custom IDs.

Can be modified to respond differently to other conditions (i.e. only letting a specific user click the button, or handling other sorts of components). If that's what you want to do, you'll want to modify the buttons data structure to hold information about your custom conditions, and add logic within the interactionCreate listener to only call the associated resolver function when necessary.

This is a naive implementation, with several potential issues:

  • listening is a global variable, not directly associated with the client the listener is being added to (though you really shouldn't have multiple clients in your project anyway so it's probably fine)
  • Using an object for buttons means that only one person can listen for a specific customID at a time; this code will just overwrite the old listener if it's called a second time with the same ID, causing the ol
@eritbh
eritbh / wsl-vcxsrv-quickstart.md
Created January 19, 2022 02:32
Run desktop applications under WSL and display them with VcXsrv
View wsl-vcxsrv-quickstart.md

First setup:

  • Install VcXsrv (https://sourceforge.net/projects/vcxsrv/)

  • Launch it (shows up in windows search as "XLaunch"), it will prompt you for some configuration

    • "Select display settings" sets how you want your WSL applications to be presented on the desktop, set these options however you like
    • "Select how to start clients" can be left at "Start no client"
    • On the "Extra settings" screen, tick "Disable access control" (or, if you don't trust your local network, have fun figuring out X authorities I guess)
    • Save your configuration to a file - this will be handy later
View Deal with Illustrator SVG fonts.md

Dealing with Illustrator SVG Fonts

tldr: using specific save settings in illustrator and a script, we can generate an SVG file that uses embedded CSS web fonts and can have its text content edited dynamically (this just solves the font display problem, not the text alignment discrepancies introduced by the way text is layed out in the SVG, that will have to wait). Check it out - all the fonts in this processed SVG image show up just fine in Firefox and are being loaded from embedded data: URIs rather than system fonts.

image

This is how I'm saving my illustrator file:

image image

@eritbh
eritbh / op-add-identities
Last active June 8, 2023 15:44
1password SSH identity management helpers
View op-add-identities
#!/bin/bash
echo "Signing into 1password..."
eval $(op signin $@)
items=($(op list items | jq '.[] | select(.templateUuid == "110") | .uuid' --raw-output))
for uuid in "${items[@]}"; do
item_data="$(op get item "$uuid")"
private_key="$(echo "$item_data" | jq '.details.sections[0].fields[] | select(.t == "ssh private key") | .v' --raw-output)"
item_title="$(echo "$item_data" | jq '.overview.title' --raw-output)"
@eritbh
eritbh / README.md
Last active February 13, 2022 17:15
Setting up a new deploy user and automating deployment tasks through Github Actions
View README.md

Continuous deployment with Github Actions and systemd services

This is a collection of templates/scripts I use to set up CD systems for my projects.

For each project I deploy, I create a user and a systemd service. The user account's home directory is where the project lives, and the systemd service defines how it's run and ensures that it stays running after failure or reboot. The user is given sudo permission only to interact with its own service, via a /etc/sudoers.d supplement. The user account isn't accessible via password auth, but it does have an SSH key that can be used to log into the account and automate updates.

deploysetup.sh automates this process. It creates a new user, configures its sudo and SSH permissions, generates an SSH key for it, and creates a template systemd service. After running the script, all I have to do is clone the project into the deploy user's home directory and configure the systemd service to run the project.

The actual CD is handled by a Github Actions workflow

View -etc-systemd-system-animeawards.service
[Unit]
Description=Web: Anime Awards Site
ConditionPathExists=/home/george/animeawards-mkii
After=network.target
[Service]
Type=simple
LimitNOFILE=1024
Restart=on-failure
View Ariake Dark.xccolortheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.960784 0.980392 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>JetBrainsMono-Bold - 12.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.72549 0.745098 0.835294 1</string>
View id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJ/z3GFDb69oD3Ww+cEbpLUkLI1OWpGULEEitbLDo3wbvbi9A3YGmpDRGnXAgs4DpOW91XxZldDuR/7HbhAO2OPY/EgcJgVk+SPdL1bSoIIAAWJacPLk+qvgcUZk1Gf7NXD7NiT0HJHj9BVdHePzCYxavt6z8NoVGl0iCF1FbjwxyEi1cr9KFUS+QOg33TUclVIap1ypyO/MeVNZ9XogT4Z1MQIeHRKkYZMq1kfvWQZOzBYM3Gu84fn2fTyRfZCde0IHVAVZtTDm8PMBYy0ukKL0OtSHzi0BEg6pTnAL0ZkCmDpBLOCM1pwoYR+4u9azp/RBp0CAmrbFHiFPjUXhJ1 george@piina.local
@eritbh
eritbh / README.md
Last active August 25, 2019 14:55
Fizzbuzz
View README.md

Fizzbuzz

The classic programming exercise.

The Rules

For every integer in some range:

  • Print "fizz" if the number is divisible by 3
  • Print "buzz" if the number is divisible by 5