Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alfred Francis alfredfrancis

🏠
Working from home
View GitHub Profile
@alfredfrancis
alfredfrancis / intent_classification.ipynb
Last active May 14, 2018
intent_classification.ipynb
View intent_classification.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View deployment.py
#Original Author https://raw.githubusercontent.com/kgoedecke/python-ecs-example/master/python_ecs_example/deployment.py
import boto3
import pprint
import os
# Credentials & Region
access_key = os.environ["AWS_ACCESS_KEY_ID"]
secret_key = os.environ["AWS_SECRET_ACCESS_KEY"]
region = "us-east-1"
View jinja2.html
{% if "error" in RepoOutput[RepoName.index(repo)] %}
<td id="error"> {{ RepoOutput[RepoName.index(repo)] }} </td>
{% elif "Already" in RepoOutput[RepoName.index(repo) %}
<td id="good"> {{ RepoOutput[RepoName.index(repo)] }} </td>
{% else %}
<td id="error"> {{ RepoOutput[RepoName.index(repo)] }} </td>
{% endif %}
</tr>
View unescape.js
unescape(s){
return this.stripTags(this.s(s)).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
View scrape_google.py
import scrapy
import re
class QuotesSpider(scrapy.Spider):
name = "microsoft"
custom_settings = {
# specifies exported fields and order
'FEED_EXPORT_FIELDS': ["url"],
}
f = open("input/test1.txt")
@alfredfrancis
alfredfrancis / nagios_iot_rpi.py
Created Sep 9, 2017
Nagios + IOT + Raspberry Pi
View nagios_iot_rpi.py
import requests
import re
from requests.auth import HTTPBasicAuth
import time
import pyttsx
engine = pyttsx.init()
REFRESH_INTERVAL = 5
@alfredfrancis
alfredfrancis / WekaClassifier.java
Created Aug 30, 2017
Java Code for Spam email/sms Classification using Weka Machine learning
View WekaClassifier.java
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
alfredfrancis / weka.java
Created Aug 30, 2017
weka_dataset_creation.java
View weka.java
import weka.classifiers.Evaluation;
import weka.classifiers.bayes.NaiveBayes;
import weka.core.Instances;
import weka.core.Instance;
import weka.core.converters.ConverterUtils.DataSource;
import weka.core.Attribute;
import weka.core.DenseInstance;
import java.io.File;
import java.io.BufferedReader;
View gist:f0f03d1587ff5e55a6407cb05763db04
[{"cn":"Israel","cyn":"New Israeli Sheqel","ccc":"ILS"},{"cn":"Afghanistan","cyn":"Afghani","ccc":"AFN"},{"cn":"Albania","cyn":"Lek","ccc":"ALL"},{"cn":"Algeria","cyn":"Algerian Dinar","ccc":"DZD"},{"cn":"AmericanSamoa","cyn":"US Dollar","ccc":"USD"},{"cn":"Andorra","cyn":"Euro","ccc":"EUR"},{"cn":"Angola","cyn":"Kwanza","ccc":"AOA"},{"cn":"Anguilla","cyn":"East Caribbean Dollar","ccc":"XCD"},{"cn":"Antigua and Barbuda","cyn":"East Caribbean Dollar","ccc":"XCD"},{"cn":"Argentina","cyn":"Argentine Peso","ccc":"ARS"},{"cn":"Armenia","cyn":"Armenian Dram","ccc":"AMD"},{"cn":"Aruba","cyn":"Aruban Florin","ccc":"AWG"},{"cn":"Australia","cyn":"Australian Dollar","ccc":"AUD"},{"cn":"Austria","cyn":"Euro","ccc":"EUR"},{"cn":"Azerbaijan","cyn":"Azerbaijanian Manat","ccc":"AZN"},{"cn":"Bahamas","cyn":"Bahamian Dollar","ccc":"BSD"},{"cn":"Bahrain","cyn":"Bahraini Dinar","ccc":"BHD"},{"cn":"Bangladesh","cyn":"Taka","ccc":"BDT"},{"cn":"Barbados","cyn":"Barbados Dollar","ccc":"BBD"},{"cn":"Belarus","ccc":"BYR"},{"cn":"Belg
@alfredfrancis
alfredfrancis / wikipedia.py
Created Aug 5, 2017
Python class for Wikipeida seaching
View wikipedia.py
import requests
from bs4 import BeautifulSoup as bs
class Wikipedia():
def getTitles(self,query,num=4):
url="https://en.wikipedia.org/w/api.php?action=query&list=search&srnamespace=0&format=json&srlimit={}&srsearch={}&srprop=".format(num,query)
data = requests.get(url)
if data.json().get("query").get("searchinfo").get("totalhits") > 0:
titles = [ title.get("title") for title in data.json().get("query").get("search")]
else: