Skip to content

Instantly share code, notes, and snippets.

@Snarp
Snarp / exposeClassKeys.js
Created April 4, 2023 00:05 — forked from AprilSylph/exposeClassKeys.js
expose source names on Tumblr
tumblr.getCssMap().then(cssMap => {
const keys = Object.keys(cssMap);
const elements = document.querySelectorAll("[class]");
for (const {classList} of elements) {
for (const className of classList) {
const mappedClassName = keys.find(key => cssMap[key].includes(className));
if (mappedClassName) classList.add(`tumblr--${mappedClassName}`);
}
}
});
@Snarp
Snarp / oz_per_linear_yd_to_gsm.rb
Created October 30, 2022 23:41
Converts ounces per linear yard (a common measurement of fabric density in North America) to GSM (grams per square meter)
# Converts ounces per linear yard (a common measurement of fabric density in
# North America) to GSM (grams per square meter).
#
# When buying fabric, a "linear yard" refers to a yard-long piece of fabric cut
# from a bolt. Ounces per linear yard are calculated by weighing a bolt of
# fabric, then dividing its weight by its length in yards when fully unspooled.
# Fabric bolts may be of varying heights, but are generally more than 1 yard
# tall; 4-5 feet is a common height.
#
# (Q) Given this variability in bolt size, why do so many vendors describe
@Snarp
Snarp / jquery_ui_autocomplete_examples.html
Created May 27, 2022 23:52
JQuery UI autocomplete widget examples with various select/sort options
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Autocomplete Example - JQuery UI</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.min.js" integrity="sha256-eTyxS0rkjpLEo16uXTS0uVCS4815lc40K2iVpWDvdSY=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css" integrity="sha256-WKb0npL30v0SRtmMVowqx9a+gy3f7OZ+yffvMzJ2at8=" crossorigin="anonymous">
@Snarp
Snarp / firewall_block.reg
Created May 19, 2022 20:23 — forked from jnaskali/firewall_block.reg
Block/Unblock exe in Windows Firewall using right-click menu (updated thanks to ghjbnm's comment below)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall]
@=""
"MUIVerb"="Windows Firewall"
"icon"="%SystemRoot%\\system32\\FirewallControlPanel.dll,0"
"subcommands"=""
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall\Shell]
@=""
@Snarp
Snarp / dot_grid_letter_paper_vector.svg
Last active May 15, 2022 00:21
Dot grid letter-sized paper, slightly-larger-than college-ruled, 1 scaling unit==1 millimeter
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Snarp
Snarp / rescue_every_single_goddamn_webdriver_error.rb
Created May 3, 2022 18:20
Automatically build a list of all Selenium / Watir webdriver errors and rescue all of them
require 'watir'
require 'selenium-webdriver'
require 'logger'
# Selenium::WebDriver::Error.constants
# => [:WebDriverError, :NoSuchElementError, :NoSuchFrameError, ...]
def rescue_every_single_goddamn_webdriver_error
selenium_errors = Selenium::WebDriver::Error.constants.map do |e_symbol|
Selenium::WebDriver::Error.const_get(e_symbol)
@Snarp
Snarp / npf_tumblr_theme.html
Created October 16, 2021 16:55 — forked from cyle/npf_tumblr_theme.html
NPF powered tumblr theme prototype
<!--
Note that this is a very rough, incomplete prototype.
More info on how to possibly leverage it here: https://github.com/tumblr/docs/issues/49
-->
<!DOCTYPE html>
<html>
<head>
{MobileAppHeaders}
@Snarp
Snarp / embed_raster_image_in_svg.rb
Created October 1, 2021 17:20
Embed raster image file (JPG, PNG, GIF, BMP) in SVG file
require 'base64'
require 'fastimage'
# This is not raster-to-vector conversion; this is putting a raster in a vector
# suit. If you find yourself in need of this information, something is very
# wrong. Something is very wrong.
def embed_raster_image_in_svg(input_image ="raster.jpg",
output_image="raster_in_vector.svg")
dimensions = FastImage::size(input_image)
@Snarp
Snarp / enumerable_stable_sort_core_ext.rb
Last active September 30, 2021 16:48
Example Ruby implementations of stable_sort and stable_sort_by
module Enumerable
# Sources:
# - https://stackoverflow.com/a/15442966/797772
# - https://rubygems.org/gems/vex/versions/0.6.2
def stable_sort_by
sort_by.with_index { |x,idx| [yield(x), idx] }
end
# def stable_sort_by
@Snarp
Snarp / ubuntu_18_zoneminder_setup_example.bash
Created September 22, 2021 20:18
Steps used September 2021 to get Zoneminder working on Ubuntu 18.04
#!/usr/bin/env bash
# Steps used September 2021 to get Zoneminder working on Ubuntu 18.04 with a
# Reolink RLC-410W camera.
# Install dependencies:
sudo apt-get install tasksel
sudo tasksel install lamp-server