Skip to content

Instantly share code, notes, and snippets.

@youngsoul
youngsoul / rpi-mysql_docker_script.sh
Created June 1, 2017 04:02
simple script to pull raspberry pi mysql docker image
# http://www.dwmkerr.com/learn-docker-by-building-a-microservice/
docker pull hypriot/rpi-mysql:latest
docker images
docker run --name db -d -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 hypriot/rpi-mysql
docker ps
docker exec -it db /bin/bash
@youngsoul
youngsoul / requirements.txt
Created August 16, 2017 18:13
Pip install scikit-learn
pip install scipy
pip install scikit-learn
pip install jupyter
pip install matplotlib
pip install pandas
pip install seaborn
@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
@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 / 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 / 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 / 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 / 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 / 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.
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/