Skip to content

Instantly share code, notes, and snippets.

@bbugh
bbugh / test.sh
Created March 19, 2019 16:29
Find out what process is using the "Too many open files" issue on Mac
# taken from this answer on stack exchange: https://superuser.com/a/1180084
# This will show the number of files open by all of the processes
sudo lsof -n | cut -f1 -d' ' | uniq -c | sort | tail
# When you find out which one is using the most files, see what files are being used by it
sudo lsof -n | grep java
# In my case, it's always java because elasticsearch doesn't clean up after being on for weeks, I guess
brew services restart elasticsearch
@bbugh
bbugh / waitForKeyElements.js
Created April 11, 2019 12:16 — forked from mjblay/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content. Forked for use without JQuery.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
//--- Page-specific function to do what we want when the node is found.
function commentCallbackFunction (element) {
element.text ("This comment changed by waitForKeyElements().");
@bbugh
bbugh / union_scope.rb
Created July 29, 2019 20:46
Rails ActiveRecord UNION scope extension - adds chainable union functionality to ActiveRecord
# MIT License, Copyright (c) 2019 Brian Bugh
# Do a UNION on two or more scopes, combining the results. Unlike Rails arel
# unions/`or`, this will preserve the ActiveRecord_Relation and allows for
# `joins` and `references`. It can also be chained with a scope without issue.
#
# NOTE: the scope `select` for each union must match; you can't select a smaller
# column subset and UNION it (this is a limitation of SQL).
#
# ==== Examples
@bbugh
bbugh / FormulateFieldset.vue
Last active October 14, 2020 18:38
vue-formulate fieldset for capturing slot data in a named subgroup object rather than array
<template>
<FormulateSlot
name="grouping"
:class="context.classes.grouping"
:context="context">
<FormulateRepeatableProvider
:index="0"
:set-field-value="(field, value) => setFieldValue(field, value)"
:context="context"
@bbugh
bbugh / earthly.plugin.zsh
Created August 18, 2022 13:23
Earthly aliases
alias 'e'="earthly"
alias 'ealias'="alias | grep --color=never earthly"
alias 'ea'='earthly account'
alias 'eac'='earthly account create'
alias 'eah'='earthly account help'
alias 'eai'='earthly account invite'
alias 'ealp'='earthly account list-permissions'
alias 'eals'='earthly account ls'
alias 'ear'='earthly account revoke'
@bbugh
bbugh / draw.io_export.bttpreset
Created December 15, 2023 16:14
BetterTouchTool Cmd+/- zooming for draw.io
[
{
"BTTAppBundleIdentifier" : "com.jgraph.drawio.desktop",
"BTTAppName" : "draw.io",
"BTTAppAutoInvertIcon" : 1,
"BTTAppProcessMatchMode" : 2,
"BTTAppProcessName" : "draw.io",
"BTTTriggers" : [
{
"BTTLastUpdatedAt" : 1702656741.3490081,