Flash

Send to Kindle I was looking for some Raspberry Pi project to do that not only used external hardware (even if that means only an LED for now), but also reached out into the net to deal with some kind of real time data. I ran into this t...
Send to Kindle I was looking for some Raspberry Pi project to do that not only used external hardware (even if that means only an LED for now), but also reached out into the net to deal with some kind of real time data. I ran into this tutorial on adafruit about checking your gmail with a Pi and lighting up an LED based on whether or not you have new mail. This was along the lines of what I wanted to do, but had two drawbacks. One, I don’t use gmail anymore, and two, it uses a python library called feedparser, which is actually an RSS parser. It only works because apparently you can access your gmail as an RSS feed or something. I wanted to do the same thing, but with any email service that supports, say, IMAP4. A bit of digging around and I found that Python has an imaplib library that can directly access any IMAP4 based 12mail account. This is included by default in the Python distro that comes with Raspbian. So no further setup there. It took a bit of fiddling around with the docs, both of the library itself and the IMAP4 specs, but I figured out the basic sequence. The library docs are here: http://pymotw.com/2/imaplib/ And the IMAP4 spec is here: http://tools.ietf.org/html/rfc3501.html First, you create an IMAP object with one of the following lines, depending whether you need SSL or not. My server does need it. imap = imaplib.IMAP4(server, port) or imap = imaplib.IMAP4_SSL(server, port) Then, you log in: imap.login(user, password) You then need to go into select mode to select IMAP folders and messages. imap.select() Then you can do a search. By default, you’ll be searching in your inbox, but there are methods to change folders as well. Search criteria are pretty powerful, but I just wanted to see how many unread messages I have. This does that: type, data = imap.search(None, "UNSEEN") The first parameter is the encoding. Using None will return messages with any encoding. Second param is the search criteria. See the IMAP4 spec linked above for a comprehensive list on what you can search for. This will return a type, data tuple of strings. The type will be “OK” or “NO” depending on success of the call. Note, even if it returns no unread messages, you’ll still get “OK” here, with an empty string in the data. The data will be an list of strings. Actually, it seems to generally be an list containing a single string. This string is a space delimited list of numbers. These numbers are ids of the messages returned by the search. It’ll be something like this: “1 2 3 4 5″. You can split this into a list of individual ids like so: messages = data[0].split() And the length of this list tells you how many messages the search returned. Zero means no new mail. One or more and you have new mail! Fire up an LED! Here’s the full program I wrote: #! /usr/bin/python import imaplib, time import RPi.GPIO as GPIO GREEN_PIN = 25 RED_PIN = 24 class MailChecker: def __init__(self, server, port): GPIO.setmode(GPIO.BCM) GPIO.setup(GREEN_PIN, GPIO.OUT) GPIO.setup(RED_PIN, GPIO.OUT) GPIO.setwarnings(False) try: self.m = imaplib.IMAP4_SSL(server, port) except: self.do_error("Unable to contact server") def do_error(self, error): # maybe flash another error LED print(error) exit() def log_in(self, user, password): try: self.m.login(user, password) except: self.do_error("Unable to log in") def check_mail(self): type, data = 0, 0 try: self.m.select() type, data = self.m.search(None, "UNSEEN") except: self.do_error("Unable to check messages") if type == "NO": self.do_error("Problem checking messages") self.report(data) def start_checking(self, interval): while True: self.check_mail() time.sleep(interval) def report(self, data): message_count = len(data[0].split()) if message_count > 0: print("You've got %i new messages" % message_count
20 minutes ago
3D Zoom One is a stack of photos with dragger control and previous/next buttons. Configure settings in XML for image size, description width and height, tweener transition effect, number of photos displayed in stack form, HTML-CSS descri...
3D Zoom One is a stack of photos with dragger control and previous/next buttons. Configure settings in XML for image size, description width and height, tweener transition effect, number of photos displayed in stack form, HTML-CSS descriptions for photos, etc.Views: 77 | Downloads: 4Added: Tue, 21 May 2013 17:13:11 +1300
about 11 hours ago
Learn how to create PDF versions of your folios, including interactive states, to share across your organization for review and feedback.
Learn how to create PDF versions of your folios, including interactive states, to share across your organization for review and feedback.
about 17 hours ago
Get a first look at the next generation of Dreamweaver, with new features for visual CSS Designer and more.
Get a first look at the next generation of Dreamweaver, with new features for visual CSS Designer and more.
about 21 hours ago
Send to KindleRecap As stated in my previous post, the plan was to hit a button that’s connected to my Raspberry Pi, which will trigger Winamp running on my pc laptop to play/pause. This without the Pi being physically connected to...
Send to KindleRecap As stated in my previous post, the plan was to hit a button that’s connected to my Raspberry Pi, which will trigger Winamp running on my pc laptop to play/pause. This without the Pi being physically connected to the pc – all via wifi and my local home network. The hardware setup Raspberry Pi with USB wifi, a small breadboard, 100k ohm resistor, a pushbutton and some hookup wire. GPIO pin 25 goes to one side of the switch, 3.3 volts to the other. You hit the switch, pin 25 gets juice and goes HIGH. The 100k ohm resistor is also hooked to pin 25 on one side and ground on the other, connecting 25 to ground when the switch is not connected, ensuring it is in a LOW state. For those of you in the know, this is a basic pull down resistor. If you’re not familiar with the concept, as I was not last week, this is a good explanation: http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/ The Python The Raspberry Pi is running a simple program written in Python: import url
7 days ago
Send to KindleBack story I wanted a media center. I priced out cases, power supplies, hard drives, cheap motherboards, etc. and figured I could build one for a couple hundred bucks or so. Then I heard about people using Raspberry Pi̵...
Send to KindleBack story I wanted a media center. I priced out cases, power supplies, hard drives, cheap motherboards, etc. and figured I could build one for a couple hundred bucks or so. Then I heard about people using Raspberry Pi’s as media centers. Did a bit of research and got me a Pi and set up OpenElec on it. Plugged in an old 500 GB USB drive. I had a media center for about a quarter of what I was going to pay. Thing is, getting the Pi set up was so much fun, I decided to buy another one just to play with. A week later I bought an Arduino Uno. I even pulled my barely touched Beagle Board out of cold storage and plugged it in. I’ve been having a blast the last couple of weeks playing with all these new toys. Bought a bunch of electronic parts, breadboard, hookup wire, gathered up some other junk I had stashed here and there. Back back story When I was 11 or 12 years old, one of my class mates brought in this Radio Shack 75-in-1 Electronics kit and did a little presentation on how to hook u
7 days ago
Learn how to use the GameInput API to communicate with several different types of devices.
Learn how to use the GameInput API to communicate with several different types of devices.
8 days ago
Get the latest information for IT or administrative professionals who manage the installation or use of Flash Player for multiple users in a controlled environment.
Get the latest information for IT or administrative professionals who manage the installation or use of Flash Player for multiple users in a controlled environment.
11 days ago
Alternate Gallery (Alternative) is free image gallery developed by using Adobe Flash and XML. Configure gallery settings in XML file for number of rows, number of columns, tween transition and duration, HTML-CSS image description, thumbn...
Alternate Gallery (Alternative) is free image gallery developed by using Adobe Flash and XML. Configure gallery settings in XML file for number of rows, number of columns, tween transition and duration, HTML-CSS image description, thumbnail size, border size, etc.Views: 111 | Downloads: 12Added: Thu, 09 May 2013 17:04:27 +1300
12 days ago
Learn how to make a single folio to look good on both standard definition (SD) and high definition (HD) iPad and iPhone devices.
Learn how to make a single folio to look good on both standard definition (SD) and high definition (HD) iPad and iPhone devices.
20 days ago