Skip to content

Instantly share code, notes, and snippets.

@abhianair
abhianair / subscription_paypal.rb
Created May 14, 2020 04:25
Paypal creating subscription using paypal api with ruby on rails
require 'net/http'
require 'uri'
def create
@subscription = current_user.subscriptions.build(subscription_params)
if @subscription.save
create_subscription_with_api(@subscription)
else
redirect_to request.referrer, notice: 'Some error caused in the payment gateway.'
@abhianair
abhianair / subscription_paypal.rb
Last active August 18, 2023 11:36
Paypal creating subscription using paypal api with ruby on rails
require 'net/http'
require 'uri'
def create
@subscription = current_user.subscriptions.build(subscription_params)
if @subscription.save
create_subscription_with_api(@subscription)
else
redirect_to request.referrer, notice: 'Some error caused in the payment gateway.'
@abhianair
abhianair / command.txt
Created May 15, 2020 10:25
Commands to restart the puma in remote server
#If the application is deployed using capistarno.
cap staging deploy:restart // cap production deploy:restart
#if the above command failed due to version controll issue:
#Error reports:
bundler: command not found: puma
Install missing gem executables with `bundle install`
@abhianair
abhianair / application.html.erb
Created May 18, 2020 08:52
Stripe payment integration in ruby on rails
<script src="https://js.stripe.com/v3/"></script>
@abhianair
abhianair / command.txt
Last active May 18, 2020 09:16
Lets encrypt command for nginx
sudo certbot --nginx --server https://acme-v02.api.letsencrypt.org/directory
@abhianair
abhianair / app.html.erb
Created June 24, 2020 05:08
Specific title tag for specific page or default title
<title><%= (yield(:title) unless yield(:title).blank?).to_s + ("Default title" if yield(:title).blank?).to_s %></title>
<% content_for :title, "Special title" %>
@abhianair
abhianair / file.txt
Last active April 27, 2024 15:03
Remotely connecting to digital ocean postgresql server using pgadmin
1) Login to your droplet with super admin privilage.
2) Navigate to /etc/postgresql/{version}/main.
3) open postgresql.conf sudo nano postgresql.conf
add line
listen_addresses = '*'
@abhianair
abhianair / index.html
Last active March 9, 2021 05:24
Select menu css style
<div class="select_box">
<select id="test">
<!-- options here -->
</select>
</div>
@abhianair
abhianair / some.js
Created March 25, 2021 03:58
Alert when div is visible during scrolling
// hide the navbar when reached bottom
window.addEventListener('scroll', function() {
var element = document.querySelector('.site-footer');
var position = element.getBoundingClientRect();
// checking whether fully visible
if(position.top >= 0 && position.bottom <= window.innerHeight) {
// console.log('Element is fully visible in screen');
}else{
$('.navbar').slideDown();
}
<div id="wave"></div>