Skip to content

Instantly share code, notes, and snippets.

View SamuelDavis's full-sized avatar

Samuel Davis SamuelDavis

  • Stallings, NC, USA
View GitHub Profile
@SamuelDavis
SamuelDavis / twitter-popup-remover.js
Created December 27, 2021 02:41
Programmatically remove the content shield from Twitter.
(function () {
const timeout = 5000;
const start = performance.now();
const interval = setInterval(() => {
const popup = document.querySelector('[data-testid="sheetDialog"] svg');
console.log(popup);
if (!popup || performance.now() - start > timeout)
return clearInterval(interval);
if (popup) popup.parentElement.click();
}, 100);
@SamuelDavis
SamuelDavis / deploy.sh
Created December 24, 2021 08:49
Deploy Script for NPM projects with a `build` command which generate a `/dist` directory.
#!/usr/bin/env sh
NAME='repo'
# abort on errors
set -e
# build
npm run build
# navigate into the build output directory
let data = Array.from(document.querySelectorAll(".commands-container h2")).map(
(el) => {
return {
heading: el.textContent,
items: Array.from(el.nextElementSibling.children).map((el) => {
const [answers, ...description] = el.textContent
.trim()
.split(/\s+-\s+/);
return {
description: description.join(" - "),
:root {
--background-color: whitesmoke;
--header-height: 2em;
--margin-end: 1em;
--margin-gap: 1px;
--margin-color: red;
--margin-right: 0.25em;
@SamuelDavis
SamuelDavis / pythonicFizzBuzz.py
Created January 30, 2020 10:22
Just testing my python skills.
def fb(cs = [3, 5], l = 100, o = 1):
for i in range(o, l):
o = ""
for j, c in enumerate(cs):
if i % c == 0:
o += "Fizz" if j % 2 == 0 else "Buzz"
print(o or i)
@SamuelDavis
SamuelDavis / oneLineFizzBuzz.js
Last active January 30, 2020 10:06
I wanted a fizzBuzz where all the constraints were inputs. Also, I manually minified it in a fit of madness.
function print(arg) {
document.body.innerText += arg + "\n";
}
function fizzBuzz(c = [3, 5], l = 100, o = 1) { // c = checks, l = limit, o = offset
return new Array(l + o) // +o because ignore zero
.fill(undefined) // can't map over uninitialized arrays
.map((_, i) => // 0 <= i < limit
c.reduce((a, c, j) => // a = accumulator, c = check, 0 <= j < checks.length
(i % c === 0) // if we've hit a Fizz/Buzz number
@SamuelDavis
SamuelDavis / wordpress-traefik-compose.yml
Last active December 6, 2021 11:51
WordPress With HTTPS Example
version: '3'
networks:
reverse-proxy: {}
wp-test: {}
volumes:
wp-test-db: {}
services:
@SamuelDavis
SamuelDavis / functionalFizzBuzz.php
Created November 11, 2019 02:45
A hilarious little functional implementation of fizz buzz. I appreciate how there's no duplicated % 3 or % 5 logic.
<?php
function guardWithModulo($d, $s)
{
return function ($i) use ($d, $s) {
return ($i % $d === 0) ? $s : null;
};
}
$cbs = [
@SamuelDavis
SamuelDavis / nested_array.php
Created October 31, 2019 04:01
Extract a nested array structure from formatted text.
<?php
$list = <<<LIST
1 Introduction
1.1 Purpose
<Identify the product whose software requirements are specified in this document, including the revision or release number Describe the scope of the product that is covered by this SRS, particularly if this SRS describes only part of the system or a single subsystem.>
1.2 Document Conventions
<Describe any standards or typographical conventions that were followed when writing this SRS, such as fonts or highlighting that have special significance For example, state whether priorities for higher-level requirements are assumed to be inherited by detailed requirements, or whether every requirement statement is to have its own priority.>
1.3 Intended Audience and Reading Suggestions
<Describe the different types of reader that the document is intended for, such as developers, project managers, marketing staff, users, testers, and documentation writers Describe what the rest of this SRS contains and how it is organized Suggest a sequence for reading the document, b
@SamuelDavis
SamuelDavis / NDimensionalArray.js
Last active August 28, 2019 11:23
automatically create arbitrarily nested arrays
class NDimensionalArray extends Array {
constructor (size, ...sizes) {
super(size)
super.fill(undefined)
if (sizes.length) {
size = sizes.shift()
this.forEach((_, i) => this[i] = new NDimensionalArray(size, ...sizes))
}
}