Skip to content

Instantly share code, notes, and snippets.

from scrollkit import *
offset = 0
def c(x, y):
factor = WIDTH/2 + (WIDTH/2 * sin(get_time()%50))
v = sin(x / factor) + sin(y / factor)
h = 180 + (180 * v)
h = (h+offset)%360
@rsayers
rsayers / yamanote.py
Created May 9, 2022 14:12
Simple terminal quiz game to learn the Yamnote Line stops and their Kanji
import random
stations = {}
stations["Shinagawa"] = "品川"
stations["Ōsaki"]="大崎"
stations["Gotanda"]="五反田"
stations["Meguro"]="目黒"
stations["Ebisu"]="恵比寿"
stations["Shibuya"]="渋谷"
stations["Harajuku"]="原宿"
import discord
import asyncio
import subprocess
from humanfriendly import format_timespan
import datetime
startup = datetime.datetime.now()
client = discord.Client()
@rsayers
rsayers / mand.f95
Created June 13, 2019 15:52
generate mandelbrot set
program mand
integer , parameter :: width = 1920*3
integer , parameter :: height = 1080*3
integer, dimension (width, height, 3) :: image
integer :: col, row, iteration, max, max_rgb, pan_x
real :: r_x, r_y, x, y, x_new, color_idx, zoom
pan_x = -300
pan_y = 0
max = 1000
max_rgb = 256**3
@rsayers
rsayers / problem1.s
Last active February 17, 2018 20:16
Project Euler problem 1 example
.data
output_text:
.asciz "%d\n" ;; So we can printf later
.balign 4
.text
.global main
.extern printf ; load external function
;; This program calculates the sum of all positive integers evenly divisible by 3 or 5
@rsayers
rsayers / di.scpt
Created July 7, 2017 15:39
Applescript to return current track playing in digitally imported
tell application "Google Chrome"
set window_list to every window # get the windows
repeat with the_window in window_list # for every window
set tab_list to every tab in the_window # get the tabs
repeat with the_tab in tab_list # for every tab
set the_url to the URL of the_tab # grab the URL
if "di.fm" is in the_url then
tell the_tab
@rsayers
rsayers / pell.py
Created December 15, 2014 00:30
Generate random workouts for pell drills
import random
import time
# Usage:
# python pell.py | espeak -m -w output.wav
#
# This will generate a wav file of your random workout
# eSpeak (http://espeak.sourceforge.net/) is used to generate
# the speech. OSX has a builtin "say" command, which can be used on that
# platform instead.
@rsayers
rsayers / updatealert.sh
Created October 20, 2014 17:28
Get emailed when text on a webpage changes
#!/bin/bash
X=0;
while [ $X -eq 0 ]
do
X=`curl "https://url.to/search" | grep "text to find" | wc -l `
sleep 60
done
echo "done" | mail "you@host.com"
@rsayers
rsayers / xkcd.sh
Created October 8, 2014 15:25
Get the latest XKCD
#!/bin/sh
IMG=`curl www.xkcd.com | grep "Image URL" | awk -F": " '{print $2}'`
curl $IMG > foo.png
curl www.xkcd.com | grep "img.*title=" | awk -F "title=\"" '{print $2}' | awk -F "\"" '{print $1}' | mailx -a foo.png -s "XKCD" YOU@HOST.COM
@rsayers
rsayers / numname.py
Created January 21, 2014 20:13
After searching for a library to spell out the names of integers, I decided to roll my own. Its far easier than I expected
def name(n):
onesteens = ['one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']
tens = ['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']
if n < 20:
return onesteens[n-1]
if n > 19 and n < 100:
dm = divmod(n,10)