Skip to content

Instantly share code, notes, and snippets.

@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 / 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
- # Find the index of the blob with the most pixels.
- most_pixels = 0
- largest_blob = 0
- for i in range(len(blobs)):
- if blobs[i].pixels() > most_pixels:
- most_pixels = blobs[i].pixels()
- largest_blob = i
+ # Find the blob with the most pixels.
+ largest_blob = max(blobs, key=lambda b: b.pixels())
@seth10
seth10 / 11-KeyboardLEDs.py
Created July 10, 2017 12:04
Functional programming example on the PiStorms
from PiStorms import PiStorms
from TouchScreenInput import TouchScreenInput
from functools import partial
psm = PiStorms()
textbox = TouchScreenInput(psm.screen)
textbox.bind_led_on_func(partial(psm.led, 1, 255, 0, 0))
textbox.bind_led_off_func(partial(psm.led, 1, *[0]*3))
result = textbox.getInput()
psm.screen.showMessage(['Your answer', result['response']])
@seth10
seth10 / PiStorms_Development.sh
Last active June 27, 2017 20:06
A script to link files in /home/pi/PiStorms to their corresponding locations in the system
b=`grep homefolder /usr/local/mindsensors/conf/msdev.cfg | cut -d"=" -f2 | cut -c 2-`
for f in 'MSDriver.py' 'MSBrowser.py' 'psm_shutdown' 'swarmserver' 'pistorms-diag.sh'; do sudo ln -f $b/sys/$f /usr/local/bin/$f; done
chmod +x $b/sys/swarmserver $b/sys/pistorms-diag.sh $b/programs/addresschange
for f in 'rmap.py' 'rmapcfg.py' 'scratch.py' 'PiStorms.py' 'PiStormsCom.py' 'TouchScreenInput.py' 'mindsensorsUI.py' 'MS_ILI9341.py' 'mindsensors.py' 'MsDevices.py' 'LegoDevices.py' 'swarmclient.py'; do sudo ln -f $b/sys/$f /usr/local/lib/python2.7/dist-packages/$f; done
sudo rm -rf /var/www
sudo ln -s $b/www /var/www
sudo ln -f $b/sys/msdev.cfg /usr/local/mindsensors/conf/msdev.cfg
# skipping images, art, scratch, changing ownerships... programs are still only in /home/pi/PiStorms
for f in 'MSDriver.sh' 'MSBrowser.sh' 'MSWeb.sh' 'SwarmServer.sh'; do sudo ln -f $b/setup/$f /etc/init.d/$f; done
for f in 'MSDriver.sh' 'MSBrowser.sh' 'MSWeb.sh' 'SwarmServer.sh'; do chmod +x $b/setup/$f; done