Skip to content

Instantly share code, notes, and snippets.

DKIM Keypair Generation

Creates an RSA keypair and extract its public key for DKIM publication via DNS.

Assumes Linux or a similar operating system and bash or a similar shell.

Uses openssl, sed, tr, and paste.

The name example can be replaced with whatever you choose.

Keybase proof

I hereby claim:

  • I am curt on github.
  • I am curtgilman (https://keybase.io/curtgilman) on keybase.
  • I have a public key ASA_3jheNPQH2AaV4kfdLM8RoT6HLkFFEvpQnv54MuVEhAo

To claim this, I am signing this object:

@curt
curt / results.ex
Created November 18, 2022 13:37
Elixir, pattern matching in arguments of named function, simple example
defmodule Results do
def strange_results(%{a: 0} = params) do
%{params | a: 1000}
end
def strange_results(params) do
params
end
end
@curt
curt / unzip-wordpress-into-different-folder.sh
Last active April 24, 2017 12:25
Download and install latest WordPress into a target folder other than `wordpress`. In this example, the target folder is called `blog`. This may be helpful if the target folder already exists and has files or subfolders. The folder `wordpress` must not already exist.
wget --no-check-certificate https://wordpress.org/latest.tar.gz
ln -s blog wordpress
tar -xzvf latest.tar.gz
unlink wordpress
@curt
curt / README.markdown
Last active July 3, 2018 00:29
WordPress plugin that replaces http: with https: in any content containing the home URL wherever found in content requested via https.
@curt
curt / email_valid.rb
Created March 18, 2010 15:46
Valid e-mail address in Ruby
require 'tmail'
def email_valid?(email)
TMail::Address.parse(email)
rescue TMail::SyntaxError
false
else
true
end
@curt
curt / capistrano_monit_rails_background_restart.rb
Created February 9, 2010 17:54
Capistrano recipe for restarting Rails background process with Monit
namespace :background do
task :restart do
run "[ -f #{shared_path}/pids/background.pid ] && kill `cat #{shared_path}/pids/background.pid`"
sudo "monit start app_background"
end
end
after "deploy", "background:restart"
@curt
curt / rails_schedules_hourly.crontab
Created February 9, 2010 16:16
Crontab entry for hourly Rails task
1 * * * * /usr/local/bin/rake -f /path/to/app/current/Rakefile RAILS_ENV=production schedules:hourly
@curt
curt / app_background.monitrc
Created February 9, 2010 16:05
Monit service entry for Rails background process
check process app_background
with pidfile "/path/to/app/shared/pids/background.pid"
start program = "/usr/bin/sudo -u user RAILS_ENV=production /usr/local/bin/ruby /path/to/app/current/background_control.rb start"
stop program = "/usr/bin/sudo -u user RAILS_ENV=production /usr/local/bin/ruby /path/to/app/current/background_control.rb stop"
@curt
curt / background_control.rb
Created February 9, 2010 14:49
Daemonize background process in Rails
#!/usr/bin/env ruby
#
# Usage: ruby background_control.rb [start|stop|restart]
#
require 'rubygems'
require 'daemons'
background_file = File.join(File.dirname(__FILE__), 'lib', 'background.rb')