Skip to content

Instantly share code, notes, and snippets.

View tobek's full-sized avatar

Toby Fox tobek

View GitHub Profile
@tobek
tobek / README.md
Last active April 3, 2024 15:55
Roam bookmarklet for rich link embeds, read later, and bookmark management

Setup:

  1. Create a browser bookmark (e.g. in bookmarks bar) where the URL is the text in bookmarklet below (open this "raw" link so it's not truncated). Yes it's huge, that's fine. You can name the bookmark "Roam Link" or whatever you like.
    • Alternately, go to this page for easier drag-and-drop bookmarklet setup (GitHub doesn't allow javascript links in gists, sorry)
  2. Go to or create a Roam page called roam/css, and create a CSS code block (``` for code block, then change the language selector dropdown to CSS) and paste the CSS below.

Usage:

  1. On the page you want to create a link embed of, hit the bookmarklet (optional: highlight some text first and it'll be included as a quote)
  2. Go to Roam and paste
@tobek
tobek / rip-dvd-chapters.sh
Created October 19, 2020 23:16
Rip and encode individual titles and chapters from DVD or ISO
#!/bin/bash
set -eo pipefail
shopt -s expand_aliases
alias ffmpeg='ffmpeg -hide_banner'
usage()
{
cat << EOF
@tobek
tobek / thewindow.sh
Last active June 21, 2023 22:58
Script for keeping your windows and applications handy
#!/bin/bash
usage()
{
cat << EOF
usage: thewindow [OPTIONS] SEARCH_STRING COMMAND
This script will search the X window manager for any open window containing SEARCH_STRING and, if found, will move to the containing desktop, raise that window, and give it focus.
If a matching window on the current desktop is found, that will be focused first instead of any matching windows on other desktops.
@tobek
tobek / lastfm-remove-duplicates.js
Last active March 7, 2018 17:20 — forked from sk22/lastfm-remove-duplicates.js
Last.fm duplicate scrobble deleter
var dupesFound = 0;
var elements = Array.from(document.querySelectorAll('.js-link-block'))
elements.map(function (element) {
var nameElement = element.querySelector('.chartlist-name')
return nameElement && nameElement.textContent.replace(/\s+/g, ' ').trim()
}).forEach(function (name, i, names) {
if (name !== names[i + 1]) return
var deleteButton = elements[i].querySelector('[data-ajax-form-sets-state="deleted"]')
if (deleteButton) {
dupesFound++;
@tobek
tobek / habitica-tags-userscript.js
Created January 26, 2017 00:06
Habitica Tag Visibility Userscript
// ==UserScript==
// @name Habitica Tag Visibility
// @namespace tobek-habitica
// @version 0.1
// @description Makes tags visible in the name of the task, without having to hover over the tags icon. Tags are shown as "[tag1][tag2][...] Task name...". This is a total hack and would be much better as part of official Habitica codebase but that's more work and discussion than the 10m I spent on this.
// @author Tobek
// @match https://habitica.com/*
// @grant none
// ==/UserScript==
@tobek
tobek / memory-alert.sh
Created December 9, 2016 01:47
Linux daemon for alerting you if you're running out of memory
#!/bin/bash
# Minimum available memory limit, MB
THRESHOLD=1024
# Check time interval, sec
INTERVAL=60
while :
do
@tobek
tobek / tgp.conf
Created December 3, 2016 04:25
PHP-FPM config for TGP on Linux
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[thegenerationsproject.info]
; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
@tobek
tobek / vice-mag-headline-generator.js
Created July 15, 2016 20:30
@deadlydizzle's Vice Magazine Headline Generator script
/* Vice Magazine Headline Generator script
Author: David Alexander (ddly.co / @deadlydizzle)
Version: 1.0 September 1, 2014
License: GNU General Public License, version 3.0 (GPLv3)
*/
// Tell JSLint's 'defined but never used' error to take a hike
/* exported setHeadline */
@tobek
tobek / youtube-upload.html
Created March 25, 2016 02:39
YouTube API v3 upload video and set snippet etc.
<!-- More info at http://stackoverflow.com/questions/25595930/youtube-api-v3-over-http-post-cant-set-snippet-while-uploading-a-video-title/ -->
<form id="upload-yt-video" action="https://www.googleapis.com/upload/youtube/v3/videos?part=snippet&access_token=YOUR_TOKEN_HERE" method="post" enctype="multipart/form-data">
<input type="text" name="title" placeholder="Video title">
<textarea name="description" placeholder="Video description"></textarea>
<input type="file" accept="video/*" name="videoFile">
<input type="submit" value="Upload Video">
</form>
<!-- load jQuery -->
@tobek
tobek / grunt-aws-s3.js
Created January 10, 2016 22:23
basic config for grunt-aws-s3 task
// using https://github.com/MathieuLoutre/grunt-aws-s3
aws_s3: {
options: {
accessKeyId: '<%= aws.key %>',
secretAccessKey: '<%= aws.secret %>',
// putting no region makes it default to US Standard
// debug: true, // do a dry run
uploadConcurrency: 5
},