Skip to content

Instantly share code, notes, and snippets.

@terabyte128
terabyte128 / rpn-calculator.rb
Last active October 30, 2019 20:09
A simple Reverse Polish Notation calculator written in Ruby. Equations can be entered interactively or as arguments.
def update_stack(stack, arg)
if /-?\d+(\.\d+)?/.match arg
stack.push arg.to_f
else
i1 = stack.pop
i2 = stack.pop
begin
result = i1.send(arg, i2)
stack.push result
@terabyte128
terabyte128 / GraphMain.java
Created March 5, 2018 22:49
Square Sum Solver
import org.graphstream.graph.Edge;
import org.graphstream.graph.Graph;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import javax.swing.*;
import javax.swing.Timer;
import java.awt.*;
import java.util.*;
@terabyte128
terabyte128 / lifx-control.py
Created July 16, 2018 01:31
quick n dirty way to play with lifx light colors
import tkinter
import lifxlan
class Application(tkinter.Frame):
def sendCommand(self, type, val):
try:
light = self.lights[int(self.selectedLight.get())]
except ValueError:
return
@terabyte128
terabyte128 / JekyllPublisher.py
Last active October 7, 2018 13:41
An easy way to manage your Jekyll website or blog (https://jekyllrb.com). Create new pages and blog posts with front matter already inserted; commit and publish to GitHub Pages.
#!/usr/local/bin/python3
# -*- coding: ascii -*-
import sys
import subprocess
import time
import argparse
def main():
parser = argparse.ArgumentParser(description="Create new Jekyll pages and publish to GitHub")
@terabyte128
terabyte128 / figure.py
Last active May 12, 2021 17:55
Generate cut list for 2x4s in Fusion 360.
#! /usr/local/bin/python3
# assumes the the BOM has been generated from https://github.com/macmanpb/CSV-BOM
# in 360: install plugin, "create" menu > create BOM, defaults should be fine
import csv
import argparse
boards = []
@terabyte128
terabyte128 / update_dns.py
Last active December 9, 2021 23:58
Update EdgeRouter local DNS entries from Traefik
import os
import re
from typing import Set
import requests
from requests.sessions import RequestsCookieJar
import urllib3
"""
Poll Traefik for changes to Host configurations, and update EdgeRouter config
@terabyte128
terabyte128 / ISOMetricProfileWithOffsets.xml
Last active June 12, 2023 04:23
Fusion 360 Custom Thread Offset Generator
<!-- this is a modified version of the XML file for ISO metric threads, with offsets of 0.1, 0.15, 0.2, and 0.25. -->
<!-- see https://github.com/thomasa88/ThreadKeeper for how to install -->
<?xml version='1.0' encoding='utf-8'?>
<ThreadType>
<Name>ISO Metric profile - Offsets</Name>
<CustomName>ISO Metric profile - Offsets</CustomName>
<Unit>mm</Unit>
<Angle>60</Angle>
<SortOrder>3</SortOrder>
<ThreadSize>
@terabyte128
terabyte128 / code_map.py
Last active April 12, 2024 03:53
map Eufy X10 Pro Omni modes to the code sent
from enum import Enum
class SmartMode(str, Enum):
ON = "on"
OFF = "off"
class Intensity(str, Enum):
FAST = "fast"