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/[email protected]/babel.min.js"></script> | |
| <style> |
| 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, '[email protected]: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 "*****************************************" |
| andy@Andys-Macbook-Pro~/workspace/go.projects/src/github.com/moscn/picoshop(users-and-orders):bee run | |
| 2015/07/06 17:50:11 [INFO] Uses 'picoshop' as 'appname' | |
| 2015/07/06 17:50:11 [INFO] Initializing watcher... | |
| 2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego) | |
| 2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/cache) | |
| 2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/cache/memcache) | |
| 2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/cache/redis) | |
| 2015/07/06 17:50:11 [TRAC] Directory(/Users/andy/workspace/go.projects/src/github.com/moscn/picoshop/Godeps/_workspace/src/github.com/astaxie/beego/config) | |
| 2015/07/06 17:50:11 [TRAC] Dir |
| <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 PaperTrailHistory < PaperTrail::Version | |
| def self.compose_query(params) | |
| condition = "" | |
| condition << | |
| (params[:type].present? ? "whodunnit NOT IN (?)" : "whodunnit IN (?)") | |
| condition << " AND object_changes ILIKE '%#{params[:q]}%'" if params[:q].present? |