sudo apt-get install python3-pip
sudo pip3 install virtualenv
import decimal | |
number = float(1.787654) | |
decimal.getcontext().prec = 2 | |
dec_number = decimal.Decimal(number) * 1 | |
print str(dec_number) |
import smtplib | |
import string | |
def smtp_gmail(): | |
username = "your smtp username here " | |
password = "your smtp password here" | |
smtp_server = "smtp.gmail.com:587" | |
email_from = "sender email" | |
email_to = "recipient email or wireless carrier sms #" | |
email_body = string.join(( |
# take snapshots to create a timelapse video | |
import time | |
import picamera | |
method = raw_input("Select timelapse in seconds or minutes (S or M):> ") | |
if "s" in method or "S" in method: | |
seconds = int(raw_input("Enter photo interval in seconds: >: ")) |
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@somewhere.com", "email2@somewhere.com", "email3@somewhere.com"] | |
email_from = "sender email" |
# 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 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 using a dict instead of numerous if/elif statements. | |
handlers = { | |
"A": funtion_one, | |
"B": function_two, | |
"C": function_three, | |
"D": function_four, | |
"E": exit | |
} |
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 |
#!/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 |