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 / 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
@adam12
adam12 / cache.rb
Created November 11, 2022 02:37 — forked from havenwood/cache.rb
Another example for xco on #ruby IRC
require_relative 'tuple_space'
class Cache
def initialize
@memory = TupleSpace.new(reaper_period_in_secs: 10, expires_in_secs: 60)
end
def get(request)
@memory[request]
end
@adam12
adam12 / database_cleaner.rb
Created January 9, 2020 02:23 — forked from jsteiner/database_cleaner.rb
Database Cleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do