$ brew install nginx$ vim /usr/local/etc/nginx/nginx.conf| #!/usr/bin/env ruby | |
| # frozen_string_literal: true | |
| # IMPORTANT: You may need to increase the number of available file handles available to this process. | |
| # The number should be greater than the maximum number of requests you want to make, because each process | |
| # opens at least 3 file handles (stdin, stdout, stderr), and other files may be opened during the program's | |
| # run (e.g. for the logger). | |
| # ulimit -n 300 && scripts/compare_request_methods.rb | |
| require 'async/http/internet' # gem install async-http if necessary |
| import { tool } from "@opencode-ai/plugin" | |
| import { existsSync } from "fs" | |
| export default tool({ | |
| description: "Extract and read text content from PDF files", | |
| args: { | |
| filePath: tool.schema.string().describe("Path to the PDF file"), | |
| offset: tool.schema.number().optional().describe("Page number to start reading from"), | |
| limit: tool.schema.number().optional().describe("Maximum number of pages to read"), | |
| }, |
| class Driver | |
| attr_reader :name | |
| def initialize(name) | |
| @name = name | |
| end | |
| end | |
| class Car | |
| def initialize(model:, driver:) |
| # frozen_string_literal: true | |
| # Runs with | |
| # ruby 3.3 | |
| # webmock 3.23 | |
| # minitest 5.24.1 | |
| require 'uri' | |
| require 'net/http' | |
| require 'json' | |
| require 'webmock/minitest' |
| require 'net/ldap' | |
| module Ldap | |
| LDAP_SERVER_IP = 'buzon.uach.mx'.freeze | |
| #LDAP_USERNAME = 'ldap_username' | |
| #LDAP_PASSWORD = 'ldap_password' | |
| #Obtiene el nombre mediante su cuenta de usuario |
| #the do´s | |
| 2.hours.ago # => Thu, 27 Aug 2015 14:39:36 AFT +04:30 | |
| 1.day.from_now # => Fri, 28 Aug 2015 16:39:36 AFT +04:30 | |
| Time.zone.parse("2015-08-27T12:09:36Z") # => Thu, 27 Aug 2015 16:39:36 AFT +04:30 | |
| Time.current # => Thu, 27 Aug 2015 16:39:36 AFT +04:30 | |
| Time.current.utc.iso8601 # When supliyng an API ("2015-08-27T12:09:36Z") | |
| Time.strptime("2015-08-27T12:09:36Z", "%Y-%m-%dT%H:%M:%S%z").in_time_zone # If you can’t use Time.zone.parse (Thu, 27 Aug 2015 16:39:36 AFT +04:30) | |
| Date.current # If you really can’t have a Time or DateTime for some reason (Thu, 27 Aug 2015) | |
| Date.current.in_time_zone # If you have a date and want to make the best out of it (Thu, 27 Aug 2015 00:00:00 AFT +04:30) | |
| #the don´ts |
| db:create #Creates the database for the current RAILS_ENV environment. If RAILS_ENV is not specified it defaults to the development and test databases. | |
| db:create:all #Creates the database for all environments. | |
| db:drop #Drops the database for the current RAILS_ENV environment. If RAILS_ENV is not specified it defaults to the development and test databases. | |
| db:drop:all #Drops the database for all environments. | |
| db:migrate #Runs migrations for the current environment that have not run yet. By default it will run migrations only in the development environment. | |
| db:migrate:redo #Runs db:migrate:down and db:migrate:up or db:migrate:rollback and db:migrate:up depending on the specified migration. I usually run this after creating and running a new migration to ensure the migration is reversable. | |
| db:migrate:up #Runs the up for the given migration VERSION. |
As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.
All the complexity is handled by ActiveRecord::Transactions. Any model class or instance has a method named .transaction. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.