One way to do this is to use bundler to scaffold our gem:
bundler gem my_gem
I prefer to put tasks meant to manage the gem itself in lib/tasks
, and tasks the gem is meant to provide to gem users in lib/my_gem/tasks
.
# Background: | |
# The following code works but I have intentionally introduced issues to make it inefficient. | |
# UserEvents are created for every interaction a user has in the system. It stores what employer, partner and | |
# controller they were on. When there were 10 users and only a little bit of traffic, this would run quickly. | |
# But now with 10,000 users and months of traffic - (millions of user events), this code would be very inefficient. | |
# Instructions: | |
# 1. Please make this code more efficient through refactoring so that it can run at a greater scale, | |
# along with adding some comments to improve the readability. | |
# 2. Please explain what the variable 'distinct_groups' will contain by the end of the execution and what |
One way to do this is to use bundler to scaffold our gem:
bundler gem my_gem
I prefer to put tasks meant to manage the gem itself in lib/tasks
, and tasks the gem is meant to provide to gem users in lib/my_gem/tasks
.
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!
First, add the ruby-openai gem! Needs to be at least version 4. Add Sidekiq too.
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Twitter Archive Browser</title> | |
<script src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script> | |
<style> |
require 'grape' | |
module My | |
class API < Grape::API | |
prefix 'api' | |
## params key list | |
################################################################################################################# | |
# 1. login | |
# 2. sign |
<script type="text/javascript"> | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | |
ga('create', 'UA-55682644-1', 'auto', { | |
'allowLinker': true | |
}); | |
ga('require', 'linker'); |
class KeyGenerator | |
require "digest/sha1" | |
def self.generate(length = 10) | |
Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)[1..length] | |
end | |
end |
require 'mina/rails' | |
require 'mina/git' | |
require 'mina/rvm' | |
require 'mina/puma' | |
set :application_name, 'myapp' | |
set :domain, 'myapp.com' | |
set :deploy_to, '/home/admin/myapp' | |
set :repository, 'git@github.com:lnikell/myapp.git' |
#!/bin/bash | |
############################################### | |
# To use: | |
# https://raw.github.com/gist/2776351/??? | |
# chmod 777 install_postgresql.sh | |
# ./install_postgresql.sh | |
############################################### | |
echo "*****************************************" | |
echo " Installing PostgreSQL" | |
echo "*****************************************" |