Skip to content

Instantly share code, notes, and snippets.

View jiggneshhgohel's full-sized avatar

Jignesh Gohel jiggneshhgohel

  • India
View GitHub Profile
@jiggneshhgohel
jiggneshhgohel / gist:52bcd562e937ec4dad7b
Last active June 4, 2018 14:26
Devise Security Extension Schema Migrations

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

@jiggneshhgohel
jiggneshhgohel / gist:ade2c57d03c4ad895e82
Created February 27, 2015 21:26
Adobe Air 2.6 Installation Steps on Ubuntu 14.04 (64-bit)
@jiggneshhgohel
jiggneshhgohel / gist:d4d5996207dcf81bef8e
Last active October 29, 2016 21:14
FactoryGirl - Generate a Random Mac Address

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 / rails-5-edge-upgrade.markdown
Last active November 19, 2015 10:40
Steps to upgrade an existing Rails 4.2.x app to unreleased Rails 5 edge version

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 / random_cell_numbers.md
Created December 15, 2015 11:35
FactoryGirl - Generate a Random Cell Number

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 / omniauth_dynamic_setup.md
Last active October 8, 2021 10:50
Omniauth Dynamic Setup Custom Params Custom Callback

/config/initializers/omniauth.rb

def provider_facebook
  'facebook'
end

def facebook_opts
  my_model_obj = MyModelService.find_by_provider_name(provider_facebook)
@jiggneshhgohel
jiggneshhgohel / ssh_config.md
Last active September 8, 2022 00:28
Windows 10 Linux Subsystem SSH-agent issues
Host github.com-jiggneshhgohel
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_work_gmail
AddKeysToAgent yes


Host csexperimental.abc.com
@jiggneshhgohel
jiggneshhgohel / doorkeeper_access_token_reuse.md
Last active October 17, 2018 09:20
Doorkeeper-based OAuth Provider (aka OAuth Server), JWT Token reuse

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 / doorkeeper_config.md
Last active September 29, 2023 16:38
Doorkeeper (with JWT token) Server and Client applications configuration, references etc

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

Rails 5.0.0.1

Doorkeeper 4.2.6

Devise 4.2.0

Gemfile

@jiggneshhgohel
jiggneshhgohel / rails_new_app.md
Created July 25, 2019 12:57
Rails new app command with various skips
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