Skip to content

Instantly share code, notes, and snippets.

Avatar

Evil Buck evilbuck

  • evilbuck llc
  • West Palm Beach, FL
View GitHub Profile
@evilbuck
evilbuck / index.js
Created Aug 30, 2021 — forked from stalniy/index.js
CASL + Objection
View index.js
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:'
View port forward from wsl2
@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 / bull-rate-limit-test.js
Created Feb 15, 2021
rate limiting bull queue example
View bull-rate-limit-test.js
const Bull = require('bull');
const queue = new Bull('test', {
limiter: {
max: 1,
duration: 1000
}
});
queue.process(async job => {
View .zshrc
# 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
View windows.terminal.profiles.json
// 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}",
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@evilbuck
evilbuck / .gitconfig
Last active Mar 11, 2020 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
View .gitconfig
[alias]
co = checkout
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"
st = status
@evilbuck
evilbuck / adapter-pattern-munging-data.example.js
Created Jun 27, 2019
Adapter pattern in javascript using data munging example.
View adapter-pattern-munging-data.example.js
const v1Data = {
metrics: {
weightLb: 400,
heightFt: 6
},
macros: {
gramsFat: 1000
}
};
@evilbuck
evilbuck / adapter-pattern-munging-data.example.js
Last active Jun 27, 2019
An adapter pattern example for munging data with javascript.
View adapter-pattern-munging-data.example.js
const v1Data = {
metrics: {
weightLb: 400,
heightFt: 6
},
macros: {
gramsFat: 1000
}
};
@evilbuck
evilbuck / serverless.rds.example.yml
Created Jun 13, 2019
serverless.yml example with rds resources plus more
View serverless.rds.example.yml
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com