Skip to content

Instantly share code, notes, and snippets.

Avatar

Jignesh Gohel jiggneshhgohel

  • India
View GitHub Profile
@jiggneshhgohel
jiggneshhgohel / rails_new_app.md
Created Jul 25, 2019
Rails new app command with various skips
View rails_new_app.md
rails new <APP_NAME> --database=postgresql --skip-yarn --skip-active-storage --skip-puma --skip-action-cable --skip-spring --skip-listen --skip-coffee --skip-turbolinks --skip-test --skip-system-test --skip-bootsnap --no-rc

Note:

  • skip and other options found from rails new --help
@jiggneshhgohel
jiggneshhgohel / doorkeeper_config.md
Last active Jul 8, 2021
Doorkeeper (with JWT token) Server and Client applications configuration, references etc
View doorkeeper_config.md

Provider(aka Server)-side configuration, routes, controllers etc

Rails 5.0.0.1

Doorkeeper 4.2.6

Devise 4.2.0

Gemfile

@jiggneshhgohel
jiggneshhgohel / doorkeeper_access_token_reuse.md
Last active Oct 17, 2018
Doorkeeper-based OAuth Provider (aka OAuth Server), JWT Token reuse
View doorkeeper_access_token_reuse.md

Rails 5.0.0.1

Doorkeeper 4.2.6

Devise 4.2.0

With reference to my comment

I was facing the same situation just recently when made my existing Rails 5 application as an OAuth Provider using Doorkeeper.

@jiggneshhgohel
jiggneshhgohel / ssh_config.md
Last active Nov 19, 2020
Windows 10 Linux Subsystem SSH-agent issues
View ssh_config.md
Host github.com-jiggneshhgohel
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_work_gmail
AddKeysToAgent yes


Host csexperimental.abc.com
@jiggneshhgohel
jiggneshhgohel / omniauth_dynamic_setup.md
Last active Oct 8, 2021
Omniauth Dynamic Setup Custom Params Custom Callback
View omniauth_dynamic_setup.md

/config/initializers/omniauth.rb

def provider_facebook
  'facebook'
end

def facebook_opts
  my_model_obj = MyModelService.find_by_provider_name(provider_facebook)
@jiggneshhgohel
jiggneshhgohel / random_cell_numbers.md
Created Dec 15, 2015
FactoryGirl - Generate a Random Cell Number
View random_cell_numbers.md

Can be useful in generating random cell numbers while writing specs for a class which has a Cell Number attribute.

FactoryGirl.define do
  sequence :cell_number do |n|
    # ----------------------------------------         ----------------------
    #|           SUFFIX PART                 |         |   PREFIX PART      |
    9.times.map { (0..9).to_a.sample }.join("").prepend([7, 8, 9].sample.to_s)
  end
end
@jiggneshhgohel
jiggneshhgohel / rails-5-edge-upgrade.markdown
Last active Nov 19, 2015
Steps to upgrade an existing Rails 4.2.x app to unreleased Rails 5 edge version
View rails-5-edge-upgrade.markdown

Note: At the time of writing this the commands shown below were executed on Ubuntu 14.04

  • Updated .ruby-version by replacing 2.2.1 WITH 2.2.3. In case this file is not present, its better to create it.

  • Updated .ruby-gemset by replacing <MY_APP_NAME> WITH <MY_APP_NAME>-on-rails-5, where <MY_APP_NAME> represents your app's name. In case this file is not present, its better to create it.

  • Upgraded rvm by running command $ rvm get stable.

  • Installed latest stable Ruby version listed here using command: $ rvm install 2.2.3

@jiggneshhgohel
jiggneshhgohel / gist:d4d5996207dcf81bef8e
Last active Oct 29, 2016
FactoryGirl - Generate a Random Mac Address
View gist:d4d5996207dcf81bef8e

Can be useful in generating fake MAC addresses while writing specs for a class which has a MAC address attribute.

FactoryGirl.define do
  sequence :mac do |n|
    12.times.map { num = (0..15).to_a.sample; num.to_s(16) }.each_slice(2).to_a.map { |arr| arr.join('') }.join(":").upcase
  end
end
@jiggneshhgohel
jiggneshhgohel / gist:ade2c57d03c4ad895e82
Created Feb 27, 2015
Adobe Air 2.6 Installation Steps on Ubuntu 14.04 (64-bit)
View gist:ade2c57d03c4ad895e82
@jiggneshhgohel
jiggneshhgohel / gist:52bcd562e937ec4dad7b
Last active Jun 4, 2018
Devise Security Extension Schema Migrations
View gist:52bcd562e937ec4dad7b

Assuming you already have a Devise model named User and you want to add following Devise Security Extension to it

  • Password Expirable
  • Password Archivable
  • Session Limitable

then your User model should look like following:

User model