Contributed Article: Seven Characteristics of Stepper Motors

{lang: 'en-GB'}

Nick Jakubowski over at Circuit Specialists has submitted an article outlining the main characteristics of stepper motors and how they work. Read on for the full article below.

(more…)

Checking File Permissions the Easy Way Using Python

{lang: 'en-GB'}

Edit: Doh! Looks like I forgot something. In Linux, if a file or directory has read, write or executable permissions for the Owner only (nothing for ‘group’ and ‘others’) check_files() doesn’t add a dictionary entry for that path if the user running the script does not own the file or directory. Adding one little ‘elif’ block fixes this. (see the slightly revised code below.)

It never ceases to amaze me what even a wet-behind-the-ears hobbyist like myself can do with Python. I needed a way to get the file permissions and check for the existence of a large number of paths that I could re-use in other scripts. The function shown below is what I came up with.

It takes a Python list containing file/directory paths as an argument and returns a dictionary containing the Paths as keys and the concatenated values ‘READ’, ‘WRITE’, EXECUTE’ separated by commas (or ‘NOACCESS’ if the user doesn’t have read, write or executable permissions) to indicate the users level of access to each path, or just the value ‘NOEXISTS’ if the path does not exist.

def check_files(paths):
        dict = {}
        status=""
        for p in paths:
            if not os.access(p, os.F_OK):
                dict[p]=status=status+"NOEXISTS"
            if(os.access(p,os.R_OK)):
                dict[p]=status=status+"READ,"
            if(os.access(p, os.W_OK)):
               dict[p]=status=status+"WRITE,"
            if (os.access(p, os.X_OK)):
                dict[p]=status=status+"EXECUTE"
            elif os.access(p, os.F_OK) and not (os.access(p,os.R_OK)) and not (os.access(p, os.W_OK)) and not (os.access(p, os.X_OK)):
               dict[p]=status=status="NOACCESS"
            status="" # Set blank before we enter the loop again
        return dict

This function will only give you the permissions for the user running the script but as this was all I needed I did not see that as a major problem. Hope someone finds this useful. As always, you can flame me/prop up my massive ego in the comments :)

Tux

Ubuntu SFTP-Only Account How-to

{lang: 'en-GB'}

This guide will show you how to setup Linux user accounts restricted to using SFTP only. These accounts will be unable to run arbitrary shell commands on the server or access/create files outside their own home directories. The steps in this guide were tested on Ubuntu Server 10.04 with version 5.3p1 of the OpenSSH daemon, obtained from the Ubuntu software repositories.

Although this guide is aimed at Ubuntu users, it should also be applicable to other flavors of Linux as well. The most important factor to consider is the version of OpenSSH you have installed on your system. Version 5.0 or above is recommended as these versions support the OpenSSH ChrootDirectory configuration option that we’ll be using here.

Right, that’s enough of the rambling, let’s get to it…

 

(more…)

Handy Link: PHP Serial Class

{lang: 'en-GB'}

Need a way to talk to your serial devices (Arduino, PIC Micro, etc) using PHP? This nifty new Serial PHP Class written by Rémy Sanchez should scratch your itch! It currently works with Windows and Linux systems.

As of the time this post was written, you will need a Linux system to use the full (that is, Read AND Write) functionality of the Serial Class.  If you are using it under Windows, you will only have Write access to the serial port, but as you can still do quite a lot with just write access as far as projects are concerned I don’t see that as a major drawback.

If you want to see a practical example of the PHP Serial Class in use, the guys at Hak5 have used it to control a Garage door via a Web interface. You can view the full episode here.

Simple Power Loss Detector with SMS Notification

{lang: 'en-GB'}

After having a few un-expected power outages this year, it got me thinking about how I could easily (and cheaply) be alerted (preferably via SMS) should one occur. With a laptop running Linux, a little bit of Python and some easily obtainable hardware and software, I come up with a simple method of doing just that. Read on for the code and set-up instructions. (more…)

Handy Link: Bitwise Operator Video Tutorial

{lang: 'en-GB'}

OK, so I haven’t posted anything here for a while but hopefully this should make up for it. Searching for a tutorial on Bitwise Operators in C brought up the little gem embedded below… Hope it’s useful.

From HPR: Python Roundtable Discussion

{lang: 'en-GB'}

This may be old news to some of you but I thought it was interesting enough to warrant a blog post.

The Podcast site Hacker Public Radio has a rather interesting episode about the current and future plans for the development of Python.  Hope it’s useful to someone.

Back up again!

{lang: 'en-GB'}

The great hosting provider migration is finally over! Good riddence fasthosts (or should I say farsehosts) and hello Cyberhostpro!

From TehnikService: Quick PCB Etching

{lang: 'en-GB'}

TehnikService has an interesting article about PCB etching using the “Sponge Method” This seems like a good way for beginners to get started making their own PCB’s.

Has any one tried this?

New Development Board Offering from Protostack

{lang: 'en-GB'}

Protostack has released a new and improved version of it’s 28-pin development board. It’s priced at $9.60 and includes a number of welcome changes from the one I reviewed here in a previous post.

Read on to see what’s changed….

(more…)

Go to Top