Skip to content

Instantly share code, notes, and snippets.

@wmakley
wmakley / aws_ses_delivery_method.rb
Last active July 26, 2022 09:12
Use AWS SESv2 SDK as an ActionMailer delivery method (API call instead of SMTP)
# Why?
# * May use same IAM role or account in use for other app features.
# * Avoid sharing same SMTP credentials across multiple apps.
#
# Alternatives:
# * https://github.com/aws/aws-sdk-rails (may be overkill)
#
# Gemfile:
# gem 'aws-sdk-sesv2'
#
@wmakley
wmakley / 12-days.rb
Last active December 24, 2021 20:54
Count the number of times each gift is given
#!/usr/bin/env ruby
verses = {
1 => "Patridges in a pear tree",
2 => "Turtle doves",
3 => "French hens",
4 => "Calling birds",
5 => "Golden rings",
6 => "Geese a layin'",
7 => "Swans a swimmin'",
@wmakley
wmakley / wsl-ssh-agent.sh
Created November 7, 2020 17:19
WSL SSH Agent Workaround
# Start ssh-agent if not started (WSL workaround)
# See: https://superuser.com/questions/1010542/how-to-make-git-not-prompt-for-passphrase-for-ssh-key-on-windows/1421619#1421619
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
@wmakley
wmakley / business-catalyst-dynamic-credit-card-years.liquid
Created November 8, 2017 17:29
Dynamically generated credit card year dropdown for Adobe Business Catalyst
{% assign currentYear = globals.site.dateNow | date: "yyyy" %}
{% for i in (0..10) -%}
{% capture yearIncrement -%}{{currentYear | plus: i}}{% endcapture -%}
<option value="{{yearIncrement}}">{{yearIncrement}}</option>
{% endfor -%}
@wmakley
wmakley / elm_handlers.js
Last active January 2, 2020 17:49
jQuery-based utilities for things that are hard to do in Elm. Modify as desired. It is used in a project that already depends on jQuery, but it only really needs jQuery for attaching event handlers to the app container, and normalizing key press events.
/*
JSCmd.elm
==========
port module JSCmd exposing (..)
port focus : String -> Cmd msg
@wmakley
wmakley / Lessons_Learned_From_a_Year_of_Elm.md
Last active November 15, 2017 18:26
Lessons Learned From a Year of Elm

Lessons Learned From a Year of Elm

These are some of the lessons I wish I had learned when I first picked up Elm, before I wrote a bunch of apps that are now more difficult to maintain than they need to be.

1. Not Everything Needs to be a Package.

Breaking an Elm program up into multiple files just to reduce scrolling does not tend to work out optimally. Evan gave a really cool talk on this called "The life of a file". Files should split organically around data structures, not just to stay short. The reasons we want to keep JavaScript files as short as possible do not apply to Elm.

For example, I've created apps with a file structure like this:

@wmakley
wmakley / Makefile
Last active December 15, 2016 19:33
Example Makefile for Elm with multiple targets
# Assumes 'elm' is in your PATH, and there is a directory called 'src' containing
# your Elm source code in the same directory as this file.
ELM = elm
OUTPUT = ../assets/javascripts/elm # For Rails asset pipeline, but could be anything
SRCS = MyApp.elm MyOtherApp.elm
TARGETS = $(SRCS:.elm=.js)
ELM_STUFF = elm-stuff/exact-dependencies.json
all: $(TARGETS)
@wmakley
wmakley / install-ruby-1.8.7.sh
Last active October 7, 2021 09:41 — forked from silviorelli/gist:ad8e1d80bdc0245eb7e7
Install Ruby 1.8.7 on Mac OSX 10.12 Sierra with rbenv
#!/bin/sh
# The main issues with Ruby 1.8.7 are that it won't build with Clang,
# and the Net::HTTPS module won't work with modern versions of OpenSSL.
#
# This assumes you have already set up homebrew, and run: xcode-select --install
brew install homebrew/dupes/apple-gcc42
brew install libyaml libffi
brew install https://github.com/Homebrew/homebrew-versions/raw/586b7e9012a3ed1f9df6c43d0483c65549349289/openssl098.rb
export CC=/usr/local/bin/gcc-4.2
<script>
// simple jQuery version. change variables to customize.
window.parseTLSinfo = function(data) {
var alert_classes = 'ssl-notice alert';
var prepend_to = 'body';
var tls_version = parseFloat(data.tls_version.split(/\s+/)[1]);
if (isNaN(tls_version)) { throw "couldn't parse TLS version from input: " + data.tls_version; }
if (tls_version < 1.1) {
@wmakley
wmakley / refinery-frontend.css
Last active August 29, 2015 14:16
Refinery CMS front-end CSS
/* Make wymeditor-inserted images appear correctly in front-end. Tweak margins as needed. */
.image-align-left {
float: left;
margin: 10px 20px 0 10px;
}
.image-align-right {
float: right;
margin: 10px 0 10px 20px;
}