Skip to content

Instantly share code, notes, and snippets.

@adam12
adam12 / migrations.exs
Created December 6, 2025 01:02 — forked from tmattio/migrations.exs
An implementation of has_many polymorphic association with Ecto
defmodule CreateCat do
use Ecto.Migration
def change do
create table(:cats) do
end
end
end
defmodule CreateDog do
@adam12
adam12 / Caddyfile
Created December 6, 2025 00:59 — forked from stympy/Caddyfile
Serving secure customer domains with Caddy - the tech behind https://www.honeybadger.io/tour/status-pages/
{
# Caddy is running behind an application load balancer hosted at AWS, so this configures Caddy to trust the headers set by it
servers {
trusted_proxies static private_ranges
}
# Avoid DoS attacks by confirming with a backend app that a requested domain should have an on-demand certificate generated
on_demand_tls {
ask http://web.internal:5000/confirm_domain
interval 1m
class BaseController < ApplicationController
include Flowable
self.form_flow = [
"AppliesController",
# Initial "can we help you" questions
"Apply::LocationsController",
"Apply::RecentlyAppliedsController",
"Apply::LanguagesController",

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@adam12
adam12 / config.rb
Last active July 17, 2024 14:11
Example for dot-assignment from Ruby object (used with Ruby Next)
RubyNext.define_text_rewriter "dot_assign" do
def safe_rewrite(source)
source.gsub(/^.+ \.= .+$/) do |m|
m.match(/(.+) .= (.+)/) do |y|
variables = y[1].split(/,\s?/)
variables.map { |var| "#{var} = #{y[2]}.#{var}" }.join(";")
end
end
end
end
@adam12
adam12 / config.lua
Created May 13, 2024 00:16
Wezterm config
local wezterm = require 'wezterm'
return {
color_scheme = 'Catppuccin Mocha',
use_fancy_tab_bar = false,
window_decorations = 'RESIZE',
font = wezterm.font 'JetBrains Mono',
font_size = 14,
}
@adam12
adam12 / signoff
Created May 8, 2024 16:39 — forked from dhh/signoff
#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)
@adam12
adam12 / spike.rb
Created April 11, 2024 14:02 — forked from havenwood/spike.rb
A spike showing compiling IR binaries for all gems
# frozen_string_literal: true
require 'fileutils'
require 'find'
require 'zlib'
binaries_dir = File.join Gem.dir, 'binaries'
gems_dir = File.join Gem.dir, 'gems'
Dir['*/', base: gems_dir].each do |gem|
@adam12
adam12 / mdns.rb
Created January 21, 2024 03:44 — forked from tenderlove/mdns.rb
Sample mDNS client in Ruby
# mDNS client
#
# Usage: ruby script.rb "_http._tcp.local."
require "socket"
require "ipaddr"
require "fcntl"
require "resolv"
module DNSSD
@adam12
adam12 / PhlexMailerLayout.rb
Created January 6, 2024 18:28 — forked from georgekettle/PhlexMailerLayout.rb
Phlex Mailer layout
You'll need to update the following variables:
- ENV['APP_NAME']
- ENV['COMPANY_ADDRESS']
- ENV['HOST']
Make sure you have app/assets/images/logo.svg for this line:
helpers.image_url('logo.svg')
And also update the CSS variables to match your color scheme:
:root {