Skip to content

Instantly share code, notes, and snippets.

@dollerbill
dollerbill / word_values.rb
Created September 6, 2023 02:57
Finding words assigned a point value of 100
DICTIONARY = File.read('/usr/share/dict/words').split("\n")
LETTER_VALUES = ('a'..'z').each_with_object({}) do |letter, obj|
obj[letter] = ('a'..'z').find_index(letter) + 1
end
def word_value(word)
letters = word.split('')
total = 0
letters.each do |letter|
next unless letter.match?(/[a-zA-Z]/)
@dollerbill
dollerbill / system_lookup.rb
Created September 4, 2023 20:30
Screenscraper System ID Lookup
# frozen_string_literal: true
class SystemLookup
SYSTEM_MAP = {
'segamegadrive, segagenesis, megadrive, genesis, superaladdinboy' => 1,
'segamastersystem, segamarkiii, segamark3, mastersystem, sms' => 2,
'nintendoentertainmentsystem, nes, famicom, familycomputer, nintendofamicom, nintendofamilycomputer' => 3,
'supernintendoentertainmentsystem, snes, supernintendo, superfamicom, nintendosuperfamicom' => 4,
'nintendogameboy, gameboy, nintendogb, gb' => 9,
'nintendogameboycolor, nintendogbcolor, gameboycolor, nintendogbc, gbcolor, gbc' => 10,
@dollerbill
dollerbill / image_cleanup.rb
Created May 19, 2023 17:48
Delete scraped boxart for removed games
require 'pathname'
systems = Pathname.new('roms').children
systems.each do |system|
s = system.basename.to_s
next if s == '.DS_Store'
%w[box2dfront screenshot wheel].each do |art|
roms = system.children.map(&:basename).map(&:to_s)
roms -= %w[metadata.pegasus.txt .DS_Store]
@dollerbill
dollerbill / rails http status codes
Created December 16, 2021 18:06 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
# A concession stand at a movie theatre sells two products: popcorn for $7 and soda for $2.50. If someone buys both at the same time, they get a bundle price of $9 for the two items. Customers can run a tab, and when settling the bill, we need to calculate how much they owe using the list of past purchases.
# Provide a function that, given the list of past purchases as input (string “,“) returns the amount owed.
# Here is a list of input/output examples:
# tally( [
# "2022-06-01,soda",
# ] ) => 2.5
@dollerbill
dollerbill / speed.js
Created September 4, 2020 04:52
Speed bookmarklet
javascript:(function(speed){document.querySelector('video').playbackRate=speed;document.querySelector('video').defaultPlaybackRate=speed;})(prompt("Enter speed (ex: 2)"));
@dollerbill
dollerbill / td_description_copy.user.js
Last active July 26, 2020 20:49
Easily copy descriptions from your torrentday uploads
// ==UserScript==
// @name TD Description Copy
// @version 0.1.1
// @match https://www.torrentday.com/details.php?id=*
// @author dollerbill
// @description Easily copy your torrentday upload descriptions
// @icon https://www.torrentday.com/favicon.ico
// @downloadURL https://gist.github.com/dollerbill/eff1c290c7cfe67617fce30799840c78
// @updateURL https://gist.github.com/dollerbill/eff1c290c7cfe67617fce30799840c78
// @grant GM_xmlhttpRequest
@dollerbill
dollerbill / README.md
Created April 17, 2018 21:38 — forked from kevinquillen/README.md
Reddit Widget for Dashing

Preview

Description

Took a little inspiration from the News widget to construct this Reddit widget. Simply add the subreddit .json feed URLs that you want to the top of the reddit.rb job script, and the widget will cycle through each one, showing top posts, their score, and comment count. You can also set the maxcount higher or lower, the default is 5 posts.

##Usage