Skip to content

Instantly share code, notes, and snippets.

View cdrani's full-sized avatar
🎯
Focusing

charles cdrani

🎯
Focusing
View GitHub Profile
@cdrani
cdrani / README.md
Created November 9, 2023 02:05 — forked from alfredringstad/README.md
Forking a single package in a monorepo

Forking a single package in a monorepo

The trend of using monorepos makes a lot of things easier to manage. However, when you want to fork a single package inside a monorepo, you'll have to chose one of two options:

  • Fork the entire monorepo (meaning you get all those extra boilerplate you don't really care about)
  • Manually copying the package files into a new git repo (meaning you'll loose all git history and have a lot of work to do when there's a new version of your base package)

The good news: There's a solution for this! And it's actually built in to git.

git subtree

One of the lesser-known (and vaguely documented) features of git is subtree. It's intended for this purpose, working as a great alternative to the criticized submodules. There are very few resources about using this in practice, so here's a guide for this specific use case.

@cdrani
cdrani / lvm-setup.md
Last active April 12, 2024 13:45
Setting up a LVM infrastucture on AWS RHEL 9 Instance

We will use an RHEL9 instance as our server. Additionally, we need to create and attach three 10GB volumes to our instance.

The volume must be in the same Availability Zone as the instance:

@cdrani
cdrani / mysql-setup.md
Last active February 4, 2023 20:41
MySQL Setup

Set up and configure our DBMS of choice, MYSQL, to store and manage data. Additionally setup user credentials validation and reset MySQL default users, databases, etc.

sudo apt install -y mysql-server

After installation, it's recommended to purge some insecure default settings and lock down access to the database system. The first thing we should do is set a password for the root password (using mysql_native_password as our default authentication method**)** as by default it has none - a huge security risk.

@cdrani
cdrani / facebook_business.rb
Last active July 6, 2022 15:45
Facebook Business
module Facebook
class EventHandler
def call(record:, request_params:, type:)
@record = record
@request_params = request_params
@facebook_pixel_id = Rails.configuration.analytics_facebook_pixel_id
send_event(type)
end
private
@cdrani
cdrani / Braze.rb
Created November 19, 2021 18:45
Braze Configuration Setup
module Braze
class << self
attr_accessor :configuration
end
def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end
@cdrani
cdrani / gist:1084f73f4dce26e02ac6950e5e18b75f
Created February 4, 2019 09:33 — forked from jendiamond/gist:6128723
Creating your own Gem & Command Line Interface Using Bundler

Presentation slides

Create a Gem - Make it a CLI - Add Rspec Tests

Create a Gem - Make it a Command Line Interface - Add Rspec Tests Using Bundler & Thor

#Creating your own Gem

  1. Run this command in your Terminal. This creates and names all the files you need for your gem. We are going to create a Lorem Ipsum Generator; you can call it whatever you want but seeing as we are creating a Lorem Ipsum generator we'll call it lorem. Read about gem naming conventions.
@cdrani
cdrani / System Design.md
Created January 30, 2019 09:03 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@cdrani
cdrani / gh-pages-deploy.md
Created December 24, 2018 23:14 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@cdrani
cdrani / rails_errors_and_fixes.md
Last active October 19, 2018 03:34
Fixes for Errors I Have Come Across Using Rails

Error: RecordNotFound Couldn't find User with 'id'="

Fix: as outlined on so

def current_user
  @current_user ||= User.find_by(id: session[:user_id]) if session[:user_id]
end

@cdrani
cdrani / setup_postgresql_on_rails.md
Last active October 7, 2018 05:08
rails postgresql

Fresh New App

  1. Create new rails app: rails new appname -d postgresql -T
  2. Enter in console: psql -U username
  3. Enter: create role approle with createdb login password 'password1';
  4. Edit development section in config/database.yml:
    1. uncomment username and change it's value to the role you created username: approle
    2. change password to one entered in role creation password: password1
  5. Enter: rails db:setup