Logesh Paul
  • Welcome
  • About
  • 📖Wiki
    • Productivity
      • My Ultimate Self Guide - For Better Living
      • Finding your Passion, Purpose of Life
      • Great Techniques To Self Mastery
      • Better Yields Best
      • Who is Driving? You (or) Your Mind
      • Goals
      • My Workdesk (Sep 2024)
      • SublimeText Plugins  —  I Use
    • Code
      • Bash
      • Regex
      • Capybara
      • Chrome
      • CSS
      • Git
      • Mac
      • Atom
      • Ruby
      • Slack
      • Husky
      • Zsh
      • Javascript
      • Best Practices
      • What is debounce?
      • Rbenv
      • Brew
      • RVM
    • Design
      • Why do we need a design system?
    • Health
      • Facts about getting fit
      • TDS and its Role in Drinking Water
      • Gut
    • Mind
      • Behaviour
      • Evolving Brain
      • The Law of Wasted Effort
    • Personal
      • Vision and Values
      • Learning From My First Startup
    • Finance
      • 5 Finance Advices From The Ancient Richest City Of The World
      • Interim Dividend
      • Cash Reserve Ratio
      • Dematerialisation
Powered by GitBook
On this page
  • Save user and modify
  • DB Dump Steps
  • Time
  • Changing the format of Date & Time
  • Populate projects and studies in sce
  • Enable / Disable Form, Codelist, etc
  • Enable / Disabled Editor
  • Clear local DB (Like prime for SCE)
  • Create fixtures in MDR
  • Run Specs
  • Run server in production environment
  • Assets
  • Jobs
  • Rake DB Drop & Prime
  • PKPD
  • Help
  • Rails Console
  • Content tag contact
  • Selenium Driver
  • Adding Route
  • Checking available routes
  • Misc
  1. Wiki
  2. Code

Ruby

The command which -a ruby will show you where Ruby is installed.

which -a ruby

Save user and modify

u = User.find_by(email: "<EMAIL>")

# Then run commands like below
# u.access_locked = false
# u.access_locked?

DB Dump Steps

# Create DB via PgAdmin App
pg_restore --port 5432 --username logeshpaul --dbname mdr_staging --no-password --verbose /Users/logeshpaul/Downloads/
.env file DATABASE_NAME_DEVELOPMENT=mdr_staging
./bin/dev

# Alternate Method shared by Lordson
psql DB_NAME < sce_dump.sql

Time

# current time
Time.now # 2009-06-24 12:39:54 +0900

# Return Time string with certain format - dd-Mon-yyyy HH:MM am/pm
"%d-%b-%Y %-l:%M%P" # 27-Jan-2016 7:19am
"%d/%m/%Y %-l:%M%P" # 27/01/2016 7:19am

Changing the format of Date & Time

<%= Time.now.strftime("%m/%d/%Y") %>
<%= DateTime.now.strftime("%m/%d/%Y") %>

<%= DateTime.now.strftime("%e-%b-%Y %m:%M %p %Z") %>
# outputs - 12-Feb-2016 07:05 PM IST

Populate projects and studies in sce

rake sycamore:dashboard:seed[1,1,50,50,50]

Enable / Disable Form, Codelist, etc

rake app:admin:features:enable["Pharma","new_vrep"]
rake app:admin:features:enable["Pharma","new_standard"]

Enable / Disabled Editor

rails c
a = Organization.last
a.ff_react_editor = true
a.save

Clear local DB (Like prime for SCE)

rake db:setup db:test:prepare

Create fixtures in MDR

rails c
StandardFixtures.create

Run Specs

Run all tests - bundle exec rake spec SPEC_OPTS="--format documentation"

Run server in production environment

rails s -p 9000 -e production

Assets

rake assets:clean
rake assets:precompile
rake -T

Jobs

rake jobs:work

Rake DB Drop & Prime

rake db:drop db:create db:schema:load
rake db:dev:prime

PKPD

rake db:drop db:create db:schema:load
engines/pkpd/bin/simulate_deploy.sh
rake db:setup

Help

rake -T | grep prime

Rails Console

rails c

Content tag contact

content_tag :li, class: css_class do
  link_to(text, path, name: name) +
  link_to('', "javascipt:void(0)", class: "CLASSNAME")
end

Selenium Driver

Selenium Driver Config steps to test the feature/CSS styles layouts/JS features in action in Chrome browser: (This are just to see whats going in your spec)

Note: Please do not commit these configs

  1. Add these to your application Gemfile within Test group:

gem "selenium-webdriver"
gem "chromedriver-helper"
  1. Run bundle install in terminal.

  2. In spec/rails_helper.rb Comment out line 54 Capybara.javascript_driver = :webkit

  3. Add below code in spec/rails_helper.rb line 53:

Capybara.register_driver :selenium_chrome do |app|
	Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

Capybara.javascript_driver = :selenium_chrome
  1. Run your individual feature spec and see them running in a new Chrome browser.

Adding Route

resources :tools do
	collection do
		get :run_now
	end
end

<%= link_to t(".add_new_metadata_source"), run_now_study_tools_path(**@**study), remote: true, class: "”=%>

Checking available routes

# All
rake routes
# Search routes
rake routes | grep <routename>

Misc

rake tmp:clear
rails new projectname
bundle exec rails g controller home
PreviousAtomNextSlack

Last updated 3 months ago

More about Time API -

In case you want a custom format use

📖
Link
Strftime