Skip to content

Instantly share code, notes, and snippets.

@abhianair
abhianair / main.py
Last active September 20, 2021 09:47
Fask Create new schema and create tables to that schema using SQLAlchemy
import sqlalchemy
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
from app import db
# engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])
# if not engine.dialect.has_schema(engine, schema_name):
# engine.execute(sqlalchemy.schema.CreateSchema(schema_name))
# insp = sqlalchemy.inspect(engine)
# if engine.dialect.has_schema(engine, schema_name):
@abhianair
abhianair / crontab
Last active June 11, 2021 17:08
Covid vaccine request - python - A python script to retrieve available hospital name at kozhikode if 18+ vaccine doses(dose 1) are available up to 5 days and result will be send to the email
#vaccine crons
*/30 * * * * /bin/bash -l -c 'cd /Users/username/path/to/file && python3 main.py'
#end
<div id="wave"></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();
}
@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 / 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 / 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 / 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 / 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
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`