Skip to content

Instantly share code, notes, and snippets.

View HarlemSquirrel's full-sized avatar

Kevin McCormack HarlemSquirrel

View GitHub Profile
@HarlemSquirrel
HarlemSquirrel / docker-compose.yml
Last active July 3, 2022 14:35
Valheim Server Docker Compose file
# https://github.com/sorisum/valheim-server-docker
version: "3.9"
services:
valheim:
image: lloesche/valheim-server
volumes:
- /mnt/valheim:/config
- valheim_data:/opt/valheim
ports:
- "2456-2458:2456-2458/udp"
@HarlemSquirrel
HarlemSquirrel / thingiverse-api-examples.js
Last active May 1, 2022 12:44
Thingiverse API Examples using JavaScript
// https://www.thingiverse.com/developers/rest-api-reference
/*******************************************************************************
* The headers needed for authenticating with the API.
* Get the SECRET_TOKEN using the browser tools of Firefox or Chrome:
* 1. Open the browser tools with F12 or ctrl+shift+i
* 2. Navigate to the Network tab
* 3. Reload a Thingiverse page
* 4. Locate a and select a request to api.thingiverse.com
* 5. Find the request headers and copy the token next to Authorization: Bearer
@HarlemSquirrel
HarlemSquirrel / 50unattended-upgrades
Created August 28, 2018 22:53
Raspbian Unattended Upgrades
// /etc/apt/apt.conf.d/50unattended-upgrades
// Unattended-Upgrade::Origins-Pattern controls which packages are
// upgraded.
//
// Lines below have the format format is "keyword=value,...". A
// package will be upgraded only if the values in its metadata match
// all the supplied keywords in a line. (In other words, omitted
// keywords are wild cards.) The keywords originate from the Release
// file, but several aliases are accepted. The accepted keywords are:
// a,archive,suite (eg, "stable")
@HarlemSquirrel
HarlemSquirrel / rspec-repeat.rb
Created January 5, 2022 22:11
Run one or more specs as many times as you need in a row.
#!/usr/bin/env ruby
##
# Run one or more specs as many times as you need in a row.
#
# The files are loaded just once for speed and
# failure counts are tracked and reported at the end.
#
# Provide the number of times and the file(s).
# i.e.
@HarlemSquirrel
HarlemSquirrel / pre-commit
Last active January 4, 2022 17:58
A pre-commit file for Ruby on Rails applications
#!/bin/bash
#
# A set of commands to run as pre-commit hooks for git.
#
# Save this to .git/hooks/pre-commit and make executable to enable
#
# This will run whenever we run `git commit`.
# To skip this, add `-n` or `--no-verify` flag.
#
@HarlemSquirrel
HarlemSquirrel / find_present.rb
Created November 8, 2021 16:28
Enumerable#find_present extension for Rails
require 'rails'
# Return the first value from the block that evalues to present.
#
# objects = [OpenStruct.new(name: nil), OpenStruct.new(name: ' '), OpenStruct.new(name: 'Matz')]
# objects.find_present(&:name) # => "Matz"
module Enumerable
def find_present(&block)
each do |item|
result = yield(item)
@HarlemSquirrel
HarlemSquirrel / haproxy.cfg
Created November 29, 2018 02:27
HAProxy config with SSL for OctoPi Raspbian Stretch
# /etc/haproxy/haproxy.cfg
global
maxconn 4096
user haproxy
group haproxy
daemon
log 127.0.0.1 local0 debug
# Default SSL material locations
ca-base /etc/ssl/certs
@HarlemSquirrel
HarlemSquirrel / refresh_aws_mfa_creds.rb
Created June 8, 2021 16:04
Refresh AWS MFA credentials
#! /usr/bin/env ruby
##
# Retrieve MFA credentials using the default profile and saving them to the mfa profile.
# Old credentials are removed in this process.
#
require 'json'
AWS_CREDS_FILE_PATH = File.join(ENV['HOME'], '.aws/credentials')
@HarlemSquirrel
HarlemSquirrel / hydrapaper.desktop
Last active April 14, 2021 20:22
HydraPaper desktop menu entry for GNOME and flatpak
[Desktop Entry]
# Place this file in ~/.local/share/applications/
Name=hydrapaper
GenericName=HydraPaper
Comment=A Gtk utility to set two different backgrounds for each monitor on GNOME
Exec=flatpak run org.gabmus.hydrapaper
Terminal=false
Type=Application
StartupNotify=true
# https://github.com/GabMus/HydraPaper/raw/master/data/icons/org.gabmus.hydrapaper.svg
@HarlemSquirrel
HarlemSquirrel / install_hydrapaper_u18.04.sh
Last active February 2, 2021 19:26
Install HydraPaper on Ubuntu 18.04
#!/bin/bash
# Install HydraPaper on Ubuntu 18.04
# No super user access required if flatpak is installed
# HarlemSquirrel.github.io
# Install flatpak
sudo apt install -y flatpak gnome-software-plugin-flatpak
# Add flathub repo for the current user
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo