Skip to content

Instantly share code, notes, and snippets.

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 {
@adam12
adam12 / gist:acb2b08b7bc1a711fdf0afe503667c2e
Created November 30, 2023 15:31 — forked from rkumar/gist:445735
ruby's OptionParser to get subcommands
#!/usr/bin/env ruby -w
## Using ruby's standard OptionParser to get subcommand's in command line arguments
## Note you cannot do: opt.rb help command
## other options are commander, main, GLI, trollop...
# run it as
# ruby opt.rb --help
# ruby opt.rb foo --help
# ruby opt.rb foo -q
# etc
@adam12
adam12 / packer.rb
Created July 12, 2023 12:58 — forked from joeldrapper/packer.rb
Paquito Job Packer
# frozen_string_literal: true
module Packer
# A special packer class for globally identifiable objects. It takes a global ID and packs it as a String, then rehydrates it as a GlobalID lookup.
class GloballyIdentifiable
def self.from_pack(uri)
GlobalID::Locator.locate(uri)
end
def initialize(identifiable)
@adam12
adam12 / ring_buffer.rb
Created July 7, 2023 16:59 — forked from havenwood/ring_buffer.rb
A ring buffer implementation example for Ruby Discord.
# frozen_string_literal: true
class RingBuffer
Nothing = Data.define
EMPTY = Nothing.new
attr_reader :size
def initialize(capacity:)
@capacity = capacity