Skip to content

Instantly share code, notes, and snippets.

@dbernheisel
dbernheisel / mass-expire-redis.sh
Last active October 8, 2019 17:34
Expire redis keys en-masse
#!/bin/bash
# Mass expire Redis keys using the SCAN command so it doesn't block or overwhelm
# memory
# Usage example: ./mass-expire-redis.sh "127.0.0.1" "6379" "mykey:*" "300"
# Logs to ./filename.ext.log
if [ $# -ne 4 ]; then
echo "Usage: $0 <host> <port> <pattern> <expiration>"
exit 1
@dbernheisel
dbernheisel / install-old-ruby.sh
Last active September 20, 2020 14:58
Installing old Ruby with old OpenSSL requires a couple flags. Here they are.
# Install prerequisites. I'm using arch, but you can do similar things with brew but paths change.
yay gcc6
pacman -S openssl-1.0
OPENSSL_DIR="/usr/lib/openssl-1.0"
# If you're on mac and installed with brew, you can do this:
# OPENSSL_DIR=$(brew --prefix openssl-1.0)
# A patch to let older Ruby to work with newer OpenSSL
SSL_PATCH="https://gist.github.com/mislav/055441129184a1512bb5/raw"
@dbernheisel
dbernheisel / myapp.conf
Created September 20, 2019 14:46
nginx phoenix app
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream myapp {
server localhost:4000;
}
server {

Keybase proof

I hereby claim:

  • I am dbernheisel on github.
  • I am dbernheisel (https://keybase.io/dbernheisel) on keybase.
  • I have a public key whose fingerprint is 4384 A7D5 19AF C609 E3A0 69D6 437A ABB7 7302 C206

To claim this, I am signing this object:

@dbernheisel
dbernheisel / interface.rb
Created November 29, 2018 14:51
Interfaces in Ruby
module Interface
# For this module to be useful, it'll need to be prepended. For example, if
# you create a CardInterface:
#
# module CardInterface
# extend Interface
# method :photo, returns: [Photo, NilClass]
# end
#
# prepend it to the class:
@dbernheisel
dbernheisel / bump-version.sh
Last active January 15, 2024 03:16
Bash script to bump the version
#!/bin/bash
# Works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or use a newly entered value.
@dbernheisel
dbernheisel / elixirconf-2018.md
Last active February 26, 2019 05:33
Notes from ElixirConf 2018

ElixirConf 2018

Short Version

Elixir in the Next 5 Years - Jose Valim Video

  • Earlier
  • Community is getting better. New podcasts, frameworks, and faster compilation.
@dbernheisel
dbernheisel / check-tool-version.sh
Last active September 20, 2018 14:43
Tool version checker script
#!/bin/bash
LANGUAGES="erlang elixir nodejs"
get_tool_version() {
grep "$1" .tool-versions | awk '{print $2}'
}
has_matching_versions() {
# Usage: has_matching_versions DEPTH VERSION1 VERSION2
@dbernheisel
dbernheisel / circleci.yml
Last active August 20, 2018 14:32
Ruby, npm/yarn, rspec CircleCI 2.0 Workflows
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
# Include the gem 'rspec_junit_formatter' in your test group for circleci to read test results and present them nicely
# Include the gem 'capybara-screenshot' in your test group for screenshot artifacts
version: 2
defaults: &defaults
@dbernheisel
dbernheisel / 2017-04-24-Intro-Elixir-Macros.md
Created November 30, 2017 23:13
Markdown presentation of Elixir Macros