Skip to content

Instantly share code, notes, and snippets.

View flanger001's full-sized avatar
🧱

David Shaffer flanger001

🧱
View GitHub Profile
@flanger001
flanger001 / integer_extensions.rb
Created January 11, 2024 20:16
Binary nonsense
# frozen_string_literal: true
module IntegerExtensions
refine Integer do
def as_binary_string(width = nil)
width ||= self.bit_length
"%0#{width}b" % self
end
def as_byte
- name: LD-47K
brand_name: Neumann
model: U47
description: Created in 1947, Neumann U47 has stood the test of time as the ultimate studio mic. Extensively used by The Beatles, Frank Sinatra, and countless others, only about 6,000 of these mics were produced. The Neumann U47 analyzed for this model has a fully brass capsule with a screw-mounted mylar diaphragm and a genuine VF14 tube.
- name: LD-87
brand_name: Neumann
model: U87
description: The Neumann U87 was brought to market as a replacement for the U67, even though it sounds quite different. The LD-87 model is based on a mid-’70s version with a split backplate capsule which sounds slightly different from a modern 87. The high-pass filter and pad switch settings are also fully modeled.
- name: LD-87 Modern
brand_name: Neumann
trap("SIGINT") { exit! }
total_width = `stty size`.scan(/\d+/)[1].to_i # terminal width
snokflakes = {}
puts "\033[2J"; # clearing output
loop do
snokflakes[rand(total_width)] = 0
@flanger001
flanger001 / containers.js
Last active August 7, 2023 16:40
If you use Firefox Multi-Account Containers with Firefox sync, sometimes you will get a number of extra containers, even thousands of them. Run this in the devtools console in the Firefox containers section `about:preferences#containers`. Add your own container tags on line 48.
let removeContainers = (...containers) => {
let items, isValid, removeButtons;
items = document.querySelectorAll("#browserContainersGroupPane richlistitem");
isValid = (el) => typeof (el) != "undefined" || el != null;
removeButtons = [];
items.forEach((el, idx) =>
{
const hbox_1 = el.getElementsByTagName("hbox").item(0);

TIL if you have decided Elasticsearch maybe shouldn't get 50% of your RAM on your local machine you can adjust it with JVM options:

$ elasticsearch_path="$(brew --prefix)/etc/elasticsearch" # Assuming a Homebrew install on a Mac
$ mkdir -p $elasticsearch_path/jvm.options.d && echo "-Xms2g\n-Xmx2g" > $elasticsearch_path/jvm.options.d/heap.options
$ unset elasticsearch_path

Then restart the server:

@flanger001
flanger001 / mysql
Last active April 13, 2022 12:51
Installing MySQL on macOS
MySQL
If the mysql2 gem fails to install, be sure your Xcode Command Line Tools are installed:
$ xcode-select --install
Then try reinstalling the gem with either of these 3 commands:
$ gem install mysql2 -- \
--with-cflags=\"-I$(brew --prefix)/opt/openssl/include\" \
@flanger001
flanger001 / development.rb
Last active May 27, 2020 17:50
This exists because Paperclip emits a lot of 404 errors if you clone your development db from production. If you do not clone your development db from production, you probably should not use this.
require "middleware/paperclip_middleware"
Rails.application.configure do
# other stuff
config.middleware.use(PaperclipMiddleware)
end
@flanger001
flanger001 / gem_update.rb
Last active April 30, 2020 19:11
Gem update script. Put this in bin/gem_update and chmod +x bin/gem_update. Thanks to https://www.honeybadger.io/blog/capturing-stdout-stderr-from-shell-commands-via-ruby/
#!/usr/bin/env ruby
require "open3"
puts "Create new branch? (press y to continue)"
print "> "
if gets.chomp.casecmp?("y")
system("git checkout master")
system("git branch -D gems/outdated")
system("git checkout -b gems/outdated")
@flanger001
flanger001 / adding_a_key.md
Last active October 15, 2018 16:28
PGP stuff

Adding a new PGP key

Scenario:

I have a key that is currently on two computers. I want to do these things:

  • Create a new key with better security
  • Sign my old key with my new key
  • Revoke my old key
  • Export both keys
@flanger001
flanger001 / btw.md
Last active October 15, 2018 02:03
Babel + Typescript + Webpack resources