This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import decimal | |
number = float(1.787654) | |
decimal.getcontext().prec = 2 | |
dec_number = decimal.Decimal(number) * 1 | |
print str(dec_number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Raspi-sump, a sump pump monitoring system. | |
# Al Audet | |
# http://www.linuxnorth.org/raspi-sump/ | |
import time | |
import numpy as np | |
import matplotlib as mpl | |
mpl.use('Agg') | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: >: ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
OlderNewer