Skip to content

Instantly share code, notes, and snippets.

View davidalejandroaguilar's full-sized avatar
💎

David Alejandro davidalejandroaguilar

💎
View GitHub Profile
@alexrudall
alexrudall / #ChatGPT Streaming.md
Last active June 22, 2024 02:41
ChatGPT streaming with ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind!

How to add ChatGPT streaming to your Ruby on Rails 7 app!

This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!

Want more content like this, for free? Check out my free book, RailsAI!

Alt Text

@kvdesa
kvdesa / add_custom_shortcuts_to_xcode.md
Last active June 26, 2024 15:08
Add custom commands with shortcuts to Xcode

Add Custom Commands with Shortcuts to Xcode

To add custom key bindings in Xcode, you have to edit this file (su privileges required): '/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/Current/Resources/IDETextKeyBindingSet.plist

To facilitate this, just add the following code to .bash_profile/.zshrc:

# Add custom commands to Xcode.
# Run this every time Xcode updates.
function addCustomCommandsToXcode() {
@ddrscott
ddrscott / pry_psql.rb
Last active August 19, 2021 19:17
Pry command to execute SQL as text or Rails scopes
# Load this file in your `.pryrc`
#
# load 'path/to/pry_sql.rb'
#
# See how to use this by running: `psql --help`
# Originally created for Rails 3.
# Updated to Rails 6
module Rails
class DBConsole
APP_PATH = Rails.root.join('config', 'application')
@subfuzion
subfuzion / curl.md
Last active June 22, 2024 13:47
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@indiesquidge
indiesquidge / subdomain-localhost-rails-5.md
Created January 19, 2016 07:42
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@chantastic
chantastic / on-jsx.markdown
Last active May 30, 2024 13:11
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@unixcharles
unixcharles / problem.rb
Created October 29, 2012 11:33
DelegateClass and "superclass mismatch for class" errors
require 'delegate'
class Klass < DelegateClass(String)
# ...
end
class Klass < DelegateClass(String)
# Re-open the class
end
# => TypeError: superclass mismatch for class Klass