Skip to content

Instantly share code, notes, and snippets.

View mark05e's full-sized avatar

mark05E mark05e

View GitHub Profile
@mark05e
mark05e / decodeEntities.js
Created January 12, 2022 21:32
Decode HTML entities in a provided string.
//https://stackoverflow.com/questions/5796718/html-entity-decode
var decodeEntities = (function() {
// this prevents any overhead from creating the object each time
var element = document.createElement('div');
function decodeHTMLEntities (str) {
if(str && typeof str === 'string') {
// strip script/html tags
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, '');
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, '');
element.innerHTML = str;
@mark05e
mark05e / isToday.js
Created January 12, 2022 21:31
Check if the date provided is today
// https://flaviocopes.com/how-to-determine-date-is-today-javascript/
const isToday = (someDate) => {
const today = new Date()
someDate = new Date(someDate);
return someDate.getDate() == today.getDate() &&
someDate.getMonth() == today.getMonth() &&
someDate.getFullYear() == today.getFullYear()
}
{
"last_update": "2021-01-13",
"images": {
"0": "https://media.giphy.com/media/hQKiGV6MG8WmsHg2yx/giphy.gif",
"1": "https://media.giphy.com/media/Mtqip7Jor0DgAvzn6U/giphy.gif",
"2": "https://media.giphy.com/media/7XuKKmGiaxXe6EjOj4/giphy-downsized-large.gif",
"3": "https://media.giphy.com/media/3i7zenReaUuI0/giphy.gif",
"4": "https://media.giphy.com/media/DhstvI3zZ598Nb1rFf/giphy-downsized-large.gif",
"5": "https://media.giphy.com/media/LqafmeaBVxCRG/giphy.gif",
"6": "https://media.giphy.com/media/9Vvoj75o3ZsK6TRUqH/giphy.gif",
@mark05e
mark05e / type-clipboard.ahk
Last active December 28, 2021 16:59
Type clipboard contents into fields which do not support copy/paste
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetKeyDelay 5000
^!v::Send {Raw}%Clipboard% ; CTRL + ALT + V
// ==UserScript==
// @name Marks_New_Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Mark
// @match <$URL$>
// @icon <$ICON$>
// @resource TOASTIFY_CSS https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css
// @require https://cdn.jsdelivr.net/npm/toastify-js
function createTableFromKeyValueArray(array) {
// https://niraeth.com/javascript-create-html-table-based-on-key-value-array/
if( array.length <= 0 )
return null;
var table = document.createElement('table');
var keys = Object.keys(array[0]);
var thead = document.createElement("thead");
var header_row = document.createElement('tr');
#NoEnv
Revision := 3
ShowHelpScreen()
;
; App content here
;
^!x::