Skip to content

Instantly share code, notes, and snippets.

@youngsoul
youngsoul / create_aws_lambda.py
Created April 28, 2019 15:53
Script to create a lamba zip file distribution. This script lets you specify the exact files you would like in the distribution, and a requirements.txt file that you would like to use for dependencies. If you specify the name of the of the lambda and a profile name it will also generate a script to use the aws cli to update the lambda function.
import os
import subprocess
import zipfile
import sys
import getopt
import shutil
import datetime
"""
import cv2
import numpy as np
"""
This histogram will be used to charac- terize the color of the flower petals,
which is a good starting point for classifying the species of a flower
"""
class RGBHistogram:
from scipy.spatial import distance as dist
import matplotlib.pyplot as plt
import numpy as np
import argparse
import glob
import cv2
"""
https://www.pyimagesearch.com/2014/07/14/3-ways-compare-histograms-using-opencv-python/
@youngsoul
youngsoul / html_to_jinja.py
Created June 6, 2018 03:33
helper script to convert creative-tim templates to Jinja2 templates. It may not catch every conversion but it does get hte majority of them.
import glob
from bs4 import BeautifulSoup
import re
"""
This script will help take a creative-tim theme, and convert it to a jinja2 template that can be used in a Flask
application.
It essentially takes all of the href to files, and wraps them in a url_for to the static directory.
@youngsoul
youngsoul / html_to_jinja.py
Last active May 1, 2018 01:18
Python script to help convert a CreativeTim theme to a jinja2 template to use with Flask
import glob
from bs4 import BeautifulSoup
import re
"""
This script will help take a creative-tim theme, and convert it to a jinja2 template that can be used in a Flask
application.
It essentially takes all of the href to files, and wraps them in a url_for to the static directory.
@youngsoul
youngsoul / remove_punctuation.py
Created December 8, 2017 17:15
Python 3 way to use translate to remove punctuation from a string
# https://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string-in-python
import string
def remove_punctuation(x):
table = str.maketrans({key: None for key in string.punctuation})
return x.translate(table)
# mydoc = Appearance: Deep Amber with medium bubbles and an off-white head settles quick with even lacing. Head upon initial pour rose to about one finger's length.
# print(remove_punctuation(mydoc)
# Appearance Deep Amber with medium bubbles and an offwhite head settles quick with even lacing Head upon initial pour rose to about one fingers length
@youngsoul
youngsoul / photon_temp_humid.cpp
Created October 13, 2017 13:42
Photon Temp/Humidity example
// This #include statement was automatically added by the Particle IDE.
#include <SHT1x.h>
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// HCPA-5V-U3
// This code is designed to work with the HCPA-5V-U3_I2CS I2C Mini Module available from ControlEverything.com.
@youngsoul
youngsoul / transformers.py
Created September 6, 2017 21:44
number of data transformers for sentiment analysis
import re
from sklearn.base import BaseEstimator, TransformerMixin
class RemoveEllipseTransformer(TransformerMixin):
@staticmethod
def _preprocess_data(data_series):
"""
inspired from:
@youngsoul
youngsoul / sentiment_models.py
Created September 6, 2017 21:44
Initial WIP Sentiment analysis of Kaggle data set
import numpy as np
import time
from sklearn.naive_bayes import MultinomialNB
from sklearn.svm import LinearSVC
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
from sklearn.model_selection import StratifiedKFold
import pandas as pd
from sklearn import metrics
from sklearn.linear_model import LogisticRegression
from stemming.porter2 import stem
@youngsoul
youngsoul / rpi_mysql_setup.sh
Created September 6, 2017 19:32
Setup mysql on raspberry pi
#!/usr/bin/env bash
sudo apt-get --yes update
# install mysql
#echo "******* Installing MySql *******"
sudo apt-get --yes --force-yes install mysql-server
sudo apt-get --yes --force-yes install mysql-client
sudo apt-get --yes --force-yes install python-mysqldb
sudo apt-get --yes --force-yes install libmysqlclient-dev