Skip to content

Instantly share code, notes, and snippets.

View mattdanielbrown's full-sized avatar

Matt Daniel Brown mattdanielbrown

View GitHub Profile
@WebReflection
WebReflection / attr.js
Created November 19, 2020 19:38
A dataset like behavior for any attribute
const proxies = new WeakMap;
const hyphen = name => name.replace(/([a-z])([A-Z])/g, '$1-$2');
const handler = {
get: (el, name) => el.getAttribute(hyphen(name)),
set: (el, name, value) => {
el.setAttribute(hyphen(name), value);
return true;
}
};
const set = el => {

async / return await explained

This is yet another explanation of why async and return await is pointless, coming from this post.

// async means that this:
const fn = async (...args) => {/* stuff */};

// is basically the equivalent of this:
@temp3l
temp3l / card.json
Created September 30, 2020 22:31
{
"credit_card": {
"$id": "#/properties/credit_card",
"$comment": "Comment for developer",
"type": "string",
"title": "credit card number",
"description": "The number on the back of this credit card",
"examples": [ "4111 1111 1111 1111", "5500 0000 0000 0004" ],
"default": "4111 1111 1111 1111",
"minLength": 10,
// just guessing
// converted: https://json-schema.org/draft/2019-09/links
export type JSONSchema7 = import('json-schema').JSONSchema7;
export type LinkDescriptionObject = {
anchor?: string;
anchorPointer?: string;
rel?: string | string[];
href?: string;
@mecid
mecid / Calendar.swift
Last active November 28, 2024 14:25
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@sethenoka
sethenoka / wireguard_pihole_install.sh
Created March 21, 2019 21:28
A script for installing a Wireguard VPN with Pi-Hole (Unbound) recursive DNS
#!/bin/bash
# This file is designed to spin up a Wireguard VPN quickly and easily,
# including configuring Pi-Hole as a recursive local DNS server using
# Unbound to block ads a the DNS level
#
# Make sure to change the public/private keys before running the script
# Also change the IPs, IP ranges, and listening port if desired
# add wireguard repo
sudo add-apt-repository ppa:wireguard/wireguard -y
@sethenoka
sethenoka / wg_install.sh
Last active April 25, 2021 04:17
A script to spin up a Wireguard VPN server with Unbound recursive DNS in a hurry
#!/bin/bash
# This file is designed to spin up a Wireguard VPN quickly and easily,
# including configuring a recursive local DNS server using Unbound
#
# Make sure to change the public/private keys before running the script
# Also change the IPs, IP ranges, and listening port if desired
# iptables-persistent currently requires user input
# add wireguard repo
sudo add-apt-repository ppa:wireguard/wireguard -y
@da2x
da2x / google-my-activity-deletion.js
Created May 27, 2018 14:48
Delete My Activity from your Google Account older than 9 moonths.
Date.prototype.getUnixTime = function() {
return this.getTime()/1000|0;
};
Date.prototype.getUnixMicroUnixTime = function() {
return this.getUnixTime()*1000000;
};
var date = new Date();
date.setMonth(date.getMonth() - 9);
@RabaDabaDoba
RabaDabaDoba / ANSI-color-codes.h
Last active April 21, 2025 15:23 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes working in C!
/*
* This is free and unencumbered software released into the public domain.
*
* For more information, please refer to <https://unlicense.org>
*/
//Regular text
#define BLK "\e[0;30m"
#define RED "\e[0;31m"
#define GRN "\e[0;32m"
var img = new Image();
img.src = 'img/assets/background.png';
var int = setInterval(function() {
if (img.complete) {
clearInterval(int);
document.getElementById('content').setAttribute('style', 'background-image: url(' + img.src + '); opacity:1;');
}
}, 50);