Skip to content

Instantly share code, notes, and snippets.

View midwire's full-sized avatar
🏠
Working from home

Chris Blackburn midwire

🏠
Working from home
View GitHub Profile
@midwire
midwire / renew-cert.sh
Last active October 8, 2021 17:02
[Lets Encrypt Cert Renewal] #linux #ssl #certbot
certbot certonly --agree-tos --email <email> --webroot -w /var/lib/letsencrypt/ -d <domain> -d www.<domain>
@midwire
midwire / split_certs.sh
Created September 14, 2021 21:07
[Split SSL (.PFX) Certificates] #bash #ssl
# will need to supply passwords through stdin
pfx_to_crt_key() {
openssl pkcs12 -in $@ -nocerts -out extracted_encrypted.key
openssl pkcs12 -in $@ -clcerts -nokeys -out extracted.crt
openssl rsa -in extracted_encrypted.key -out extracted_decrypted.key
}
@midwire
midwire / vpn.conf
Created August 18, 2021 23:05
[Wireguard VPN exclude local subnets] Works with Algo VPN #vpn #wireguard #algo
[Interface]
PrivateKey = <KEY-HERE>
Address = <IP-HERE>, <IP6-HERE>
DNS = <ETC>
# Customize to taste:
PostUp = route add -net 192.168.107.0 netmask 255.255.255.0 gw 192.168.1.1 metric 600 dev wlp5s0
PreDown = route del -net 192.168.107.0/24
@midwire
midwire / excellent.sql
Created August 11, 2021 17:57
[Select first row in each GROUP BY group] #postgres #sql
-- https://stackoverflow.com/questions/3800551/select-first-row-in-each-group-by-group
-- Can be a good way to find the oldest duplicate records et. al.
SELECT DISTINCT ON (customer)
id, customer, total
FROM purchases
ORDER BY customer, total DESC, id;
@midwire
midwire / update-ruby-build.sh
Created July 28, 2021 17:21
[Update ruby-build/rbenv versions] #rbenv
git -C "$(rbenv root)"/plugins/ruby-build pull
@midwire
midwire / form.vue
Last active July 3, 2021 16:19
[Vue 3 Idioms] #vue #vue3
<template>
<h1>Create an event</h1>
<div class="form-container">
// Vue form
<form @submit.prevent="onSubmit">
<label>Select a category: </label>
<select v-model="event.category">
<option
v-for="option in categories"
:value="option"
@midwire
midwire / test_spec.rb
Created July 2, 2021 18:41
[RSpec frequently used code] #rspec #ruby
# Stub and Call the original
expect(object).to receive(:some_method).and_call_original
expect(object).to receive(:some_method).with(2,3),and_call_original
expect(object).to receive(:some_method).at_least(3).times.with(2,3),and_call_original
# Counts
expect(object).to receive(:some_method).once
expect(object).to receive(:some_method).twice
expect(object).to receive(:some_method).exactly(n).times
expect(object).to receive(:some_method).at_least(n).times
@midwire
midwire / vue_commands.sh
Last active June 25, 2021 16:30
[Vue CLI commands] #vue #javascript #command
# Create a new Vue app
vue create APPNAME
@midwire
midwire / change-postgres-user-pw.sh
Last active June 22, 2021 16:27
[Change postgres user password] #postgres #linux
sudo su - postgres
psql -d template1
alter user postgres with password 'new password';
exit # psql
exit # postgres login shell
systemctl restart postgresql
@midwire
midwire / stub_referrer_spec.rb
Created June 21, 2021 19:33
[Stub request.referrer in RSpec Controller Spec] #ruby #rails #rspec
allow_any_instance_of(ActionController::TestRequest).to receive(:referrer) { 'whatever' }