Skip to content

Instantly share code, notes, and snippets.

View SamuelDavis's full-sized avatar

Samuel Davis SamuelDavis

  • Stallings, NC, USA
View GitHub Profile
set title
" Styling
syntax on
colorscheme slate
" Search
set incsearch " incrementally highlight search while typing
" Sidebar
@SamuelDavis
SamuelDavis / component_proxy_type.ts
Last active February 12, 2023 20:43
An example of typing a proxy object to get/set properties in bitESC's components
import {
addComponent,
addEntity,
createWorld,
defineComponent,
defineQuery,
type ComponentType,
type IWorld,
Types,
type ISchema,
@SamuelDavis
SamuelDavis / init.lua
Last active March 19, 2023 13:52
Hammerspoon Config
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Left", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h
@SamuelDavis
SamuelDavis / .bashrc
Last active May 5, 2022 01:25
Arch Linux installation/configuration
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
export BROWSER="brave-bin"
export _JAVA_AWT_WM_NONREPARENTING=1 # dwm support for phpstorm
export PATH="$PATH:$HOME/code/scripts"
@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