Skip to content

Instantly share code, notes, and snippets.

View AfolabiOlaoluwa's full-sized avatar

Olaoluwa Afolabi AfolabiOlaoluwa

View GitHub Profile
@AfolabiOlaoluwa
AfolabiOlaoluwa / peatio-rubykube-installation-guide.md
Created October 18, 2024 09:39 — forked from bilalpakistani/peatio-rubykube-installation-guide.md
Installation peatio Production - Installation guide - Rubykube

Overview

1) Setup deploy user
2) Install Ruby
3) Install MySQL
4) Install Redis
5) Install RabbitMQ
6) Install Bitcoind
7) Install Nginx with Passenger
  1. Install JavaScript Runtime
@AfolabiOlaoluwa
AfolabiOlaoluwa / add-new-crypto-to-peatio.md
Created October 18, 2024 09:13 — forked from muhammednagy/add-new-crypto-to-peatio.md
Adding A New Cryptocurrency to Peatio

State: Draft
Based on the Peatio Stable branch


Coin Daemon

To the coin daemon's {coin}.conf file, include the -walletnotify command:

# Notify when receiving coins
@AfolabiOlaoluwa
AfolabiOlaoluwa / users_controller.rb
Created January 21, 2021 17:09 — forked from danielpuglisi/users_controller.rb
Rails examples: Single Table Inheritance (STI), strong parameters, single controller.
# Variant 1
def user_params(type)
params.require(type.to_sym).permit(attributes)
end
# Variant 2
def user_params(type)
case type
when "user"
params.require(:user).permit(user_attributes)
class Comment < ActiveRecord::Base
belongs_to :post, counter_cache: true
end
@AfolabiOlaoluwa
AfolabiOlaoluwa / 00.md
Created November 24, 2019 09:02 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

# Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers.
# e.g. [[1,2,[3]],4] -> [1,2,3,4].
# SOLUTION
class Array
def flatten_array(number = nil)
number ? multiple_flatten(self, number) : recursive_flatten(self)
end
@AfolabiOlaoluwa
AfolabiOlaoluwa / Ruby on Rails Hints
Created July 29, 2019 13:19
When Should I Not Use a Service Object?
## When Should I Not Use a Service Object?
This one’s easy. I have these rules:
1. Does your code handle routing, params or do other controller-y things?
If so, don’t use a service object—your code belongs in the controller.
2. Are you trying to share your code in different controllers?
In this case, don’t use a service object—use a concern.
3. Is your code like a model that doesn’t need persistence?
@AfolabiOlaoluwa
AfolabiOlaoluwa / Dockerfile
Created April 2, 2019 10:58 — forked from oinak/Dockerfile
Example docker config for rails develompent
FROM ruby:2.4
## In case of postgresql for heroku:
# RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list.d/postgeresql.list \
# && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
# && apt-get update \
# && apt-get update \
# && apt-get install -y --no-install-recommends \
# postgresql-client-9.6 pv ack-grep ccze unp htop vim \
# && rm -rf /var/lib/apt/lists/* \

Deploying to Heroku

  1. Deploy the app to heroku following heroku normal instructions (add link to heroku help)

  2. Set heroku environment variables

    Make sure all the options in config.yml are properly set then run:

     bundle exec rake heroku:config
    
@AfolabiOlaoluwa
AfolabiOlaoluwa / app.rake
Created December 9, 2018 10:49 — forked from ChuckJHardy/app.rake
Rake Task for Database Population
------------ From Rake Task
namespace :app do
# Checks and ensures task is not run in production.
task :ensure_development_environment => :environment do
if Rails.env.production?
raise "\nI'm sorry, I can't do that.\n(You're asking me to drop your production database.)"
end
end