Skip to content

Instantly share code, notes, and snippets.

View alfredfrancis's full-sized avatar

Alfred Francis alfredfrancis

View GitHub Profile
alfredfrancis /
Created August 30, 2017 19:08
Java Code for Spam email/sms Classification using Weka Machine learning
import weka.classifiers.Evaluation;
import weka.classifiers.bayes.NaiveBayes;
import weka.classifiers.bayes.NaiveBayesMultinomial;
import weka.classifiers.meta.FilteredClassifier;
import weka.classifiers.Evaluation;
import weka.core.Instances;
import weka.core.Instance;
import weka.core.converters.ConverterUtils.DataSource;
import weka.core.Attribute;
alfredfrancis /
Created September 30, 2020 15:08
Python script to remove email signature
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 /
Last active May 16, 2020 16:00
Flask service to fetch latest celery task status
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 / progress.component.html
Last active May 16, 2020 15:59
Angular 8 UI for Celery Tasks
<div class="notification-progress" role="alert">
<div class="notification-header">
<span class="close" (click)="removeNotification(notification)">&times;</span>
<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'}">
alfredfrancis / products.json
Last active April 30, 2020 21:07
Refference JSON for Javascript array functions tutorial
"title": "Brown eggs",
"category": "dairy",
"price": 28.1,
"rating": 4
}, {
"title": "Sweet fresh stawberry",
"category": "fruit",
"price": 29.45,
"rating": 4
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`
import tweepy
import sqlite3
import datetime
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";
alfredfrancis /
Created March 27, 2020 18:18
Google Vision API OCR - Python
import base64
with open("yourfile.ext", "rb") as image_file:
encoded_string = base64.b64encode(
alfredfrancis / docker-compose.traefik.demo.yml
Created March 25, 2020 16:25
Service Discovery and Reverse Proxy for Docker-based Microservices using Traefik
version: '3'
# The official v2 Traefik docker image
image: traefik:v2.1
# Enables the web UI and tells Traefik to listen to docker
- --api.insecure=true
- --api.dashboard=true # <== Enabling the dashboard to view services, middlewares, routers, etc...
alfredfrancis /
Created March 5, 2020 14:04
Wordcloud using mongodb data
"$project": {
"words": { "$split": ["$query", " "] }
"$unwind": {
"path": "$words"