Skip to content

Instantly share code, notes, and snippets.

View endymion1818's full-sized avatar
🦈
47

Ben Read endymion1818

🦈
47
View GitHub Profile
@endymion1818
endymion1818 / pre-commit
Created October 4, 2019 09:28
protected branches (git hook)
#!/bin/bash
protected_branches=( production master )
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
for i in "${protected_branches[@]}"
do
protected_branch=$i
@endymion1818
endymion1818 / bash-commands.sh
Last active April 10, 2021 21:10
frequently used bash commands
curl -I <domain> # what headers are enabled on this site
sudo lsof -i :<port> # what process (pid) is running at a specified port, followed often by kill -9 <pid>
sudo killall -HUP mDNSResponder # reset local DNS cache
@endymion1818
endymion1818 / next.config.js
Created August 6, 2021 13:13
NextJS withPlugins redirects
const withPlugins = require('next-compose-plugins');
const withSourceMaps = require('@zeit/next-source-maps');
const nextConfig = {
basePath: '/messages',
};
const _withSourceMaps = [
withSourceMaps,
{
@endymion1818
endymion1818 / test.js
Last active September 23, 2021 10:55
stackoverflow-66579559
// I had issues with this
it('should work', async () => {
await waitFor(() => {
// assertion
})
});
// this worked for me
@endymion1818
endymion1818 / config.sh
Created February 8, 2022 16:21
some handy aliases
alias grum="git checkout master && git pull --all"
alias gc="git commit"
alias ga="git add"
alias gp="git push"
alias k="kubectl"
@endymion1818
endymion1818 / doabarrelroll.js
Created April 30, 2022 20:02
do a barrel roll invoke via spacebar
(function() {
var styles = document.createElement("style");
styles.innerHTML = "@-moz-keyframes roll{100%{-moz-transform:rotate(360deg)}}@-o-keyframes roll{100%{-o-transform:rotate(360deg)}}@-webkit-keyframes roll{100%{-webkit-transform:rotate(360deg)}}.do-a-barrel-roll{-moz-animation-duration:2s;-moz-animation-name:roll;-moz-animation-iteration-count:1;-webkit-animation-duration:2s;-webkit-animation-name:roll;-webkit-animation-iteration-count:1;-o-animation-duration:2s;-o-animation-name:roll;-o-animation-iteration-count:1}";
document.getElementsByTagName("body")[0].appendChild(styles);
var interval;
var keyed = "";
document.addEventListener("keypress", function(event) {
if (event.charCode === 32) {
@endymion1818
endymion1818 / theme.js
Last active April 19, 2023 10:43
toggles
document.addEventListener("DOMContentLoaded", function() {
// Theme Toggle
const themeToggle = document.getElementById("dark-mode-toggle");
const themeToggleCircle = document.getElementById("dark-mode-toggle-circle");
// Check if the user has set a theme preference set in localStorage or if the browser preferences
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
} else {
@endymion1818
endymion1818 / toggle.html
Created April 27, 2023 13:06
tailwind toggle with pseudoelements
<span class="tw-flex tw-items-center tw-cursor-pointer">
<label for="autoplay" class="tw-text-xs tw-font-medium tw-text-zinc-400 dark:tw-text-zinc-500 tw-mr-2">Autoplay</label>
<input type="checkbox" id="autoplay" class="tw-bg-zinc-200 tw-relative tw-inline-flex tw-h-6 tw-w-11 tw-flex-shrink-0 tw-cursor-pointer tw-rounded-full tw-border-2 tw-border-transparent tw-transition-colors tw-duration-200 tw-ease-in-out focus:tw-outline-none focus:tw-ring-2 focus:tw-ring-primary-600 focus:tw-ring-offset-2 before:tw-content-[''] before:tw-translate-x-0 before:tw-pointer-events-none before:tw-inline-block before:tw-h-5 before:tw-w-5 before:tw-transform before:tw-rounded-full before:tw-bg-white before:tw-shadow before:tw-ring-0 before:tw-transition before:tw-duration-200 before:tw-ease-in-out before:tw-relative before:tw-z-10 checked:before:tw-translate-x-5 checked:tw-bg-zinc-200 checked:tw-text-zinc-200 checked:focus:tw-text-primary-600 checked:after:tw-block checked:after:tw-content-[''] checked:after:tw-bg-zin
@endymion1818
endymion1818 / index.d.ts
Created July 27, 2023 14:20
Pick only one
type RequireOnlyOne<T, Keys extends keyof T = keyof T> =
Pick<T, Exclude<keyof T, Keys>>
& {
[K in Keys]-?:
Required<Pick<T, K>>
& Partial<Record<Exclude<Keys, K>, undefined>>
}[Keys]
type Events = 'play' | 'pause' | 'ready' | 'seek' | 'end';