Skip to content

Instantly share code, notes, and snippets.

View AfolabiOlaoluwa's full-sized avatar

Olaoluwa Afolabi AfolabiOlaoluwa

View GitHub Profile

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@AfolabiOlaoluwa
AfolabiOlaoluwa / connect_tutorial_python.py
Created May 10, 2017 10:14 — forked from jmasonherr/connect_tutorial_python.py
Stripe connect tutorial for python
# coding: utf-8
import json
import stripe
import datetime
# Required for OAuth flow
from rauth import OAuth2Service
# Our secret key from stripe
STRIPE_SECRET_KEY = 'sk_test_xxxxxxxxxxxxx'
@AfolabiOlaoluwa
AfolabiOlaoluwa / gist:15107eda4524e2f98cc8198c63e46784
Created May 6, 2018 19:19 — forked from arjunvenkat/gist:1115bc41bf395a162084
Seeding a Rails database with a CSV file

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.

@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

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 / 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/* \
@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:

class Comment < ActiveRecord::Base
belongs_to :post, counter_cache: true
end
@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)