Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
wizard04wsu / fuzzySpoiler.htm
Last active June 20, 2023 01:41
CSS to obfuscate text until you hover over it. I got this idea from https://www.reddit.com/r/MumboJumboFanServer/ where similar CSS is used to hide spoilers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS to obfuscate text</title>
<style>
@wizard04wsu
wizard04wsu / ts.bat
Created October 4, 2022 16:30
Tree-sitter build script for Atom
@echo off
:: Required version of tree-sitter-cli (TODO: update manually as needed)
set "treesitter=0.15.14"
::=======================================
:: Constants
@wizard04wsu
wizard04wsu / changeBase.js
Last active July 30, 2022 19:45
Convert a number to a different base (e.g., from hex to decimal)
//Convert a number to a different base (e.g., from hex to decimal).
//Returns a string representation of the number, or NaN if `num` does not represent a number of the specified base.
function changeBase(num, fromRadix, toRadix){
if(!(1*fromRadix) || fromRadix%1 !== 0 || fromRadix < 2 || fromRadix > 36){
throw new RangeError(`'fromRadix' must be an integer between 2 and 36, inclusive.`);
}
if(!(1*toRadix) || toRadix%1 !== 0 || toRadix < 2 || toRadix > 36){
throw new RangeError(`'toRadix' must be an integer between 2 and 36, inclusive.`);
}
@wizard04wsu
wizard04wsu / isType.js
Last active August 27, 2021 17:13
Improved JavaScript type testing - Future revisions will be at https://github.com/wizard04wsu/javascript-type-testing
/**
* A more robust 'typeof'.
* https://gist.github.com/wizard04wsu/8055356
*
*
* For each of the type testing methods, the only parameter is the item to be tested. These methods do not perform coercion.
*
* is(o) - Returns the item's type.
* - NaN is considered its own type (instead of a number), since it essentially represents something that cannot be converted to a number.
* - For objects, the type of the object is given instead of just 'object' (e.g., 'Array').
@wizard04wsu
wizard04wsu / cookies.js
Last active May 12, 2021 09:32
Methods for working with cookies
//If cookies are not supported by the browser, `Cookies` will be undefined
//Cookies.set(name, value[, options])
// creates, modifies, or removes a cookie
// `options` may be an object including `expires`, `path`, `domain`, and/or `secure`
// `options.expires` can be either a Date object or the number of seconds until it should expire
// (0 or undefined indicates end of session, <0 removes the cookie, Infinity sets it to 50 years)
//
//Cookies.get(name)
// returns the value of the first cookie with that name
@wizard04wsu
wizard04wsu / ellipsis.htm
Last active November 24, 2020 21:20
An absolutely-positioned ellipsis displays when a multi-line box overflows.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ellipsis Box</title>
<style>
@wizard04wsu
wizard04wsu / notifications.js
Created February 12, 2014 19:49
Cross-browser desktop notifications (for supporting browsers)
//http://www.w3.org/TR/notifications/
//https://developer.mozilla.org/en-US/docs/Web/API/notification
//Notifier.isSupported
//
//Notifier.permission //"granted", "denied", or "default"
//
//Notifier.requestPermission([callback]) //first argument of callback is the current permission
//
//Notifier.notify(title[, options])
@wizard04wsu
wizard04wsu / accessibleMenubar.css
Last active July 1, 2020 17:58
HTML/JavaScript menu bar that can be navigated with the mouse and keyboard. Tested with the NVDA screen reader; using ARIA role="menubar" reduces noise and automatically enters focus mode. *** requires https://gist.github.com/wizard04wsu/3ec34604d7538303e9f0 ***
ul.menubar, ul.menubar ul {
list-style-type:none;
}
ul.menubar > li {
display:inline-block;
vertical-align:top;
border:1px solid red;
}
ul.menubar ul {
display:none;
@wizard04wsu
wizard04wsu / VBArray.vbs
Last active July 1, 2020 17:57
VBScript or VBA array functions
Function getUBound(arr)
getUBound = -1
On Error Resume Next
getUBound = UBound(arr)
On Error GoTo 0
End Function
Function getLength(arr)
getLength = getUBound(arr) + 1
End Function
@wizard04wsu
wizard04wsu / dates.js
Created February 6, 2014 21:30
JavaScript Date methods
//month names, weekday names, and ordinal indicators are in English
// Date.now()
// Date.fromISOString(isoStr)
// Date.timeBetween(date1, date2)
// dat.isLeapYear()
// dat.isUTCLeapYear()
// dat.getDaysInMonth()
// dat.getUTCDaysInMonth()
// dat.getMonthName()