Skip to content

Instantly share code, notes, and snippets.

View Allwin12's full-sized avatar

Allwin Raju Allwin12

  • Genesys
  • chennai
View GitHub Profile
@Allwin12
Allwin12 / cricket-score.py
Created October 24, 2019 10:56
Get live cricket score every 60 seconds using python - Linux only
import subprocess
from bs4 import BeautifulSoup
import requests
import time
while True:
url = "http://static.cricinfo.com/rss/livescores.xml"
r = requests.get(url)
soup = BeautifulSoup(r.text, "html.parser")
data = soup.find_all("description")
@Allwin12
Allwin12 / header-text.html
Created October 25, 2019 11:20
The header text style i use in my blog - https://www.codesimple.info/
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Baloo+Bhai" />
<style>
.alignleft {
float: left;
}
.alignright {
float: right;
}
</style>
@Allwin12
Allwin12 / navigation_bar.html
Last active October 25, 2019 11:23
The navigation bar used in the website - https://www.codesimple.info/
<!doctype html>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<style>
body {margin:0;font-family:Arial}
.topnav {
overflow: hidden;
background-color: #333;
}
@Allwin12
Allwin12 / social-links.html
Created October 25, 2019 11:25
The social media widget i used in the blog - https://www.codesimple.info/
@Allwin12
Allwin12 / footer.html
Created October 25, 2019 11:26
The footer i used on the blog - https://www.codesimple.info/
@Allwin12
Allwin12 / flask_mail.py
Created October 29, 2019 12:28
Send email using flask and python
from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
mail = Mail(app)
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USERNAME'] = 'yourmail@mail.com'
app.config['MAIL_PASSWORD'] = 'yourpassword'
@Allwin12
Allwin12 / models.py
Created November 4, 2019 14:58
Flask SQLAlchemy model
class Book(db.model):
__tablename__='books'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String()),
author = db.Column(db.String()),
published = db.Column(db.String()),
@Allwin12
Allwin12 / insert.py
Created November 4, 2019 15:06
Flask SQLAlchemy insert operation
book = Book(name="The monk who sold his ferrari", author="Robin Sharma", published="1997-03-04")
db.session.add(book)
db.session.commit()
@Allwin12
Allwin12 / crud_delete.py
Last active November 5, 2019 10:44
Flask SQLAlchemy delete a record
db.session.delete(book)
db.session.commit()
author = Author.objects.get(pk=author.pk)
reporter.refresh_from_db()