2012-12-24

After setting up my BeagleBone with a phone so that I can run scripts when certain numbers are dialed, it became apparent that I should have other ways of running scripts on the BeagleBone, and most importantly, it should be possible to run scripts at a given time. Time for a new project!

A bit of Background

For a while, I had been using SSH to connect to the BeagleBone and using the at command to schedule the running of a script at a specific time. For example to run my "maiden_fade" script at 8:10 AM, I would use the following:

echo "morning_maiden" | at 8:10

While that is fine and dandy, I really really did not want to open a terminal, ssh to the BeagleBone, and then type a command in order to do what I want. To make everything nice and easy, I started the Ruby Web Alarm Project. Originally, I had wanted to hack this thing together during a "code sprint" at the NBLUG, but there wasn't enough time. Oh well.

What is Ruby Web Alarm?

Ruby Web Alarm is a small Ruby based webserver with an HTML and JavaScript based UI that allows one to schedule scripts to be run within 24 hours. (This should really be changed to allow a user to set a script to run farther in the future)

Screen Shots!

Some Blather About the Code

As stated previously, the server for Ruby Web Alarm is written in Ruby (hey, fancy that!), and does not use any 3rd party gems. All of the included libraries are part of the Ruby Standard Library.

For the UI, jQuery handles async calls to the server and I'm using a slightly modified stylesheet from the MuttonChop Mobile UI.

What it Needs

While the project mosty does what I need it to do, it still needs some feature improvements such as:

  • Better time input (I'd like to use the HTML5 Range element, but none of the modern webkit based mobile browsers have a working Range element)
  • Daily, weekly, monthly repeating

Maiden Fade?

In case you were wondering what the "maiden_fade" script looks like...

#!/bin/sh
curl http://wind:2876/player/volume/0
/opt/mc_random_iron_maiden.py
for i in {1..35}; do
    curl http://wind:2876/player/volume/$i
    sleep 1
done

It sets the volume to zero, starts playing a random Iron Maiden track, and then, each second of the next 35 seconds it increases the volume by 1. Is there a better way to wake up than to fade into some Maiden?

And if you were wondering about the Random Iron Maiden script...

#!/usr/bin/env python2
import urllib
import json
import random
f = urllib.urlopen("http://wind:2876/audio/search/iron%20maiden")
fjson = f.read()
search_result = json.loads( fjson )
files = search_result['files']
random_file = random.choice( files )
url = "http://wind:2876/audio/play/%d" % (random_file['id'])
urllib.urlopen(url)

UP THE IRONS!

Comments
2013-04-10 Alice:
My coder is trying to convince me to move to .
net from PHP. I have always disliked the idea because of the expenses.
But he's tryiong none the less. I've been using WordPress on a variety of websites for about a year and am worried about switching to another platform.
I have heard very good things about blogengine.net.
Is there a way I can transfer all my wordpress content into it?
Any help would be really appreciated!
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
1 plus 7
Answer:
required
subscribe
 
2019
2016
2015
2014
2013
2012
2011
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008