Skip to content

Instantly share code, notes, and snippets.

View secretpray's full-sized avatar
🎯
Focusing

Aleksander secretpray

🎯
Focusing
View GitHub Profile
@Bhacaz
Bhacaz / README.md
Created August 23, 2024 00:10
DaisyUI with Tailwind-cli / standalone

The goal is to eliminate Node.js (including jsbundling and cssbundling) as a dependency when using tailwindcss-rails.

The approach involves downloading and bundling DaisyUI once, allowing Tailwind CLI to handle the rest of

@alexrudall
alexrudall / #ChatGPT Streaming.md
Last active April 20, 2025 08:13
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

@secretpray
secretpray / New tally method (Ruby 2.7).md
Last active February 28, 2024 16:49
New tally method (Ruby 2.7)
def search_result
  categories.each_with_object([]) do |category, keywords|
    keywords << category.keywords.split(', ').select{ |c| c.include?(query) } unless category.keywords.blank?
  end.flatten.tally.first(3).map(&:first)
end
[1, 2, 2, 3].tally
@bpohoriletz
bpohoriletz / rails_docker.sh
Last active September 15, 2024 00:17
Rails 7.0.1/Ruby 3.1/SQLite app in Docker
# set ruby/rails version
export DOCKER_RAILS_VERSION="7.0.1"
export DOCKER_RUBY_VERSION="3.1.0"
export RAILS_PROJECT_NAME="rails7"
# create folder for the project and add Gemfile with necessary rails version
mkdir "$RAILS_PROJECT_NAME"
cd "$RAILS_PROJECT_NAME"
echo "ruby '$DOCKER_RUBY_VERSION'
source 'https://rubygems.org'
gem 'rails', '$DOCKER_RAILS_VERSION'" > Gemfile
@davideluque
davideluque / !README.MD
Last active December 15, 2024 18:32
Sign in with Apple in Ruby on Rails using apple_id gem.

Sign in with Apple Implementation for Ruby on Rails

Note: Before diving into this implementation, consider that there are more popular and potentially easier-to-use solutions for implementing Sign in with Apple in Ruby on Rails, such as Omniauth. If you prefer a more out-of-the-box approach, explore those alternatives.

Overview

This implementation of the Sign in with Apple service in Ruby on Rails is suitable for APIs, eliminating the need for views.

Features

(from : https://simplifiedthinking.co.uk/2015/10/03/install-mqtt-server/ )
Installing Brew
The Mosquitto MQTT Server can be easily installed using Homebrew. If it’s not installed on your system already, then a quick visit to the homepage will give you all you need to get going. Homebrew is an OS X Package Manager for installing and updating non-Mac OS X utilities that are more commonly found in other variants of Linux. To install the basic package manager run the following command.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Mosquitto MQTT
@poc7667
poc7667 / active_admin.rb
Last active October 2, 2021 09:44
active admin / paper clip / images /
module ActiveAdmin::ViewHelpers
include ApplicationHelper
def show_image(p)
p.object.image.nil? ? p.template.content_tag(:span, "No Upload Image Yet") : p.template.image_tag(p.object.image.url(:small))
end
end
module ActiveAdmin
module Views
class Footer < Component
@inopinatus
inopinatus / hstore_accessor.rb
Last active June 29, 2024 17:26
hstore accessor class method for AR
# include from an initializer
module HstoreAccessor
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|