Skip to content

Instantly share code, notes, and snippets.

View evilbuck's full-sized avatar

Evil Buck evilbuck

  • evilbuck llc
  • Hobe Sound, FL
View GitHub Profile
@evilbuck
evilbuck / adapter-pattern-munging-data.example.js
Created June 27, 2019 13:33
Adapter pattern in javascript using data munging example.
const v1Data = {
metrics: {
weightLb: 400,
heightFt: 6
},
macros: {
gramsFat: 1000
}
};
@evilbuck
evilbuck / .gitconfig
Last active September 21, 2021 18:45 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
[alias]
co = checkout
ci = commit
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
dmerged = "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
@evilbuck
evilbuck / machine.js
Created September 3, 2019 23:19
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
//"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
// "defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"defaultProfile": "{7f586916-8357-53d4-bb2b-ca96f639898a}",
"profiles": [
{
"guid": "{7f586916-8357-53d4-bb2b-ca96f639898a}",
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/evilbuck/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@evilbuck
evilbuck / bull-rate-limit-test.js
Created February 15, 2021 17:31
rate limiting bull queue example
const Bull = require('bull');
const queue = new Bull('test', {
limiter: {
max: 1,
duration: 1000
}
});
queue.process(async job => {
@ECHO OFF
SET LXDISTRO=WLinux & SET WSL2PORT=3000 & SET HOSTPORT=3000
NETSH INTERFACE PORTPROXY RESET & NETSH AdvFirewall Firewall delete rule name="%LXDISTRO% Port Forward" > NUL
WSL -d %LXDISTRO% -- ip addr show eth0 ^| grep -oP '(?^<=inet\s)\d+(\.\d+){3}' > IP.TMP
SET /p IP=<IP.TMP
NETSH INTERFACE PORTPROXY ADD v4tov4 listenport=%HOSTPORT% listenaddress=0.0.0.0 connectport=%WSL2PORT% connectaddress=%IP%
NETSH AdvFirewall Firewall add rule name="%LXDISTRO% Port Forward" dir=in action=allow protocol=TCP localport=%HOSTPORT% > NUL
ECHO WSL2 Virtual Machine %IP%:%WSL2PORT%now accepting traffic on %COMPUTERNAME%:%HOSTPORT%
@evilbuck
evilbuck / index.js
Created August 30, 2021 14:36 — forked from stalniy/index.js
CASL + Objection
const { defineAbility } = require('@casl/ability');
const { rulesToQuery } = require('@casl/ability/extra');
const Knex = require('knex');
const { Model } = require('objection');
const { interpret } = require('@ucast/objection')
const { CompoundCondition } = require('@ucast/core')
const knex = Knex({
client: 'sqlite3',
connection: ':memory:'
@evilbuck
evilbuck / BaseWebComponent.js
Created April 14, 2023 16:33
Web Component
import _ from 'lodash';
export default class BaseWebComponent extends HTMLElement {
store = null;
events = [];
_previouslyRendered = false;
constructor({ controller, model, store, template }) {
super();
this.store = store;
@evilbuck
evilbuck / git-ancestor.sh
Created October 6, 2023 15:48
Git: Find the nearest ancestor branch
# Another way to phrase the question is
# "What is the nearest commit that resides on a branch other than the current branch,
# and which branch is that?"
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/[^\[]*//' \
| awk 'match($0, /\[[a-zA-Z0-9\/.-]+\]/) { print substr( $0, RSTART+1, RLENGTH-2 )}'