Skip to content

Instantly share code, notes, and snippets.

View chris-roerig's full-sized avatar
😎
💯

Chris Roerig chris-roerig

😎
💯
View GitHub Profile
@chris-roerig
chris-roerig / update-minecraft-launcher.sh
Created September 4, 2020 20:38
Script to download and install deb packge of Minecraft
#!/bin/bash
# This script will pull the latest Minecraft.deb file from Mojang and install it.
# I put this on a cron to run every week. I created this because I was tired of having
# to update the launcher every time I opened it.
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
@chris-roerig
chris-roerig / ruby-2_6_0-docs-details.md
Last active June 9, 2019 15:12
Description level Ruby 2.6.0 documentation

    
Simple Access Control Lists.

Access control lists are composed of “allow” and “deny” halves to control access.  Use “all” or “*” to match any address.  To match a specific address use any address or address mask that IPAddr can understand.

Example:
@chris-roerig
chris-roerig / recipe.rb
Last active October 18, 2018 16:25
Automate vimrc and VundleInstall with Chef
remote_file "/home/chris/.vimrc" do
source "https://raw.githubusercontent.com/chris-roerig/dotfiles/master/vimrc"
owner "chris"
group "chris"
mode "0755"
end
directory "/home/chris/.vim/bundle/" do
owner "chris"
group "chris"
@chris-roerig
chris-roerig / initializer_paperclip.rb
Last active June 27, 2017 15:39
Rails 4 S3 Paperclip initializer
# Gemfile
# gem "aws-sdk"
# gem 'paperclip', :git=> 'https://github.com/thoughtbot/paperclip', :ref => '523bd46c768226893f23889079a7aa9c73b57d68'
# config/initializers/paperclip.rb
Paperclip::Attachment.default_options.update({
storage: :s3,
s3_protocol: 'https',
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@chris-roerig
chris-roerig / log_to.rb
Created February 13, 2017 17:13
Log to a specific file in Rails
# Logs to the specified file in the Rails log folder
#
# Usage:
# LogTo.file("tracking-numbers").info "log some data"
# or
# logger = LogTo.file("tracking-numbers")
# logger.info "this is saved in my tracking-numbers log"
class LogTo
def self.file(name)
return Rails.logger if Rails.env.test?
@mcfdn
mcfdn / Multiple Deploy Keys in GitHub.md
Last active November 21, 2022 14:02
Using multiple GitHub deploy keys on a single server with a single user

Using multiple GitHub deploy keys on a single server with a single user

Within GitHub it is possible to set up two types of SSH key - account level SSH keys and and repository level SSH keys. These repository level SSH keys are known in GitHub as deploy keys.

Deploy keys are useful for deploying code because they do not rely on an individual user account, which is susceptible to change, to “store” the server keys.

There is, however, an ‘issue’ with using deploy keys; each key across all repositories on GitHub must be unique. No one key can be used more than once. This becomes a problem when deploying to repositories to the same server with the same user. If you create two keys, the SSH client will not know which key to use when connecting to GitHub.

One solution is to use an SSH config file to define which key to use in which situation. This isn’t as easy as it seems.. you might try something like this:

@eloo
eloo / node_exporter.default
Last active December 22, 2023 09:00
Init.d script for prometheus node exporter
# Set the command-line arguments to pass to the server.
ARGS='-web.listen-address=:9100 -collector.diskstats.ignored-devices="^(ram|loop|fd)\\d+$"'
# Prometheus-node-exporter supports the following options:
# -collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z])\\d+$": Regexp of devices to ignore for diskstats.
# -collector.filesystem.ignored-mount-points="^/(sys|proc|dev)($|/)": Regexp of mount points to ignore for filesystem collector.
# -collector.ipvs.procfs="/proc": procfs mountpoint.
# -collector.megacli.command="megacli": Command to run megacli.
# -collector.ntp.server="": NTP server to use for ntp collector.
# -collector.textfile.directory="": Directory to read text files with metrics from.
@chris-roerig
chris-roerig / ruby_macro_methds.rb
Last active July 14, 2020 20:59
How to add macro style methods to a rails model
# Rails Concern
# models/concerns/nicknameable.rb
module Nicknameable
extend ActiveSupport::Concern
included do
def self.nicknames(*args)
define_method("nicknames") { args }
end
nicknames
@juliandunn
juliandunn / post-mortem-template.md
Created April 29, 2015 00:53
Post mortem template

INCIDENT DATE - INCIDENT TYPE

Meeting

Waiving meetings

In some cases the IC might determine that a PM meeting for the incident isn't needed. If the IC decides to waive the meeting please replace the Meeting section with a note indicating the meeting has been waived (example: Meeting waived: Paul Mooring)