sudo apt-get install python3-pip
sudo pip3 install virtualenv
import datetime | |
# When dumping to csv excel puts date in 5 digit float format (e.g. 39856.0) | |
# function converts series of dates to date string. | |
def date_to_string(digit_date): | |
new_form = [] | |
for d in digit_date: | |
try: | |
x = datetime.date(1899,12,30) + datetime.timedelta(days=float(d)) | |
new_form.append(x.strftime('%Y-%m-%d')) |
NAME | |
nose.tools | |
DESCRIPTION | |
Tools for testing | |
----------------- | |
nose.tools provides a few convenience functions to make writing tests | |
easier. You don't have to use them; nothing in the rest of nose depends | |
on any of these methods. |
# Source: https://stackoverflow.com/questions/27934885/how-to-hide-code-from-cells-in-ipython-notebook-visualized-with-nbviewer | |
from IPython.display import HTML | |
HTML('''<script> | |
code_show=true; | |
function code_toggle() { | |
if (code_show){ | |
$('div.input').hide(); | |
} else { |
#!/usr/bin/python | |
'''Having a little fun with Raspberry Pi and gpiozero. Small script that uses | |
a button and leds to indicate a graceful Linux shutdown. | |
Module at https://github.com/RPi-Distro/python-gpiozero | |
Wiring your button | |
https://github.com/RPi-Distro/python-gpiozero/blob/master/docs/inputs.md |
# Example of using a dict instead of numerous if/elif statements. | |
handlers = { | |
"A": funtion_one, | |
"B": function_two, | |
"C": function_three, | |
"D": function_four, | |
"E": exit | |
} |
import decimal | |
value1 = 29.458699990 | |
value2 = 0.458699990 | |
decimal_places = 2 | |
def decimalize(value, decimal_places): | |
"""Round a value to a specified decimal place.""" | |
left_of_decimal, the_decimal, right_of_decimal = str(value).partition(".") | |
if left_of_decimal == str(0): |
# Example of job definition: | |
# .---------------- minute (0 - 59) | |
# | .------------- hour (0 - 23) | |
# | | .---------- day of month (1 - 31) | |
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... | |
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat | |
# | | | | | | |
# * * * * * user-name command to be executed | |
import smtplib | |
import string | |
def smtp_gmail(): | |
username = "your smtp username here " | |
password = "your smtp password here" | |
smtp_server = "smtp.gmail.com:587" | |
recipients = ["[email protected]", "[email protected]", "[email protected]"] | |
email_from = "sender email" |
1 - Create the file /etc/modprobe.d/8192cu.conf | |
2 - Add the following line to the file | |
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0 | |
3 - Reboot | |
4 - Check if power saving mode is switched off (0 = off, 1 = on) | |
cat /sys/module/8192cu/parameters/rtw_power_mgnt |