Skip to content

Instantly share code, notes, and snippets.

View asyraffff's full-sized avatar
🐔
cookin

Amirul Asyraf asyraffff

🐔
cookin
  • Malaysia
View GitHub Profile
@alexrudall
alexrudall / #ChatGPT Streaming.md
Last active September 11, 2024 06:30
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

<div class="card">
<div class="card-header">
<h3 class="card-title">
<%= notification.to_notification.in_app_subject %>
</h3>
</div>
<div class="card-body">
<%= notification.to_notification.in_app_body %>
</div>
</div>
@rickychilcott
rickychilcott / slim_select_controller.js
Last active December 28, 2021 05:10
Slim-select stimulus controller
import { Controller } from "stimulus"
import SlimSelect from "slim-select"
import "slim-select/dist/slimselect.min.css"
import "../style/slimselect-customized.css"
export default class extends Controller {
connect() {
const limit = this.data.get("limit")
const placeholder = this.data.get("placeholder")
const searchText = this.data.get("no-results")
🌞 Morning 123 commits █▉░░░░░░░░░░░░░░░░░░░ 9.4%
🌆 Daytime 345 commits █████▌░░░░░░░░░░░░░░░ 26.3%
🌃 Evening 548 commits ████████▊░░░░░░░░░░░░ 41.8%
🌙 Night 295 commits ████▋░░░░░░░░░░░░░░░░ 22.5%
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@leastbad
leastbad / README.md
Created April 16, 2020 08:08
Choices.js Stimulus wrapper preview

Choices.js Stimulus wrapper

https://joshuajohnson.co.uk/Choices/

Soon, this will be published as an NPM package, but there's an absence of documentation right now. It supports almost all functions from the original library; soon it will support 100% of them.

This wrapper adds Ajax pre-fetch search. Happens if controller has a data-search-path attribute.

Stimulus controller targets use new v2 syntax. Controller attaches a reference to itself on the element so that you can access the internal state from external scripts.

Deploying a basic Ruby on Rails app with Postgres Database to Microsoft Azure

This was written on 8 November, 2019. Some of the issues mentioned below were discovered and resolved with the help of Microsoft support staff, and will hopefully be fixed in the near future.

Overview

The steps below are mostly taken from this tutorial, Deploying your Rails + PostgreSQL app on Microsoft Azure, but have also been influenced by these two other tutorials: Create a Ruby on Rails App in App Service on Linux and Build a Ruby and Postgres app in Azure App Service on Linux.

The descriptions of each step are my own personal understanding. I'm not an Azure expert, so they may not be correct 100% of the time.

Rails Version Note: The versions u

@bradtraversy
bradtraversy / webdev_online_resources.md
Last active September 18, 2024 10:59
Online Resources For Web Developers (No Downloading)

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do