Skip to content

Instantly share code, notes, and snippets.

@abidvf
abidvf / capistrano_deployment
Created October 14, 2019 07:38
Capistrano Deployment
1 sudo vi ~/.ssh/authorized_keys
2 exit
3 sudo apt update
4 sudo apt install gnupg
5 gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
6 \curl -sSL https://get.rvm.io | bash
7 \curl -sSL https://get.rvm.io | bash -s stable --rails
8 exit
9 rvm list
10 rvm install ruby-2.6.4
@abidvf
abidvf / node_nginx_ssl.md
Created September 24, 2019 10:15 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to Digital Ocean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@abidvf
abidvf / customDateFormat.js
Created April 19, 2019 05:22
Custom Date Format
export function customDateFormat(date) {
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
const splittedDate = date.split("-")
const month = parseInt(splittedDate[1])-1
return months[month] +" "+ splittedDate[2] +", "+ splittedDate[0]
}
@abidvf
abidvf / form.html
Created April 2, 2019 04:37
Add dynamic form fields
<form role="form" action="/wohoo" method="POST">
<label>Stuff</label>
<div class="multi-field-wrapper">
<div class="multi-fields">
<div class="multi-field">
<input type="text" name="stuff[]">
<button type="button" class="remove-field">Remove</button>
</div>
</div>
<button type="button" class="add-field">Add field</button>
@abidvf
abidvf / test.rb
Created December 29, 2017 07:41
test env gemfile group
group :test do
gem 'faker'
gem 'database_cleaner'
gem 'cucumber'
gem 'cucumber-rails', '~> 1.4', '>= 1.4.3', :require => false
gem 'capybara', '~> 2.0'
gem "capybara-webkit"
gem 'selenium-webdriver', '~> 2.53'
gem 'thin'
gem 'poltergeist'
@abidvf
abidvf / signin_pos_steps.rb
Created December 29, 2017 07:33
step definition file cucumber rails
require 'capybara'
require 'byebug'
require 'faker'
extend Pages
Before do |scenario|
@page = Pages::Pos.new
end
Given(/^Initiating browser$/) do
@page.initiate_browser()
end
@abidvf
abidvf / manage_pos.feature
Last active December 29, 2017 07:34
cucumber feature file to cover a scenario
Feature: POS flow
Background:
Given Initiating browser
Scenario: Provider creation
Given Hit Site home
When Clicked on login link
Then On login page enter email address
And Enter admin password
And Click on login button
@abidvf
abidvf / pos.po.rb
Last active December 29, 2017 07:09
Page object module for cucumber-rails
module Pages
class Pos
include Capybara::DSL
def site_url url
visit url
end
def initiate_browser
if ENV['BROWSER'] == "ff"
Capybara.register_driver :selenium do |app|
@abidvf
abidvf / env.rb
Last active December 29, 2017 07:23
Cucumber rails env.rb file
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'cucumber/rails'
require 'capybara'
require 'capybara/cucumber'
require 'capybara/poltergeist'
function getDirection(magneticHeading) {
var textDirection;
if (typeof magneticHeading !== "number") {
textDirection = '';
} else if (magneticHeading >= 337.5 || (magneticHeading >= 0 && magneticHeading <= 22.5)) {
textDirection = 'N';
} else if (magneticHeading >= 22.5 && magneticHeading <= 67.5) {
textDirection = 'NE';
} else if (magneticHeading >= 67.5 && magneticHeading <= 112.5) {
textDirection = 'E';