Skip to content

Instantly share code, notes, and snippets.

View alairock's full-sized avatar

Skyler Lewis alairock

View GitHub Profile
@alairock
alairock / pgpass.ts
Created July 8, 2024 20:03
PGPass file reader, typed for TS, Node, JS
import * as path from "path"
import fs from "fs/promises"
import { getLogger } from "../logging"
/**
* The default port number for PostgreSQL database connections.
*/
const defaultPort = 5432
@alairock
alairock / SHNight.go
Created February 6, 2024 05:22
Secret Hitler Night Phase Code
package sh
import (
"errors"
"math/rand"
)
type Game struct{}
type GameState struct {
@alairock
alairock / work-time.py
Created October 26, 2023 23:06
Calculation of clocking in, minute-by-minute, vs rounding.
import random
import numpy as np
import matplotlib.pyplot as plt
# Initialize variables for multiple tests
num_tests = 10000
differences = []
# Loop for each test
for test in range(num_tests):
@alairock
alairock / serial.rs
Created August 23, 2020 00:54
Serial Reader in Rust with cli for selecting open ports
// [dependencies]
// serialport = "3.3.0"
// dialoguer = "0.6.2"
use serialport::{available_ports, SerialPortType};
use crate::serial;
use dialoguer::theme::ColorfulTheme;
use dialoguer::Select;
use std::io;
@alairock
alairock / ProMicroDebouncePulseAndClock.ino
Created July 17, 2020 19:49
This is the code for a single button, debounced, pulse/variable-clock combo.
int RXLED = 17;
int TXLED = 30;
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 16; // the number of the pushbutton pin
const int ledPin = 10; // the number of the LED pin
// Variables will change:
int ledState = HIGH; // the current state of the output pin
int buttonState; // the current reading from the input pin
SMALL = 1
MED = 2
LARGE = 3
s = list(range(1, 31))
m = list(range(31, 61))
l = list(range(61, 91))
print(s)
print(m)
from bs4 import BeautifulSoup
import requests
url = "https://www.azjobconnection.gov/ada/r/search/jobs?utf8=%E2%9C%93&per_page=50&keywords=Python&refiners=%7B%7D&is_subsequent_search=false&status=Active"
r = requests.get(url)
soup = BeautifulSoup(r.content, features="html.parser")
jobs_to_look_at = []
@alairock
alairock / database.py
Created November 27, 2019 23:57
Example database file
import asyncpg
import asyncio
DATABASE_POOL = None
async def get_connection_pool():
if DATABASE_POOL is None:
await asyncio.sleep(1)
return await get_connection_pool()
@alairock
alairock / lastfm_cleaner.py
Last active December 20, 2023 04:07
Clean out comedians from lastfm
import pylast
import secretstorage
import requests
from pycookiecheat import chrome_cookies
##########
# CONFIG #
##########
# You have to have your own unique two values for API_KEY and API_SECRET
# Obtain yours from https://www.last.fm/api/account/create for Last.fm
@alairock
alairock / block.py
Created January 7, 2019 02:46
Simple Python Decentralized Ledger
import hashlib as hasher
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
self.hash = self.hash_block()