A while back I had an e-mail from my web hosting company saying they were increasing the price for the package I was using. This got me thinking about whether the route I’d taken for hosting was the best option and if I’m getting my money’s worth there. For reference I had a reseller hosting package, hosting a few sites for family members using not very much disk space or bandwidth – certainly not near the allowance on the package. So I started thinking about what I would do if it was just my site, and this is my thinking out loud/somewhere to document my ideas/findings:
- Host a blog
- Easy to update
- Ability to experiment with styling
- Use my existing URLs
After considering a few options including wordpress.com, github pages, Scriptogr.am, my Raspberry Pi and various static site generators – I decided to move my sites to run on a Droplet at DigitalOcean which gives me the flexibility I want for my site, whilst still being able to host the other sites in the same place.
Currently I’m still using WordPress for my blog, but I’m experimenting with a static site generator for the next round of changes
For Christmas the girls gave me a Raspberry Pi, and for my first project I decided to try recording how bright the sunlight at our window is using an old Webcam.
The basic idea is:
- Capture a photo
- Analyse the brightness of the photo
- Log it (and eventually publish to cosm)
So first of all getting the webcam set up – My webcam is a Logitech Quickcam Express, which proved to work nicely with the Raspberry Pi, after plugging it in, it showed up straight away in the output to lsusb:
ricky@pi ~ $ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 046d:0840 Logitech, Inc. QuickCam Express
To get the photo from the webcam I used fswebcam which was simple to install (sudo apt-get install fswebcam) and use:
fswebcam --no-banner -d /dev/video0 webcam.jpg
The no-banner removes the default date and time at the bottom of the image, /dev/video0 is where the webcam appeared and webcam.jpg is the file to save the image to.
I found a python function to calculate the brightness of the image from StackExchange so put it all together and here is the python script I’m using:
os.system("fswebcam --no-banner --scale 50x50 -d /dev/video0 webcam.jpg")
im = Image.open("webcam.jpg")
stat = ImageStat.Stat(im)
r,g,b = stat.mean
brightness = math.sqrt(0.241*(r**2) + 0.691*(g**2) + 0.068*(b**2))
dt = datetime.datetime.now().strftime("%Y%m%d-%H:%M:%S")
data = '%s,%sn' % (dt, brightness)
It could be tidied up quite a bit and I’m sure there’s a way to capture the image within Python without having to write it to disk first as well. My first days readings taken every 10 minutes look something like this:
A while back I wrote my original script to tweet event reminders from Google Calendar and it’s been through a couple of iterations since and been broken for a while. Well finally I got round to update it to use OAuth to connect to twitter using the twitteroauth library and switched to using Postmark Inbound for handling the incoming e-mail.
What you will need
Getting set up
Register a new twitter app from the Twitter Developer Site (making sure you sign in with the account you want the tweets to come from) – fill out all the necessary fields and click create. On the next page you should get the OAuth details (Consumer key and Consumer secret) and a section to generate your access token and access token secret, these all need putting into the section at the top of the script.
Install the script on your web hosting, along with the twitteroauth directory from twitteroauth at GitHub. If you got to the script URL in a web browser you should see it post a , to your twitter account without any errors. (I need to add some testing code really!)
Set up a server in your Postmark account then go into the Settings page for that server and update the Inbound Hook to point to the full URL of the script on your server to point to your script for inbound emails. Make a note of the inbound e-mail address from the server tab of your settings as you will need this to forward the calendar reminders to.
Add your Inbound Email address as a forwarding address to your Gmail account. It will send a confirmation code to the address, which you can collect from the Inbound section of the Postmark interface
Create a filter in your gmail account to forward your calendar reminders to the Inbound Email address from your postmark account (Mine forwards anything from firstname.lastname@example.org).
Now everything should be in place to start sending reminders. For each event in your calendar set up e-mail reminders for the number of days/hours before you want the reminder tweeted. These should then appear something like this at twitter:
<Description> this afternoon at <time>, <Location>
<Description> next Saturday at <time>, <Location>
Yes I know it’s now the 2nd December so this is a day late, but here’s a list of the online advent calendars I’ve seen so far (and I’ll probably keep adding to it!)
24 Ways – Web development tutorial every day till Christmas
DTS Advent Devotionals – A devotional each day on the names of Jesus
Adfont Calendar – A free webfont every day in advent
Prezzo – A competition to win vouchers each day
Inky Advent - An inky picture each day by Johanna Basford
Advent verses – My own one with the advent verses I’ve put in the girls advent calendar
Christmas is Coming – A christmas themed illustration every day
Yo Illo Illustrator’s Advent Calendar – An illustration each day from the group of London Illustrators (found via @VeerUpdate)
For a while I’ve been turning off iptables to let my secondary machine connect as synergy client to let me use one keyboard and mouse across both machines. Finally today I decided to set up the rules properly to do it, so here’s how:
Create a new rule file in the iptables chain directory for incoming rules:
sudo vi /etc/iptables.d/filter/INPUT/53-custom-synergys.rule
with the following lines in it:
# Allows incoming flows for Synergy.
-A INPUT -p tcp -m tcp --dport 24800 -j ACCEPT
-A INPUT -p udp -m udp --dport 24800 -j ACCEPT
Restart iptables for the rules to take effect
sudo /etc/init.d/iptables restart
For a while I’ve been following the updates on a new plugin for WordPress – Artsy Editor which gives you a completely clean page in which to write your post with easy access to the formatting options through a popup which appears intelligently when you select text, as seen in the image above. You can also drag an image into the editor to upload and insert it where you are typing. All in all it works really smoothly.
In the new release of WordPress 3.2 there is also a similar full browser editing feature included called distraction-free mode. It works pretty well and but it doesn’t have drag and drop uploading and it’s formatting bar feels more cluttered. While you are writing both options provide you with a completely clear page in your browser when you move your mouse with the distraction-free editor you get a full toolbar appear, where as in Artsy Editor, the interface stays very minimal until you select the text or click on one of the controls. The WordPress distraction-free view pulls in the editor css specified by your theme for the editing section in the page, where as Artsy Editor allows you to choose a background and font from a list of choices – which works well as the whole page takes on the background colour not just the editing section as the wordpress view does. The other major advantage in Artsy Editor for me is in the ease of publishing (I’m very prone to leave drafts sitting around for months) – when you move the mouse from editing, the one button it shows is to Publish (you can hover over it to save draft, preview, view HTML or send to trash).
The distraction-free editor isn’t that far behind and I can see it improving in the coming releases, but for me I prefer the streamlined interface of Artsy Editor, particularly it’s drag and drop image handling. Try out the uncluttered interface of Artsy Editor for yourself at the website!