- You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use
rails newfirst to generate all of the boilerplate files necessary. - Create an app in the current directory with
rails new . - Use Tailwind CSS for styling. Use
--css tailwindas an option on therails newcall to do this automatically. - Use Ruby 3.2+ and Rails 8.0+ practices.
- Use the default Minitest approach for testing, do not use RSpec.
- Default to using SQLite in development.
rails newwill do this automatically but take care if you write any custom SQL that it is SQLite compatible. - An app can be built with a devcontainer such as
rails new myapp --devcontainerbut only do this if requested directly. - Rails apps have a lot of directories to consider, such as app, config, db, etc.
- Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
- Guard against incapable browsers accessing controllers with `allo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'openai' | |
| client = OpenAI::Client.new(access_token: ENV['openai_key']) | |
| assistants = OpenAI::Assistants.new(client: client) | |
| # assistant = assistants.create( | |
| # parameters: { | |
| # name: 'Math tutor', | |
| # model: 'gpt-4', | |
| # instructions: 'You are a personal math tutor. Write and run code to answer math questions.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sidekiq/api' | |
| # 1. Clear retry set | |
| Sidekiq::RetrySet.new.clear | |
| # 2. Clear scheduled jobs | |
| Sidekiq::ScheduledSet.new.clear |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function modifyForWeichertImport() { | |
| var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); | |
| var deleteSecondaryAddressColumn = true | |
| var secondaryAddressColumnNumber = 4 | |
| if (deleteSecondaryAddressColumn) { | |
| // delete secondary address column | |
| sheet.deleteColumn(secondaryAddressColumnNumber); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Copyright 2019 Google LLC. | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| function getEnvironment() { | |
| var environment = { | |
| spreadsheetID: "<REPLACE WITH YOUR SPREADSHEET ID>", | |
| firebaseUrl: "<REPLACE WITH YOUR REALTIME DB URL>" | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Converts time selectec time zone to time in Sydney Australia nad New Delhi in Rails | |
| time_zones = ActiveSupport::TimeZone.all.map(&:name) | |
| time_from = '2020-06-20 23:00:00' | |
| Time.zone = time_zones.first #'America/New_York' | |
| time_zones_to_convert_to = ["Australia/Sydney", "New Delhi"] | |
| from_time = Time.zone.parse(time_from) | |
| puts "From #{Time.zone} #{from_time}" | |
| time_zones_to_convert_to.each do|to_zone| | |
| puts "#{to_zone} #{from_time.in_time_zone(to_zone)}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # disallow dotbot crawler | |
| User-agent: dotbot | |
| Disallow: / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tz = ActiveSupport::TimeZone.new("Islamabad") | |
| # Time to be converted to Pak time | |
| started_at = Time.now + 5.hours | |
| started_at.in_time_zone(tz) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # grep some lines and remove some text from each grepped line and save the output to a file | |
| grep getConn PCCASHPOS*.out | grep -v "JDBC.getConn" | sed 's/^.*getConnection\|//' > /tmp/conn.out |
NewerOlder