Skip to content

Instantly share code, notes, and snippets.

@youngsoul
youngsoul / OmegaPhilipsHue.py
Last active December 22, 2015 03:33
Example python script to turn on Philips Hues lights with Onion Omega board
__author__ = 'youngsoul'
import time
import random
from string import Template
import urllib2
"""
Dev Note:
@youngsoul
youngsoul / HelloBottle.py
Created November 17, 2015 06:27
Example of setting up Bottle on Onion Omega
"""
vi /etc/opkg.conf
— delete line ‘option check_signature 1'
opkg update
mkdir -p /home/bottle
wget --no-check-certificate https://github.com/defnull/bottle/raw/master/bottle.py
opkg install python-light
opkg install python-email
opkg install python-codecs
opkg install python-logging
@youngsoul
youngsoul / session3-project.ino
Created December 10, 2015 03:51
Particle Photon Session 3 Project
#include "InternetButton/InternetButton.h"
/**
* Session3 Project
* Upon Startup:
* ** create a rainbow with the LEDs. hint: b.rainbow(10);
* ** set the Button LEDs (at position 3,6,9,12) to Red
* ** subscribe to an event called, 'showRainbow' that shows rainbow
* and returns the LEDs to their previous color. Either red or Green
* ** create a function call 'doReset' that will reset the LEDs to Red
*
@youngsoul
youngsoul / rpi_python3_setup.sh
Last active February 5, 2017 16:39
Shell script to setup python3 on raspberry pi
#!/bin/bash
# https://www.raspberrypi.org/documentation/linux/software/python.md
echo "Run sudo raspi-config? [y/N]:"
read runraspi
if [ "$runraspi" = "y" ]
then
echo "*** execute: sudo raspi-config ***"
echo "Perform the following configuration tasks:"
echo "*** Expand the root filesystem ***"
@youngsoul
youngsoul / gist:d99173eff3570036c2bef9636120adf6
Created February 6, 2017 02:13
If pip3 install fails with ImportError: cannot import name IncompleteRead
https://forums.adafruit.com/viewtopic.php?f=50&t=100684&p=503827#p503827
sudo apt-get remove python3-pip
sudo easy_install3 pip
then retry the pip3 install <package>
@youngsoul
youngsoul / setup_onion_omega_ssh_keys.txt
Created February 18, 2017 13:47
Setup onion omega ssh keys
# https://community.onion.io/topic/489/is-there-a-step-by-step-for-setting-up-private-public-key-use/2
cd ~/.ssh
eval `ssh-agent -s`
ssh-keygen -t rsa -C "user@email.com"
ssh-add id_rsa
@youngsoul
youngsoul / PandasTest.py
Last active May 6, 2021 19:49
http://bit.ly/2nFLe2JDataSchool Pandas Video #2reading from url gave some SSL errors, and using requests was able to fix this.This is an example usage on how to get the movieusers
import pandas as pd
from io import StringIO
import requests
requests.packages.urllib3.disable_warnings()
url = 'http://bit.ly/movieusers'
data = requests.get(url=url, verify=False).text
data_reader = StringIO(data)
@youngsoul
youngsoul / get_mnist_dataset.py
Created April 11, 2017 02:26
Download the MNIST data as needed for the 'Hands-On Machine Learning with Scikit-Learn and TensorFlow' book
from six.moves import urllib
from sklearn.datasets import fetch_mldata
import requests
requests.packages.urllib3.disable_warnings()
"""
Adapted from the Github repo:
https://github.com/ageron/handson-ml
for the 03_classification notebook.
@youngsoul
youngsoul / custom_ordered_pandas_data_frame.py
Created May 5, 2017 01:11
Create a categorical column order for the Python for Data Science and machine learning class on Udemy
# create a collection of the ordered months
all_months = ['January', 'February', 'March', 'April','May','June','July','August','September', 'October', 'November', 'December']
# create a categorical column from the month column
flights['ordered_month'] = pd.Categorical(flights['month'], all_months)
flights.head()
fp = flights.pivot_table(index='ordered_month', columns='year', values='passengers')
sns.heatmap(fp)
@youngsoul
youngsoul / MCP3428_N.py
Last active May 19, 2017 03:39
Rework of the ControlEverything MCP3428_N.py file to handle 16,14 and 12 Bit ADC resolution
# This gist is a re-work of the file: CE_PYTHON_LIB/MCP3428_N.py
# from ControlEverythingCommunity github page
# https://github.com/ControlEverythingCommunity/CE_PYTHON_LIB/blob/3c3b1be89dc105d7f11e4d0549a689f1cf145ac2/MCP3428_N.py
#
# I modified it so that it would actually handle 16 bit, 14 bit and 12 bit resolution settings.
# The other thing I noticed, was that at full 10V scale, I expected a value of 65535 ( or close ) but instead I got a
# values closer to 32768. I am not sure exactly why that is.
# I also modified to show the voltage ( assuming a 10V input )
# Distributed with a free-will license.