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 / 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 )}'
@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 / .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 / 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:'
@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 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 => {
@evilbuck
evilbuck / tap.js
Created November 15, 2012 20:50
javascript implementation of Ruby 1.9's tap
Object.defineProperty(Object.prototype, 'tap', {
value: function(fun){
fun.call( this );
return this;
},
enumerable: false
});
// Usage:
// a = [];
// 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}",
/* global window document localStorage fetch alert */
// Fill in with your values
const AUTH0_CLIENT_ID = 'your-auth0-client-id-here';
const AUTH0_DOMAIN = 'your-auth0-domain-here.auth0.com';
const AUTH0_CALLBACK_URL = window.location.href; // eslint-disable-line
const PUBLIC_ENDPOINT = 'https://your-aws-endpoint-here.amazonaws.com/dev/api/public';
const PRIVATE_ENDPOINT = 'https://your-aws-endpoint-here.us-east-1.amazonaws.com/dev/api/private';
// initialize auth0 lock
@evilbuck
evilbuck / git-selective-merge.md
Created February 27, 2019 16:03 — forked from katylava/git-selective-merge.md
git selective merge

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

On master:

> git co -b temp