Skip to content

Instantly share code, notes, and snippets.

@viking
viking / script.js
Last active May 30, 2022 21:26
Auto-skip commercials in Hulu live TV recorded programs
var huluInt = setInterval(() => {
if (document.querySelector('div.AdUnitView') !== null) {
document.querySelector('.FastForwardButton').click();
setTimeout(() => {
let event = new MouseEvent('pointerenter');
document.querySelector('#web-player-app').dispatchEvent(event);
}, 2000);
setTimeout(() => {
let event = new MouseEvent('pointerleave');
document.querySelector('#web-player-app').dispatchEvent(event);
@viking
viking / diet.sql
Last active May 21, 2019 22:58
Utilities for simple nutrition tracking (SQLite)
/* References:
* https://www.fda.gov/food/nutrition-education-resources-and-materials/how-understand-and-use-nutrition-facts-label
* https://www.accessdata.fda.gov/scripts/interactivenutritionfactslabel/factsheets/vitamin_and_mineral_chart.pdf
*/
CREATE TABLE servings (id INTEGER PRIMARY KEY, product TEXT, size TEXT, grams NUMERIC DEFAULT 0, calories NUMERIC DEFAULT 0, total_fat_g NUMERIC DEFAULT 0, sat_fat_g NUMERIC DEFAULT 0, trans_fat_g NUMERIC DEFAULT 0, cholesterol_mg NUMERIC DEFAULT 0, sodium_mg NUMERIC DEFAULT 0, total_carb_g NUMERIC DEFAULT 0, fiber_g NUMERIC DEFAULT 0, total_sugars_g NUMERIC DEFAULT 0, protein_g NUMERIC DEFAULT 0, vitamin_a_mcg NUMERIC DEFAULT 0, vitamin_c_mcg NUMERIC DEFAULT 0, vitamin_d_mcg NUMERIC DEFAULT 0, calcium_mg NUMERIC DEFAULT 0, iron_mg NUMERIC DEFAULT 0, potassium_mg NUMERIC DEFAULT 0, updated_at DATE);
CREATE TABLE diet (id INTEGER PRIMARY KEY, servings_id INTEGER, num_servings INTEGER DEFAULT 0, time_stamp DATETIME);
CREATE VIEW daily_amount AS SELECT strftime('%Y-%

Keybase proof

I hereby claim:

  • I am viking on github.
  • I am kindlyviking (https://keybase.io/kindlyviking) on keybase.
  • I have a public key whose fingerprint is 2F1C B90A 31C6 0CE5 91DF 9C1B CB5A 9B0C F299 379C

To claim this, I am signing this object:

@viking
viking / compo.sh
Created September 30, 2016 20:24
Download and extract tracker files from s3m competitions
#!/bin/bash
num=$1
wget --content-disposition https://s3m.it/pack/$num
file=`ls -t | head -n 1`
dir=`echo "$file" | sed 's/\.7z$//'`
mkdir "$dir"
cd "$dir"
7z x "../$file"
cd -
target="beef"; i=0; msg=`git log -1 --pretty="%B"`; while true; do hash=`git rev-parse HEAD`; if [[ $hash == "$target"* ]]; then break; fi; git commit --amend -q -m "$msg$i"; i=$((i+1)); echo $i; if [ $((i % 10000)) -eq 9999 ]; then echo "Cleaning up..."; git gc; fi; done
@viking
viking / coda-feed.rb
Last active October 1, 2020 15:32
Script to download songs by coda
require 'rss'
require 'uri'
url = 'http://coda.s3m.us/feed/'
URI.open(url) do |rss|
feed = RSS::Parser.parse(rss, false)
feed.items.each do |item|
if item.enclosure
url = URI.parse(item.enclosure.url)
filename = File.basename(url.path)
@viking
viking / ffx-lightning.sh
Created October 18, 2014 12:56
Script for sound notifications on when to dodge lightning in Final Fantasy X
#!/bin/bash
quick() {
sleep 1
afplay /System/Library/Sounds/Morse.aiff &
sleep 1
afplay /System/Library/Sounds/Morse.aiff &
sleep 1
afplay /System/Library/Sounds/Ping.aiff &
}
@viking
viking / mario-kart.js
Last active August 29, 2015 14:02
Mario Kart wavepot song
var pitches = {
'B2': 123,
'C3': 131,
'C#3': 139,
'D3': 147,
'D#3': 156,
'E3': 165,
'F3': 175,
'F#3': 185,
'G3': 196,
@viking
viking / wavepot.js
Created June 19, 2014 22:06
wavepot song
var pitches = {
'C4': 262,
'C#4': 278,
'D4': 294,
'D#4': 311,
'E4': 330,
'F4': 349,
'F#4': 370,
'G4': 392,
'G#4': 415,
@viking
viking / i3-shell.sh
Last active March 25, 2024 16:25
Bash script for i3 to run a terminal in the same working directory as the current focused application
#!/bin/bash
# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152
CMD=xterm
CWD=''
# Get window ID
ID=$(xdpyinfo | grep focus | cut -f4 -d " ")
# Get PID of process whose window this is