Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Luiyit's full-sized avatar
🏠
Working from home

Luiyit Hernandez Luiyit

🏠
Working from home
View GitHub Profile
@Luiyit
Luiyit / Local MongoDB + Docker + Prisma.md
Last active November 27, 2023 20:20
Configurate MongoDB with Prisma client

Mongo DB + Prisma

MongoDB is a NoSQL database and Prisma is an ORM for NodeJS. Here are the steps to create a MongoDB database and set up Prisma to use it.

Install MongoDB locally (If you need replica set use docker)

This option works, but you will need to use Docker because prisma needs something called Replica Set.So, the easy way to have it is using docker or creating the database on MongoDB Atlas.

I recommend just to use MongoDB inside a docker container and then connect to it from Prisma.

@Luiyit
Luiyit / system_test_with_capybara.md
Last active August 12, 2023 01:06
System test with Capybara | Ruby 7 on WSL2

How to fix the error Webdrivers::BrowserNotFound on WSL2

Last update: 11/08/2023.

The error looks like something like this: Failed to determine Chrome binary location. (Webdrivers::BrowserNotFound) Under WSL, we are running the Linux version of Ruby, which won't be able to communicate via WebDriver with the Windows Chrome executable. So, we need to change the default browser driver used by Capybara.

  1. Open the file application_system_test_case.rb inside your rails project, remove the configuration for driven_by and make sure to copy and pase the new driver configuration.
@Luiyit
Luiyit / curl-ssl-issue-fix.md
Last active August 1, 2023 21:57
How to fix "SSL certificate problem" using curl on Windows

How to fix SSL certificate problem using curl on Windows

Confirm the issue

You can confir the issue checking the curl error $error = curl_error($curl) SHould say somathing like: SSL certificate problem: unable to get local issuer certificate

1. Download the lasted cacert.pem

you can download the file here

@Luiyit
Luiyit / laravel-10-ubuntu.md
Last active July 29, 2023 13:57
How to install Laravel 10 step by step in Ubuntu

How to install Laravel 10 step by step in Ubuntu

DEV NOTE: Support for Ubuntu 18.04 was removed from Ondřej Surý's PPA on June 15, 2023 as that version of Ubuntu is no longer supported. As per the description on the PPA landing page

Reference

@Luiyit
Luiyit / webpack.config.ts
Created July 27, 2023 20:26
How to fix Webpack Dev Server HMR using WSL 2 (TypeScript)
import { Configuration as WebpackConfiguration } from "webpack";
import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
import path from "path";
import HtmlWebpackPlugin from "html-webpack-plugin";
interface Configuration extends WebpackConfiguration {
devServer?: WebpackDevServerConfiguration;
}
const config = (): Configuration => ({
@Luiyit
Luiyit / add_pass_customers_to_program.rb
Last active February 2, 2022 17:12
Add pass customers to program
def add_pass_customers_to_program(passes_slugs, program_uid, include_cancelled: true)
ActiveRecord::Base.transaction do
passes_slugs.each do |slug|
pass = Pass.find_by_slug(slug)
pass_customers = pass.pass_customers.active_upcoming
pass_customers = pass_customers.not_cancelled unless include_cancelled
pass_customers.each do |pass_customer|
client = pass_customer.user
program_customer = ::Customers::Bundles::Program.active_upcoming.find_by(product_uid: program_uid, user_uuid: client.uuid)
@Luiyit
Luiyit / remove_pass_customer_products.rb
Last active April 2, 2021 21:12
Remove pass customer and products
# TODO: include sessions
def remove_customer_pass(client_user_id, pass_customer_id, delete_pass_customer = false, expire_pass_customer = false)
user_client = User.find(client_user_id)
if user_client
pass_customer_classes = []
customer_collection = nil
pass_customer = PassCustomer.find(pass_customer_id)
pass_applies_to = pass_customer.pass.pass_products.pluck(:applies_to)
talent = pass_customer.pass.user.talent
@Luiyit
Luiyit / free_on_demand_access.rb
Last active March 3, 2021 16:57
Gives free access to the On Demand collection. Each customer must include the email and the end date.
def free_on_demand_access (on_demand_collection_id, customers)
collection = OnDemandCollection.find(on_demand_collection_id)
return "Invalid collection" if collection.nil?
ActiveRecord::Base.transaction do
customers.each do |customer|
user = User.find_by(email: customer[:email])
return "Invalid user email #{customer[:email]}" if user.nil?
return "Invalid finish date for #{customer[:email]}" if customer[:finish_date].nil?
def create_backend_admin(admin_email, admin_pass)
admin_exist = Admin.find_by(email: admin_email)
if not admin_exist
admin = Admin.create({
email: admin_email,
password: admin_pass,
password_confirmation: admin_pass,
})
pp admin
@Luiyit
Luiyit / redeem_class_credit.rb
Created November 19, 2020 21:52
Use pack to book class
def redeem_class_credit(customer_user_id, class_id)
# Validate customer
current_user = User.find(customer_user_id)
return "Invalide customer user id" if current_user.nil?
# Validate class
klass = TalentClass.find(class_id);
return "Invalide class id" if klass.nil?