Skip to content

Instantly share code, notes, and snippets.

View darksinge's full-sized avatar

Craig Blackburn darksinge

View GitHub Profile
@darksinge
darksinge / MyClass.cs
Created April 21, 2018 22:04
StartCoroutine from class that doesn't inherit from MonoBehavior
class MyClass {
MyClass() {
APIManager manager = GameObject.FindWithTag("APIManager").GetComponent<APIManager>();
manager.StartCoroutine(MyFunction());
}
IEnumerator MyFunction() {
yield return "Hello World!";
@darksinge
darksinge / Jugs.py
Last active September 21, 2018 04:04
The Jug Algorithm for Discrete Math - MATH 3310, USU
# Credit for gcd() method - https://stackoverflow.com/questions/11175131/code-for-greatest-common-divisor-in-python
def gcd(a, b):
"""Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when
b is divided by it, the result comes out positive).
"""
while b:
a, b = b, a % b
return a
@darksinge
darksinge / simple_encryption.py
Created September 26, 2018 02:19
Simple Encryption
encode_table = {
'a': "01",
'b': "02",
'c': "03",
'd': "04",
'e': "05",
'f': "06",
'g': "07",
'h': "08",
'i': "09",
@darksinge
darksinge / multiprocessing_example.py
Last active November 2, 2018 21:59
Example of using the multiprocessing module in Python to fully utilize a CPU with 'n' cores.
import multiprocessing
from threading import Thread
import random
import string
class ThreadWorker(Thread):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@darksinge
darksinge / eeprom.py
Last active May 19, 2019 21:02
Python script to control a Raspberry Pi's GPIO pins for programming an EEPROM (work in progress...)
import RPi.GPIO as GPIO
import os
import time
import math
usleep = lambda x: time.sleep(x / 1000000.0)
GPIO.setwarnings(False)
@darksinge
darksinge / nginx.stuff
Created January 24, 2020 20:44
NGINX Config Example
# /etc/nginx/nginx.conf
http {
...
include /etc/nginx/sites-available/*.conf # Include all config files that end in .conf
...
}
# /etc/nginx/sites-available/example.com.conf
server {
listen 80 default_server;
@darksinge
darksinge / cloudSettings
Last active June 4, 2020 20:13
cloudSettings
{"lastUpload":"2020-06-04T20:13:28.728Z","extensionVersion":"v3.4.3"}
@darksinge
darksinge / DOCKER_CHEAT_SHEET.md
Last active October 2, 2023 18:40
Kubernetes Cheat Sheet (and minikube, docker, kubectl, eksctl, and AWS ECR)

Docker Commands

  • docker exect -it myimage /bin/bash
  • docker build --tag myimage:tag_name .
  • docker container attach myimage
  • docker run -itd --name <name> --network <network> --publish 80:8080 myimage:tag
  • docker image tag myimage myrepo/myimage:tag
  • docker image push myrepo/myimage:tag
@darksinge
darksinge / trigger.sh
Created August 24, 2020 21:40
How to manually trigger a GitHub Action through the GitHub API
#!/usr/bin/env bash
# Get the <token> through the GitHub website:
# 1. Go to Settings->Developer Settings->Personal access tokens
# 2. Create a token with the 'repo' scope selected.
# https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
# The value for "event_type" should match "on.repository_dispatch.type" in workflow.yaml.
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
@darksinge
darksinge / eslint-and-prettier-setup.md
Last active October 5, 2022 16:10
Eslint+prettier setup

Typescript Setup (npm)

Install dependencies

$ npm i --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin prettier eslint-config-prettier eslint-plugin-prettier

.eslintrc.js

module.exports = {