Skip to content

Instantly share code, notes, and snippets.

View dpneumo's full-sized avatar

Mitch Kuppinger dpneumo

  • Arlington, TX
View GitHub Profile
dpneumo / edge.rb
Created February 20, 2023 13:24
AoC 2022 Day16 Part1
View edge.rb
class Edge
attr_reader :start, :to, :dist
def initialize(start:, to:, dist:)
@start = start
@to = to
@dist = dist
dpneumo / !Geocode an Address
Last active January 13, 2021 02:45
Geocode an address hash with Google geocode api
View !Geocode an Address
I needed a tool to add latitude and longitude to seeds.rb in a Rails application.
geocoder.rb uses the Google geocode api. An apikey is required. For limited use it is free. The apikey should be protected from prying eyes. (encryption, .gitignore, ...)
Geocoder#geocode takes an address string in canonical form ( "#{number} #{street} #{city} #{state}" ) as input. It returns latitude and longitude as a hash: { lat: 30.0000, lng: -90.000 }
seed_geocoder.rb extracts the address string from seeds.rb, requests the geocode hash from the Geocoder obj and writes the newseeds.rb file.
The newseeds file does need some minor additional work to make it a functional seeds.rb.
dpneumo / README
Last active March 25, 2019 05:56
Create a root CA cert, an intermediate CA cert, and a server cert
Copy the 4 scripts to /home/<user>
From /home/<user>:
ipaddr=$(ip route get | awk '{print $7}')
SUBJ_IP=$ipaddr ./
This will:
dpneumo / 40-redis.conf
Created January 2, 2019 00:53
Multi-instance Redis on one host (Centos7)
View 40-redis.conf
# Redis sysctl configuration
vm.overcommit_memory = 1
dpneumo /
Created November 11, 2018 03:44
Session setup Rails 5.2

Session in Rails 5.2

  • Expiration:

    • Absolute age
      • In config/initializers/session_store.rb:
      Rails.application.config.session_store  :cookie_store,
        key: '_cirrus_session',
        expire_after: 1.days,
dpneumo / certfiles.txt
Created October 22, 2018 00:38
cloud-init problem
View certfiles.txt
[loco@td2 ~]$ sudo cat certfiles.txt
[sudo] password for loco:
total 8
4 -rw-r--r--. 1 root root 2240 Oct 21 23:21 stratuscert.pem
4 -rw-r--r--. 1 root root 2496 Oct 21 23:21 blacklakecacert.pem
dpneumo / Vagrantfile
Last active October 20, 2018 16:14
Adjust Vagrant network setup to environment at vm startup
View Vagrantfile
# Defines our Vagrant environment
# -*- mode: ruby -*-
# vi: set ft=ruby :
require_relative 'bridged_interfaces'
Vagrant.configure("2") do |config|
# create wisp node
config.vm.define :wisp do |wisp|
dpneumo /
Last active February 18, 2022 08:18
Modify cloud-init phone_home module to return a created server's public key for insertion into known_hosts. Works with cloud-iniit version 0.7.9 and later.
# Diff of the original cc_phone_home and the slightly modified version that supports
# including the server pub_keys in the phone_home payload
# Original:
# A couple of typos in comment lines in the original were elided to make the diff a bit clearer.
# The Centos7 distros I am using do not provide pub_key_dsa.
# I am talking to a Rails app with phone_home.
# A dummy X-CSRF-Token: 1234567890 in the headers simplifies the code on the Rails side.
# I authenticate the phone_home payload by including a token provided in the
dpneumo /
Last active September 11, 2019 17:00
Setup User Namespaces for docker on RHEL/Centos 7.3

On CentOS 7.3 with Kernel Version: 3.10.0

1. Allow filesystem support for namespaces: xfs partition: format with ``` mkfs.xfs -m crc=1 -n ftype=1 ``` The current CentOS 7 does this by default.
dpneumo / gist:519a85ce7dfd4124ad605db37cd9a6b2
Created April 8, 2016 18:00
otto dev fails immediately. Output with VAGRANT_LOG=debug & OTTO_LOG=true
View gist:519a85ce7dfd4124ad605db37cd9a6b2
E:\Projects\otto-getting-started>otto dev
2016/04/08 12:50:33 [INFO] Otto version: 0.2.0 4ff0dce79f07008dcebcf34f118e8ec3dc4f96a5+CHANGES
2016/04/08 12:50:33 [DEBUG] Starting plugin: C:\otto_0.2.0_windows_386\otto.exe []string{"C:\\otto_0.2.0_windows_386\\otto.exe", "plugin-builtin", "app-ruby"}
2016/04/08 12:50:33 [DEBUG] Waiting for RPC address for: C:\otto_0.2.0_windows_386\otto.exe
2016/04/08 12:50:33 [DEBUG] otto.exe: 2016/04/08 12:50:33 [INFO] Otto version: 0.2.0 4ff0dce79f07008dcebcf34f118e8ec3dc4f96a5+CHANGES
2016/04/08 12:50:33 [DEBUG] otto.exe: 2016/04/08 12:50:33 Plugin address: tcp
2016/04/08 12:50:33 [DEBUG] reading IP, cache path: E:\Projects\otto-getting-started\.otto\data\dev_ip
2016/04/08 12:50:33 [DEBUG] read ip from cache:
2016/04/08 12:50:33 [INFO] Loading app implementation for Tuple: ("ruby", "aws", "simple")
2016/04/08 12:50:33 [DEBUG] core walking app: otto-getting-started