Skip to content

Instantly share code, notes, and snippets.

View wilsonsilva's full-sized avatar

Wilson Silva wilsonsilva

View GitHub Profile
@peterc
peterc / PROMPT.txt
Last active February 20, 2025 18:23
Prompt to start a software engineering debate about a proposed app idea
You simulate a group of expert software developers, engineers and architects who debate and analyze an application development idea in order to ultimately produce a robust spec. Each participant has a unique perspective, engages in natural discussion, and refines ideas through back-and-forth exchange. The goal is to explore concepts, challenge assumptions, and reach well-reasoned conclusions.
This is an on-going conversation between an external user who is asking for a piece of software to be built and the group of experts.
## Output Format
1. Simulate a technical debate** where ideas and answers emerges organically.
2. Use a play script style where when someone speaks, their name is included at the start of each line.
3. You must end with a pertinent question for the user to answer in order to productively continue the debate. Format the answer like so: "QUESTION: Question goes here." This must be the very final paragraph of your response.
4. If the group is satisfied they have all the answers needed to pr
@peterc
peterc / CONVENTIONS.md
Last active February 28, 2025 06:58
CONVENTIONS.md file for AI Rails 8 development
  • You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use rails new first to generate all of the boilerplate files necessary.
  • Create an app in the current directory with rails new .
  • Use Tailwind CSS for styling. Use --css tailwind as an option on the rails new call to do this automatically.
  • Use Ruby 3.2+ and Rails 8.0+ practices.
  • Use the default Minitest approach for testing, do not use RSpec.
  • Default to using SQLite in development. rails new will do this automatically but take care if you write any custom SQL that it is SQLite compatible.
  • An app can be built with a devcontainer such as rails new myapp --devcontainer but only do this if requested directly.
  • Rails apps have a lot of directories to consider, such as app, config, db, etc.
  • Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
  • Guard against incapable browsers accessing controllers with `allo
@peterc
peterc / sinatra-react.md
Last active February 20, 2025 18:20
How to set up a basic Sinatra + React webapp

How to set up a basic Sinatra + React webapp in 2025

Let's say you want to use Ruby for the backend of a basic webapp but React on the frontend. Here's how.

(Note: All tested on January 13, 2025 with Ruby 3.3, Sinatra 4.1.1, and React 18.3. Configs may change over time.)

First, create the app folder and set up Sinatra:

mkdir my-sinatra-react-app
@karpathy
karpathy / add_to_zshrc.sh
Created August 25, 2024 20:43
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
class BaseClient
class APINotFound < StandardError; end
attr_reader :auth_strategy
def initialize(auth_strategy: :headers, headers: {})
@auth_strategy = auth_strategy
@headers = headers
end

Unhappy path

Before delving into how we support database (DB) transactions, let's first consider how we can handle operations that only pertain to the unhappy path. This consideration is important because, as we will see, it will become relevant when we reach the main topic.

Most of the time, the unhappy path is something managed by the caller (e.g., a controller rendering an error in case of failure). However, there are situations where it makes sense to encapsulate part of the unhappy path within the operations class. For instance, you might want to log the failure somewhere.

When relying on the vanilla #steps method, the implementation is straightforward:

class CreateUser &lt; Dry::Operation
@bizz84
bizz84 / macOS-Podfile
Last active October 5, 2023 01:42
macOS Podfile template for Flutter apps
# Set the platform at the top
platform :osx, '10.15'
# Rest of the pod file
# Update post_install step
post_install do |installer|
# Ensure pods use the minimum deployment target set above
# https://stackoverflow.com/a/64385584/436422
pods_project = installer.pods_project
module ArrayColumns
extend ActiveSupport::Concern
class_methods do
def array_columns_sanitize_list(values = [])
return [] if values.nil?
values.select(&:present?).map(&:to_s).uniq.sort
end
def array_columns(*column_names)
@eseidel
eseidel / flutter_companies.md
Last active November 13, 2023 14:28
List of companies serving Flutter developers

This is a list of companies serving Flutter developers who replied to my Twitter thread on June 14th, 2023.

This does not include companies using Flutter (there are simply too many to list!), only those offering products or services for Flutter developers.

Presence on this list is not imply any endorsement of the company or its products (other than Shorebird, of course, I endourse my own company).

@baweaver
baweaver / block_transform_ast.rb
Last active August 3, 2023 22:53
Pattern matching applied to ASTs, defining the transformation between shorthand and standard block format.
require "rubocop"
# Useful for debugging and seeing how the nodes deconstruct
def deep_deconstruct(node)
return node unless node.respond_to?(:deconstruct)
node.deconstruct.map { deep_deconstruct(_1) }
end
def block_to_shorthand?(a, b)