Skip to content

Instantly share code, notes, and snippets.

View darksinge's full-sized avatar

Craig Blackburn darksinge

View GitHub Profile
@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 / 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 / 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 / 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 / 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!";