Skip to content

Instantly share code, notes, and snippets.

@seth10
seth10 / scr.py
Created October 3, 2016 17:41
Calculate optimal configuration for Screeps creeps
import math
def roundUp(x,y):
return int(math.ceil(float(x)/y))
d = input('Distance: ') #10 #distance of path betweem source and controller
SPAWN_ENERGY_CAPACITY = 300
CONTROLLER_STRUCTURES = { "extension": { 3: 10 } }
STRUCTURE_EXTENSION = "extension"
EXTENSION_ENERGY_CAPACITY = { 3: 50 }
@seth10
seth10 / quote_regex.md
Last active October 8, 2022 03:30
A record of all the regular expressions I tried to match single and double quotes for LaTeX in FicBot

Single quotes

  1. / '([A-Za-z ]+)'(?=[^A-Za-z])/g -> `$1'

    Find a quote preceded by a space. Capture one or more letters or spaces. Find another quote. Lookahead to find a character that is not a letter. If the character following the last quote were a letter, it would be a contraction. The replacement string should have a leading space because we do capture a space before the first quote.

  2. /(\s|{)(?:')(.+?)(?:')(\s|})/g -> $1`$2'$3

    First big new attempt, see detailed explanation at 675e6a1. Capture a whitespace character or opening brace (from an italics or bold LaTeX command). Match a quote. Capture one or more of any character, but the least amount possible. Match a quote. Capture a whitespace character or closing brace. Put it back together with the captured whitepsace or braces at the ends and captured text between new quotes.

@seth10
seth10 / StepMania_resize.ahk
Last active March 20, 2022 16:31
AHK script to resize the StepMania window to not waste any vertical space
; Make repeated hotkey uses work, each time closing and re-launching StepMania, and only re-showing the task bar when the game is manually closed (instead of using the hotkey to relaunch it).
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force ; automatically replace old instance of script when launched again
#MaxThreadsPerHotkey 999 ; allows multiple instances of the hotkey subroutine to run, each temporarily halting the previous
@seth10
seth10 / SystematicLove.cpp
Created March 29, 2017 23:32
Systematic Love
#include <iostream>
#include <math.h>
const int HEART_SIZE = 20;
const int HALF_SIZE = HEART_SIZE / 2;
bool is_in_love(int x, int y);
int main(void)
{
@seth10
seth10 / SetDateCreatedToDateAdded.sh
Created December 21, 2018 20:25
A bash function to set the "Date Created" of a file to the macOS/Finder "Date Added"
SetDateCreatedToDateAdded () { SetFile -d "$(date -j -f '%Y-%m-%d %H:%M:%S' "$(mdls $1 | grep -w kMDItemDateAdded | awk '{print $3,$4}')" +"%m/%d/%Y %H:%M:%S")" $1; }
@seth10
seth10 / mediaquery.html
Created October 20, 2017 20:20
Hide "Back to top" links when printing a page
<p>
This is the top of the page. Pretend there is a ton of content here.
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
Here is the bottom.
Check out <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media">CSS media queries</a>.
</p>
<a href="#" class="back2top">Back to top<a>
<style>
class Motor(object):
def __init__(self):
pass
motorA = Motor()
motorB = Motor()
motorC = Motor()
motorD = Motor()
Motor.__init__ = lambda: None
del Motor
@seth10
seth10 / 14seg_minimal_example.ino
Last active September 8, 2017 16:28
All complete programs from watch repo
//https://raw.githubusercontent.com/seth10/watch/31f9083a07451147009f5e92a93645e02fa69217/14seg/14seg.ino
#include "Adafruit_LEDBackpack.h"
char *message = " Hello world! ";
Adafruit_AlphaNum4 alpha4;
void setup() {
alpha4.begin();
@seth10
seth10 / 00-MoistureCSV.py
Created August 1, 2017 19:37
A simple program to take readings for a moisture sensor on the PiStorms-GRX
# import some stuff we'll need
from GroveDevices import Grove_Moisture_Sensor
from PiStorms_GRX import PiStorms_GRX
import numpy as np
import time
# create a sensor (on port BAA1), the PiStorms object, and an empty list to hold the data
sensor = Grove_Moisture_Sensor("BAA1")
psm = PiStorms_GRX()
data = []
history | awk '{ print $2; }' | sort | uniq
#
alias
br
bt
cat
cd
chmod
clear
cp