Skip to content

Instantly share code, notes, and snippets.

View RichOrElse's full-sized avatar

Ritchie Paul Buitre RichOrElse

View GitHub Profile
@fernandoaleman
fernandoaleman / mysql2-catalina.md
Last active July 11, 2023 02:11
Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Catalina with MySQL 5.7.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl
@coorasse
coorasse / eager_loading.rb
Last active February 10, 2023 02:16
Eager loading of association with parameter in Rails
begin
require 'bundler/inline'
rescue LoadError => e
warn 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '~> 5.2'
@jcypret
jcypret / Gemfile
Last active October 7, 2021 13:59
Phone normalization in Rails
gem "phonelib"
@jodosha
jodosha / README.md
Created September 7, 2017 14:34
Mount Hanami inside Rails

1. Setup

rails new blog
cd blog
hanami new bookshelf
vim Gemfile # add `hanami`
bundle
vim bookshelf/config/environment.rb # See Note 1
@zubaer-ahammed
zubaer-ahammed / Reset MySQL Root Password in Mac OS.md
Last active April 4, 2024 10:38
Reset MySQL Root Password in Mac OS

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop
@towry
towry / context.rb
Last active July 21, 2017 07:33
describe the DCI(Data, context, interaction) architecture in Ruby.
require_relative "customer"
require_relative "user"
# context bind role to object.
# by using the extend method in ruby.
# now the data object has some behaviors that get from the role class(Customer).
class Context
def initialize(user, book)
@customer, @book = user, book
@customer.extend(Customer)
@fernandoaleman
fernandoaleman / fix-libv8-mac.txt
Created May 5, 2016 15:14
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@olivierlacan
olivierlacan / migrate_postgresql_database.md
Last active March 24, 2022 20:30
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X. See upgraded version of this guide: http://olivierlacan.com/posts/migrating-homebrew-postgres-to-a-new-version/

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important:

@phlegx
phlegx / Rails 4 - how to give alias names to includes() and joins() in active record quering
Last active February 12, 2024 19:12
Rails 4 - how to give alias names to includes() and joins() in active record quering
See question on stack overflow: http://stackoverflow.com/questions/28595636/rails-4-how-to-give-alias-names-to-includes-and-joins-in-active-record-que
- Model Student and model Teacher are both STI models with super class model User
- Model Story is a STI model with super class model Task
- includes() and joins(), both fails
Rails alias naming convention (includes() and joins())
- One model as parameter
- is base model (includes(:users))
@ludyna
ludyna / dci_example.rb
Last active March 20, 2018 20:08
DCI (Data, Contexts, Interactions) paradigm example in Ruby
# DCI EXAMPLE IN RUBY (with some prototype elements)
# Blog post: https://www.ludyna.com/oleh/dci-example-in-ruby
#
# More info:
#
# Creator of MVC & DCI, Trygve Reenskaug: DCI: Re-thinking the foundations of
# object orientation and of programming
# http://vimeo.com/8235394
#
# James Coplien: Why DCI is the Right Architecture for Right Now