Skip to content

Instantly share code, notes, and snippets.

View alexjyong's full-sized avatar

Alex Yong alexjyong

View GitHub Profile
@alexjyong
alexjyong / codespace_port_forward.sh
Created June 22, 2023 20:09
codespace_port_forward.sh
#!/bin/bash
#this script is meant to be ran on your local machine with gh installed.
#it is not meant to be ran within codespaces.
# this will select a codespace from a repo of your choosing and forward the ports to your
#local machine, so you can visit any process running on the codespace in your browser instead of going to the
# complex codespace generated url, which may break some code.
# this is pretty much the codespace version of this for gitpod https://www.gitpod.io/blog/local-app
# Function to clean up port forwarding processes
@alexjyong
alexjyong / HelpfulCommands.md
Created August 22, 2023 14:06
helpful commands

These are commands I've found helpful for day to day work.

Generally geared for *nix environments.

Nuke all docker resources on a machine.

docker rm -f $(docker ps -a -q) && docker rmi -f $(docker images -q) && docker volume rm $(docker volume ls -q) && docker network rm $(docker network ls -q) && docker system prune -a --volumes -f
@alexjyong
alexjyong / googleDriveList.py
Created August 23, 2023 01:57
get file list from google drive
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN_FROM_PLAYGROUND'
def bytes_to_human_readable(byte_size):
"""Convert bytes to human-readable file sizes."""
for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
if byte_size < 1024.0:
return f"{byte_size:.2f} {unit}"
@alexjyong
alexjyong / RestoreDeletedBranch.md
Last active October 25, 2023 19:30
Restore a deleted branch
  1. Fire up a codespace instance in the repo
  2. Run gh api repos/OWNER/REPO/events > myJson.json
  3. The JSON that comes out is unreadable, so clean it up with jq . myJson.json > clean.json
  4. Go through the json file, find the DeleteEvent where you nuked your branch, and below it, find the last push event you did to your branch. In the payload, find the head's SHA and grab it.
  5. Create a JSON file in this format
{
  "ref": "refs/heads/YOUR_BRANCH_NAME",
  "sha": "SHA_VALUE"
}
@alexjyong
alexjyong / MarsAndMoonTime.py
Created February 26, 2024 21:43
Script to calculate mars and moon time at a given location.
from datetime import datetime, timezone
import pytz
# Constants for Martian and Lunar day lengths in seconds
MARS_DAY_LENGTH = 88775.244
MOON_DAY_LENGTH = 2551442.8 # Average lunar day
# Function to get Earth time in a specific timezone
def get_earth_time(timezone):
tz = pytz.timezone(timezone)
@alexjyong
alexjyong / TheSims1Controller.icp
Created October 14, 2024 13:03
TheSims 1 Winlator Controller
{"id":5,"name":"TheSims1Controller","cursorSpeed":0.96,"elements":[{"type":"BUTTON","shape":"CIRCLE","bindings":["KEY_KP_ADD","NONE","NONE","NONE"],"scale":1,"x":0.8704261779785156,"y":0.8468809127807617,"toggleSwitch":false,"text":"➕","iconId":0},{"type":"BUTTON","shape":"CIRCLE","bindings":["KEY_MINUS","NONE","NONE","NONE"],"scale":1,"x":0.9306930899620056,"y":0.695652186870575,"toggleSwitch":false,"text":"➖","iconId":0},{"type":"BUTTON","shape":"RECT","bindings":["KEY_F2","NONE","NONE","NONE"],"scale":1,"x":0.9212225675582886,"y":0.27977314591407776,"toggleSwitch":false,"text":"🏗️","iconId":0},{"type":"BUTTON","shape":"RECT","bindings":["KEY_F3","NONE","NONE","NONE"],"scale":1,"x":0.9212225675582886,"y":0.42155009508132935,"toggleSwitch":false,"text":"🛍️","iconId":0},{"type":"BUTTON","shape":"ROUND_RECT","bindings":["KEY_P","NONE","NONE","NONE"],"scale":0.85,"x":0.059405941516160965,"y":0.10775047540664673,"toggleSwitch":false,"text":"⏯️","iconId":0},{"type":"BUTTON","shape":"ROUND_RECT","bindings":["KEY_F
@alexjyong
alexjyong / thesimsmoddinginfo.txt
Last active October 27, 2024 16:32
resources for The Sims modding (original game)
https://simstek.fandom.com/wiki/IFF
https://simstek.fandom.com/wiki/SimAntics
https://web.archive.org/web/20200602060602/http://simtech.sourceforge.net/tech/bhav.html
#!/bin/bash
echo "This will clean up all Docker resources on your instance."
echo "This is useful if you need to start fresh."
echo "This is also assuming you are running on a codespace instance. This hasn't been tested outside of that."
echo "This is irreversible. Are you sure you want to continue? (Y/N)"
read -r response
if [[ "$response" == "Y" || "$response" == "y" ]]; then