Skip to content

Instantly share code, notes, and snippets.

View alexcastrodev's full-sized avatar
🚀
Let's go !!!!

Alexandro Castro alexcastrodev

🚀
Let's go !!!!
  • Flecto
  • Portugal
View GitHub Profile
const online_basket = [
{ id: 1, quantity: 2 },
{ id: 3, quantity: 1 },
]
const offline_basket = [
{ id: 5, quantity: 1 },
{ id: 3, quantity: 2 },
{ id: 1, quantity: 1 }
]
export function get_nearby_delivery_fees(distance: number) {
if (!Number.isSafeInteger(distance)) {
throw new Error('Invalid distance');
}
const table_price = [
{
until: 6.5,
fee: 12.5
},
@alexcastrodev
alexcastrodev / openapi.yml
Last active October 25, 2024 18:34
reuse openapi params 3.0
openapi: 3.0.0
info:
title: Thing API
version: 1.0.0
description: An API to create and update Thing objects using JSON:API specification
paths:
/things:
post:
summary: Create a new Thing
@alexcastrodev
alexcastrodev / tests.rb
Last active July 28, 2024 12:08
parallel rake rspec
# frozen_string_literal: true
namespace :tests do
desc "Create multiple test databases, load schema, seed data, and run RSpec tests in parallel"
task :parallel, [:quantity] => :environment do |t, args|
quantity = args[:quantity].to_i
raise ArgumentError, "Please provide a valid quantity greater than 0." if quantity <= 0
test_config = ActiveRecord::Base.configurations.configurations.find { |config| config.env_name == 'test' }
raise "Test configuration not found." if test_config.nil?
@alexcastrodev
alexcastrodev / rate_limit_shopify.rb
Last active June 6, 2024 10:55
rate_limit_shopify.rb
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "faker"
require 'time'
module SomethingLib
class Images
@last_called = nil
@call_count = 0
BING_API_LIMIT = 5
INTERVAL = 1 # 1 second interval
def self.generate(title)
import { Browser, Page } from '@playwright/test'
import path from 'node:path';
interface IBaseTestController {
browser?: Browser
page: Page
baseURL: string
path?: string
har: {
title: string
version: '3.8'
x-postgres-defaults: &postgres-defaults
image: postgres:latest
environment:
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: your_password
POSTGRES_DB: your_database
volumes:
- pgdata:/var/lib/postgresql/data