View jigidi-helper.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
window.jColors = ['red', 'blue', 'brown', 'orange', 'yellow', 'pink', 'lightblue', 'lightgreen', 'lightgray']; | |
window.lColors = ['white', 'black', 'purple', 'darkgray', '#009']; | |
window.lWidths = [5, 10, 20]; | |
window.jCols = parseInt(document.getElementById('info-creator').innerText.match(/(\d+)×/)[1]); | |
window.jC = 0; | |
CanvasRenderingContext2D.prototype.putImageData = function(imageData, dx, dy){ | |
const col = window.jC % window.jCols; | |
const row = Math.floor(window.jC / window.jCols); | |
this.fillStyle = window.jColors[col % window.jColors.length]; | |
this.fillRect(-1000,-1000,2000,2000); |
View _no_code_page_.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 | |
// half-hearted CSS minification | |
$css = preg_replace( | |
array('/\s*(\w)\s*{\s*/','/\s*(\S*:)(\s*)([^;]*)(\s|\n)*;(\n|\s)*/','/\n/','/\s*}\s*/'), | |
array('$1{ ','$1$3;',"",'} '), | |
file_get_contents('linked.css') | |
); | |
// embed as a data: uri | |
$base64css = rtrim(strtr(base64_encode($css), '+/', '-_'), '='); |
View wp-mastodon-sync.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/php | |
<?php | |
define('Q23_WP_DIR', '/www/danq.me/www'); | |
define('Q23_MASTODON_SERVER', 'm.danq.me'); | |
define('Q23_MASTODON_META_KEY', 'q23_mastodon_sync'); | |
define('Q23_MASTODON_META_SYNDICATION_LINKS', 'mf2_syndication'); | |
define('Q23_MASTODON_SYNC_POSTS_LIMIT', 30); | |
define('Q23_MASTODON_SYNC_REPLIES_LIMIT', 30); | |
define('Q23_MASTODON_COMMENT_USER_AGENT', 'Q23 DanQ.me Mastodon Comment Backfeeder'); |
View referer-faker.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 | |
define('SECRET_PASSWORD', 'YOUR-SECRET-PASSWORD-GOES-HERE'); | |
if($_GET['pw'] != SECRET_PASSWORD) http_response_code(403) && die(); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $_GET['url']); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_REFERER, $_GET['referer']); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
View finger-to-wordpress.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 | |
# This program gets executed (by /etc/efingerd/luser) when somebody runs finger something@danq.me | |
# The output is returned directly to them | |
# For more information, see https://danq.me/wp-finger | |
require 'mysql2' | |
require 'word_wrap' | |
require 'word_wrap/core_ext' | |
db = Mysql2::Client.new(username: 'WORDPRESS_DB_USERNAME', password: 'WORDPRESS_DB_PASSWORD', database: 'WORDPRESS_DB_NAME') |
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}" ); | |
} |
NewerOlder