Skip to content

Instantly share code, notes, and snippets.

@automatthew
automatthew / README.md
Created October 2, 2020 19:09
UATV podcast addon

Enhances streams on unauthorized.tv by adding buttons to jump 30s forward/backward and change playback rate. On android devices, the playback controls on the notification screen also receive jump buttons.

On your desktop browser, install a userscript manager like Tampermonkey and add the script below. Each stream will be augmented with extra buttons.

On android, create a bookmark and copy-paste the snippet below into the URL field. Click on this bookmark whenever you're listening to a podcast to upgrade the page. (You can usually invoke the bookmarklet from the URL bar by typing in its name)

javascript:(function()%7B(function()%7B'use%20strict'%3Bconst%20%24%3Ddocument.querySelector.bind(document)%3Bconst%20gui%3Ddocument.createElement('div')%3Bgui.innerHTML%3D%60%0A%3Cdiv%20class%3D%22tm-controls%22%3E%0A%20%20%3Cbutton%20class%3D%22tm-controls__back%22%3E%3Ci%20class%3D%22fa%20fa-backward%22%3E%3C%2Fi%3E%3C%2Fbutton%3E%0A%20%20%3Cbutton%20class%3D%22tm-controls__rate%22%3E1x%3C%2Fbutton%3E%0A%20%20%3
@automatthew
automatthew / pdfdata.rb
Created February 12, 2010 11:45
script for editing pdf metadata using pdftk
#!/usr/bin/env ruby
require 'tempfile'
require 'fileutils'
FileUtils.mkdir_p "processed"
def metadata(filename)
command = "pdftk #{filename.dump} dump_data"
puts command
@automatthew
automatthew / Embedder.java
Created November 19, 2009 18:06
Improved interface for JRuby Embed
import org.jruby.embed.PathType;
import org.jruby.embed.ScriptingContainer;
public class Embedder {
public ScriptingContainer container;
public String file;
public Embedder(String filename) {
file = filename;
container = new ScriptingContainer();
@automatthew
automatthew / instant.rake
Created November 10, 2009 20:13
compile and run trivial Java with Rake
# instant.rake
# Rake rules for compiling and running trivial Java programs
#
# Usage: rake com.example.MonkeyShines
# Source goes under ./src
# Classes end up under ./target
require 'rake/clean'
libs = FileList["lib/*"]
@automatthew
automatthew / solr_tomcat.rake
Created October 15, 2009 21:52
rake tasks for Solr
# This task presumes you have made an erb template of solrconfig.xml
# with an interpolation like this:
# <dataDir>${solr.data.dir:<%= app_root %>/solr/data}</dataDir>
desc "generate solrconfig.xml file for ./solr_app"
task :configure => "solr_app/conf/solrconfig.xml"
rule '.xml' => '.erb' do |t|
require 'erubis'
File.open(t.name, "w") do |f|
@automatthew
automatthew / script.rb
Created September 29, 2009 16:16
Pattern for single file lib/script
#!/usr/bin/env ruby
#
# Simple pattern for a Ruby script where the command line processing
# is done separately from the rest of the code. This allows the file
# to be required by other Ruby code without acting as an executable.
class Project
# Defaults to be overridden by command line options
@automatthew
automatthew / edits.rb
Created August 14, 2009 19:48
basic edits for Strings
# useful for things like http://norvig.com/spell-correct.html
module Edits
DICT = { "cap" => 1, "carp" => 1, "clap" => 1, "cramp" => 1 }
def deletes
map_transforms { |word, i| word.delete_at(i) }
end
@automatthew
automatthew / n-log.rb
Created August 14, 2009 18:28
like ngrams, but for phrases
#!/usr/bin/env ruby
require 'enumerator'
max = ARGV[0].to_i || 5
while string = STDIN.gets
bits = string.chomp.split
(2..max).each do |i|
bits.each_cons(i) do |nlog|
puts nlog.join(" ")
end
@automatthew
automatthew / analyzer.rb
Created July 23, 2009 20:53
token analysis and expansion
class Analyzer
def initialize
@expansions = []
@transformations = []
@substitutions = {}
@tokenizer = lambda { |string| string.split }
end
def tokenizer(&proc)
@automatthew
automatthew / thread_safe_camel_snake.rb
Created April 8, 2009 14:03
camel and snake casing
def camel_case( string )
string.split('_').map do |word|
"#{word.slice(/^\w/).upcase}#{word.slice(/^\w(\w+)/, 1)}"
end.join
end
def snake_case( string )
string.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
end