Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alfred Francis alfredfrancis

🏠
Working from home
View GitHub Profile
@alfredfrancis
alfredfrancis / remove_email_signature.py
Created Sep 30, 2020
Python script to remove email signature
View remove_email_signature.py
import talon
from talon import quotations
from talon.signature.bruteforce import extract_signature
import html2text
raw_text = '<div dir="ltr"><div>\n<span style="color:rgb(0,0,0);font-family:docs-Calibri;font-size:15px;white-space:pre-wrap">I have applied for PF final settlement on Apr 26 but till today i didnt get any update .i am requesting you to please speedup the process and settle amount. i have many commitments and medical emergency so please consider and do the needful earliest possible.</span><br><div><br></div><br><div dir="ltr" class="gmail_signature"><div dir="ltr">\n<div>Best,</div>\n<div><br></div>\n<div>Alfred Francis</div>\n<div>AI Architect, Cogniwide</div>\n<div>+91 701 209 7621</div>\n</div></div>\n</div></div>\n<br>\n\n'
text = html2text.html2text(raw_text)
text, signature = extract_signature(text)
@alfredfrancis
alfredfrancis / celery_status_service.py
Last active May 16, 2020
Flask service to fetch latest celery task status
View celery_status_service.py
@app.route('/status/<task_id>')
def taskstatus(project_id,task_id):
task = long_process_task.AsyncResult(task_id)
if task.state == 'PENDING':
# job did not start yet
response = {
'state': task.state,
'current': 0,
'total': 1,
'status': 'Pending...'
@alfredfrancis
alfredfrancis / progress.component.html
Last active May 16, 2020
Angular 8 UI for Celery Tasks
View progress.component.html
<div class="notification-progress" role="alert">
<div class="notification-header">
<span class="close" (click)="removeNotification(notification)">&times;</span>
<h3>{{notification.message}}</h3>
</div>
<div class="notification-body">
<em class="notification-body-content">{{polling_status.status}}</em><br/>
<progress-bar [progress]="polling_status.current" [color-degraded]="{'0': '#ff7777', '35': '#e6ae48', '90': '#00cbcb'}">
</progress-bar>
</div>
@alfredfrancis
alfredfrancis / products.json
Last active Apr 30, 2020
Refference JSON for Javascript array functions tutorial
View products.json
[{
"title": "Brown eggs",
"category": "dairy",
"price": 28.1,
"rating": 4
}, {
"title": "Sweet fresh stawberry",
"category": "fruit",
"price": 29.45,
"rating": 4
View tweets_to_db.py
"""
1. Setup a Twitter Developer account and create new App, get its consumer key and consumer secret and replace them below
2. Replace TWEETS_DB, QUERY, and LANGUAGE values
3. Install required packages: `pip install tweepy schedule`
4. Run process using `python tweets_to_db.py`
"""
import tweepy
import sqlite3
import datetime
View speeh.js
if (window.hasOwnProperty('webkitSpeechRecognition')) {
$(".mic-chat").css({ opacity: 1 })
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
var recognition = new SpeechRecognition();
recognition.continuous = false;
recognition.interimResults = false;
recognition.lang = "en-IN";
recognition.start();
@alfredfrancis
alfredfrancis / base64_encode.py
Created Mar 27, 2020
Google Vision API OCR - Python
View base64_encode.py
import base64
with open("yourfile.ext", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
@alfredfrancis
alfredfrancis / docker-compose.traefik.demo.yml
Created Mar 25, 2020
Service Discovery and Reverse Proxy for Docker-based Microservices using Traefik
View docker-compose.traefik.demo.yml
version: '3'
services:
reverse-proxy:
# The official v2 Traefik docker image
image: traefik:v2.1
# Enables the web UI and tells Traefik to listen to docker
command:
- --api.insecure=true
- --api.dashboard=true # <== Enabling the dashboard to view services, middlewares, routers, etc...
@alfredfrancis
alfredfrancis / mongo_wordcloud.py
Created Mar 5, 2020
Wordcloud using mongodb data
View mongo_wordcloud.py
db.getCollection('cogniwidebot').aggregate([
{
"$project": {
"words": { "$split": ["$query", " "] }
}
},
{
"$unwind": {
"path": "$words"
}
View insert_cogniassist.js
inject = document.createElement('script');
inject.src = "https://cogniwide.github.io/cogniassist-chat-widget/public/cogniassist-latest.js";
document.getElementsByTagName('head')[0].appendChild(inject);
var div = document.createElement('div');
document.body.appendChild(div);
div.id = 'cogniassist'