Skip to content

Instantly share code, notes, and snippets.

@Snarp
Snarp / 00-README.md
Created January 17, 2021 20:59 — forked from nightpool/00-README.md
NPF-to-HTML renderer

npf.js is the main bulk of the code, and it exposes three functions:

renderContent

Render content returns an object {content, ask}. It returns the ask content separately so it can be handled spearately by the consuming client. content is an HTML element, ask is itself an object containing content (an HTML element) and the other properties of the ask layout type (specifically of interest is the attribution property).

mentions

media

@Snarp
Snarp / mute_etsy_ads_userscript.js
Created April 28, 2021 22:48
Etsy.com - Mute Deceptive Search Result Ads: Hides the difficult-to-identify ads in Etsy search results.
// ==UserScript==
// @name Etsy.com - Mute Deceptive Search Result Ads
// @author snarp
// @version 0.3
// @description Hides the difficult-to-identify ads in Etsy search results.
// @run-at document-idle
// @include https://www.etsy.com/*/search?q=*
// @include https://www.etsy.com/search?q=*
// @grant none
// @icon https://www.etsy.com/images/favicon.ico
@Snarp
Snarp / init_watir_edgedriver_on_ubuntu.rb
Created June 24, 2021 01:24
Initialize a Microsoft Edge Watir/Selenium browser/driver on Ubuntu 18.04
# NOTE: The Edge version in use here is:
# `92.0.902.15 (Official build) beta (64-bit)`
gem 'selenium-webdriver', '=4.0.0.beta4'
require 'selenium-webdriver'
gem 'watir', '~> 6.19'
require 'watir'
# gem 'webdrivers', '~> 4.6' # Edge not supported on Linux as of latest release
# require 'webdrivers'
@Snarp
Snarp / initialize_watir_firefox_with_profile.rb
Last active September 8, 2021 18:15
Initializes an instance of Watir::Browser using a specified Firefox profile.
require 'watir'
require 'webdrivers/geckodriver'
# Source:
# <https://github.com/SeleniumHQ/selenium/issues/7796#issuecomment-555833317>
# Find your Firefox profile's directory by opening 'about:support' in the
# browser and scrolling down to the 'Profile Directory' field.
#
# Alternately, to create a new profile, go to 'about:profiles' and click
@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
@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 / 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 / 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 / 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 / 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.