Skip to content

Instantly share code, notes, and snippets.

View Drumstix42's full-sized avatar
๐Ÿ•

Drumstix42 Drumstix42

๐Ÿ•
View GitHub Profile
@Drumstix42
Drumstix42 / .bashrc
Created December 19, 2024 02:31
Load nvm version based on nvmrc for Windows
# ------------------------------------------------------
# Load proper nvm version if a nvmrc is given on WINDOWS
# ------------------------------------------------------
load-nvmrc() {
if [[ -f .nvmrc && -r .nvmrc ]]; then
declare version;
version="$(< .nvmrc)";
if [ -z "$(node -v | grep $version)" ]; then
if [ -z "$(nvm list | grep $version)" ]; then
echo "Node $version is not currently installed through nvm. Installing.";
\documentclass[11pt, oneside]{article}
\usepackage[margin=0.5in]{geometry}
\geometry{letterpaper}
\usepackage[parfill]{parskip}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{xcolor}
\pagecolor{white}
\usepackage[colorlinks = true, linkcolor = blue, urlcolor = blue]{hyperref}
\pagestyle{empty}
@Drumstix42
Drumstix42 / vueWrapper.js
Created February 27, 2022 09:02 — forked from BabOuDev/vueWrapper.js
AngularJS directive wrapper for VueJS components
import Vue from 'vue'
// the list of vue components to install
import components from './vueComponents'
class SlVueWrapper {
constructor($timeout) {
this.name = 'vue';
this.restrict = 'A';
this.terminal = true;
@Drumstix42
Drumstix42 / github-export-labels.js
Created September 4, 2020 22:33 — forked from douglascayers/github-export-labels.js
Export and import GitHub labels between projects by running JavaScript in the browser console to automate clicks.
/**
* Inspired by @MoOx original script: https://gist.github.com/MoOx/93c2853fee760f42d97f
* Adds file download per @micalevisk https://gist.github.com/MoOx/93c2853fee760f42d97f#gistcomment-2660220
*
* Changes include:
* - Get the description from the `title` attribute instead of `aria-label` (doesn't exist anymore)
* - Use style.backgroundColor and parse the rgb(...) to hex (rather than regex parsing of 'style' string)
* - Downloads labels to a JSON file named after the webpage to know which GitHub repo they came from.
*
* Last tested 2019-July-27:
@Drumstix42
Drumstix42 / settings.jsonc
Last active April 14, 2020 21:43
VSCode settings.json
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"window.restoreWindows": "all",
"window.newWindowDimensions": "inherit",
// Inconsolata: https://levien.com/type/myfonts/inconsolata.html
"editor.fontFamily": "Inconsolata, Consolas, 'Courier New', monospace",
"editor.fontSize": 16, // 15 without Inconsolata
"editor.lineHeight": 21, // recommended to reset to default without Inconsolata
@Drumstix42
Drumstix42 / getRandomArrayItem.js
Last active October 24, 2019 04:04
Get random item from an Array
const getCryptoRandomValue = () => crypto.getRandomValues(new Uint32Array(1))[0]/Math.pow(2, 32);
const getRandomArrayItem = a => a[getCryptoRandomValue()*a.length|0];
const array = [1,2,3,4,5];
console.log(getRandomArrayItem(array));
@Drumstix42
Drumstix42 / keyboard_code_enums.js
Created August 19, 2019 01:33 — forked from cjcliffe/keyboard_code_enums.js
Javascript Keycode Enums
var enums = {};
enums.keyboard = {
BACKSPACE: 8,
TAB: 9,
ENTER: 13,
SHIFT: 16,
CTRL: 17,
ALT: 18,
PAUSE: 19,
CAPS_LOCK: 20,
@Drumstix42
Drumstix42 / pipe.js
Created June 10, 2019 02:20
Pipe function one-liner
const pipe = (fn,...fns) => (...args) => !fns.length ? fn(...args) : pipe(...fns)(fn(...args));
// example: pipe(function1, function2)
@Drumstix42
Drumstix42 / isElementOverlapping.js
Last active May 30, 2019 00:59
Check if two elements are overlapping one another, based on their position relative to the viewport.
function isElementOverlapping(elem1, elem2) {
var rect1 = elem1.getBoundingClientRect();
var rect2 = elem2.getBoundingClientRect();
return !(
rect1.right < rect2.left ||
rect1.left > rect2.right ||
rect1.bottom < rect2.top ||
rect1.top > rect2.bottom
);
};