View browser-basic-auth-test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'bundler' | |
Bundler.require | |
require 'sinatra' | |
set :bind, '0.0.0.0' | |
set :port, 80 | |
def show_credentials(request) | |
<<-EOF |
View get-twitter-avatar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright (c) 2021 Dan Q; released under the MIT License. */ | |
const Puppeteer = require('puppeteer'); | |
getAvatar = async (twitterUsername) => { | |
const browser = await Puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']}); | |
const page = await browser.newPage(); | |
await page.goto(`https://twitter.com/${twitterUsername}`); | |
await page.waitForSelector('a[href$="/photo"] img[src]'); | |
const url = await page.evaluate(()=>document.querySelector('a[href$="/photo"] img').src); |
View clicker.rbw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dependencies | |
require 'bundler/inline' | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'win32-sound', require: 'win32/sound' | |
end | |
include Win32 | |
FREQUENCY = 37 # Hz; 37-32767 - what pitch sound? | |
DURATION = 1 # Ms - how long to play for? |
View loader-modern-browsers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This version works with modern browsers | |
function lazyLoadCSS(){ | |
[...document.querySelectorAll('noscript[lazyload]')].forEach(ns=>ns.outerHTML=ns.innerHTML); | |
} | |
(document.readyState != 'loading') ? lazyLoadCSS() : document.addEventListener('DOMContentLoaded', lazyLoadCSS); |
View wp-post-kinds-prefix-kind-in-rss.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Make titles in RSS feed be prefixed by the Kind of the post. | |
function add_kind_to_rss_post_title(){ | |
$kinds = wp_get_post_terms( get_the_ID(), 'kind' ); | |
if( ! isset( $kinds ) || empty( $kinds ) ) return get_the_title(); // sanity-check. | |
$kind = $kinds[0]->name; | |
$title = get_the_title(); | |
return trim( "[{$kind}] {$title}" ); | |
} |
View countdown.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Countdown</title> | |
<style type="text/css"> | |
body { | |
margin: 0; | |
font-family: sans-serif; | |
font-size: 8vh; |
View bbc-news-rss-filter-sport-out.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# # Sample crontab: | |
# # At 41 minutes past each hour, run the script and log the results | |
# 41 * * * * ~/bbc-news-rss-filter-sport-out.rb > ~/bbc-news-rss-filter-sport-out.log 2>>&1 | |
# Dependencies: | |
# * open-uri - load remote URL content easily | |
# * nokogiri - parse/filter XML | |
# * b2 - command line tools, described below |
View consolepic.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Bundler/Gemfile (inline mode) | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'chunky_png' | |
end | |
# Check for PNG file passed at command line or error out |
View google-authenticator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# encoding: utf-8 | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'rotp' | |
gem 'thor' | |
end |
View Basic Reddit Content Exporter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Basic Reddit Content Exporter | |
// Author: Dan Q <https://danq.me/> | |
// License: The Unlicense <https://unlicense.org/> / Public Domain | |
// 1. Go to www.reddit.com and log in (logging in means that we don't have to worry about a modhash) | |
// 2. Edit this script to include YOUR username and the content you want to download | |
// 3. Paste this script into your browser console | |
(()=>{ | |
const username = 'avapoet'; // <-- your username goes here (be sure to be logged in as it, too!) | |
const content = 'submitted'; // <-- valid options: overview (everything), submitted (posts), comments, |
NewerOlder