July 7th: MoM RiDaZz TuEsDaY / FuLL MoOn DaSH

Jul 3, 2009

bicycle ride: mom ridazz tuesday / full moon dash @ echo park boat house 10:00 pm sharp

No gym membership required.

Meet @ echo park boat house @ 9 pm We roll out @ 10 pm. (not biker time, its the actual time we split from the meet point.)

This will not be an all night ride. Were trying to leave early so we can finish early, especially for the people who have work the next day.

Come on out and roll with your MoM.

This is going to be a medium paced ride with fast paced thrown in from time to time.

Bring all the stuff you will need like spare tire, pump, helmet, front light and rear light, water and anything else you might want to bring that will keep your wheels rolling and your self happy.

No Ridda will be left behind. We don't leave you. We don't drop people, people drop themselves by either giving up or they don't put enough effort into keeping up with the pack.

We will try and obey all traffic laws. Ride safe and be safe.


Note: The above graphic is something I have put together, feel free to copy it, and print it. Click it for a full size image.

July 9th, Thursday: Fedora 11 Demonstration

Jul 3, 2009

Fedora 11 Demonstration, Thursday July 9th, 2009 for the SGVLUG monthly meetup. 107 Downs at Caltech Campus in Pasadena.

San Gabriel Valley Linux User Group July 9th 7-9pm, afterwards join us at Burger Continental to continue the conversation with food and drinks.

107 Downs at Caltech Campus in Pasadena http://www.sgvlug.org

Fedora 11, code named Leonidas, is the latest offering from Fedora. With over 60 improvements and new features, Fedora 11 will be demonstrated at the meeting.

Larry Cafiero is the Regional Ambassador for the U.S. West Coast for the Fedora Project. He is also a senior partner at Redwood Digital Research in Felton, California (Santa Cruz County), which is a small business/SOHO computer maintenance and networking firm utilizing FOSS programs. He also blogs as "Larry the Free Software Guy"

This will be a presentation you won't want to C-x C-c


Note: The above collage is something I put together. Feel free to copy it, and improve upon it. Click it to view the full resolution version of it. It was fun to put together, but is still rather rough. Even just leave feedback, and I'll see if I can improve it.

FULL MOON HUSTLE NO.4

Jun 4, 2009

Full Moon Hustle

June 7th, 2009

MEET at 1st & Grand on the TOP OF THE PARKING STRUCTURE @ 8:30pm RIDE at 9:30pm

I'll make some stencils again, so bring a t-shirt, or a bag to paint on. And any spray paint you have, I have brown and blue. This is a 20 to 30 mile ride, with moderate hills.

Today we ride to the beach!

UPDATE: Thanks to Hector for showing up. We ended up not riding to the beach but just around downtown for a bit, as it would be better to have at least 5 people to ride with. This will likely be the last Full Moon Ride / Hustle.


How Can I Tell If My Bash Script Is Already Running?

May 23, 2009

I have been writing a bash script that is a daemon that watches and processes a queue file to execute more commands. Instead of running the daemon when the queue is empty I shut it down when the queue has been fully processed. So in the script that I use to add items to the queue I check to see of the daemon is running in if not I start it. However it seems impossible and error prone to grep for the name of the script from ps ax to check for it, so often times I'd end up with multiple daemons running at the same time, writing to the same files, and causing queue processing chaos. I have stumble upon Jonathan Franzone's post, "How Can I Tell If My Bash Script Is Already Running?", for a bash script that checks itself to see if it's already running using a lock file that stores the pid of the process:

A lot of times I have to write Bash scripts that get scheduled to run over and over again. These scripts can also take a while to run depending on the task I have for it. There could be a huge problem if I crank up multiple versions of the same script on accident and they are working on the same files and/or directories. So to solve this problem I’ll use a technique that creates lock files when the script is running and then removes it when it is finished running. Then I can just check for the existence of my lock file before I run the script and exit if it is already running.

To keep things nice and tidy I usually have a section to declare and define all of my variables. This is where I specify what the name of the lock file is going to be. I will generally base the lock file on the name of the currently executing script and just append a .lck file extension.


PDIR=${0%`basename $0`}
LCK_FILE=`basename $0`.lck

Now the very first thing I do in my file is check for the existence of my lock file. The -f option checks that the given file name is a regular file (not a directory or device). If it does not exist then I make the assumption that my script is not running and I create the lock file. Notice that I use the $$ system variable which returns the PID (process ID) of the currently running script. I simply echo this value into the lock file.

if [ -f "${LCK_FILE}" ]; then

...

else
  echo "Not running"
  echo $$ > "${LCK_FILE}"
fi

Well, if the file does exist then we need to make doubly sure that it is running. Why? Well the script may have terminated prematurely and not have had a chance to cleanup the lock file. So I grab the PID value out of the lock file and then use the ps command to see if a process with that PID is actually running. If it is not running then I again just echo $$ out to the lock file. If it is running I just exit.

  MYPID=`head -n 1 "${LCK_FILE}"`

  TEST_RUNNING=`ps -p ${MYPID} | grep ${MYPID}`

  if [ -z "${TEST_RUNNING}" ]; then
    # The process is not running
    # Echo current PID into lock file
    echo "Not running"
    echo $$ > "${LCK_FILE}"
  else
    echo "`basename $0` is already running [${MYPID}]"
    exit 0
  fi

Well, that’s pretty much it! Now if you have to cron (schedule) a Bash script, you can rest assured that you won’t have multiple copies running at the same time. Here is the entire test script that I used. You can copy & paste it to use as a template for creating your own.

#!/bin/bash
# ------------------------------------------------------------
# File        : AmIRunning
# Author      : Jonathan Franzone
# Company     : http://www.franzone.com
# Date        : 09/23/2007
# Description : Test script for creating lock files
# ------------------------------------------------------------

# ------------------------------------------------------------
# Setup Environment
# ------------------------------------------------------------
PDIR=${0%`basename $0`}
LCK_FILE=`basename $0`.lck

# ------------------------------------------------------------
# Am I Running
# ------------------------------------------------------------
if [ -f "${LCK_FILE}" ]; then

  # The file exists so read the PID
  # to see if it is still running
  MYPID=`head -n 1 "${LCK_FILE}"`

  TEST_RUNNING=`ps -p ${MYPID} | grep ${MYPID}`

  if [ -z "${TEST_RUNNING}" ]; then
    # The process is not running
    # Echo current PID into lock file
    echo "Not running"
    echo $$ > "${LCK_FILE}"
  else
    echo "`basename $0` is already running [${MYPID}]"
    exit 0
  fi

else
  echo "Not running"
  echo $$ > "${LCK_FILE}"
fi

# ------------------------------------------------------------
# Do Something
# ------------------------------------------------------------
while true
do
  clear
  echo
  ls -F
  echo
  date
  echo
  sleep 5
done

# ------------------------------------------------------------
# Cleanup
# ------------------------------------------------------------
rm -f "${LCK_FILE}"

# ------------------------------------------------------------
# Done
# ------------------------------------------------------------
exit 0

Fool Moon Hustle No.3 Artwork

May 19, 2009

So the turnout for this last FULL MOON RIDE, which ended up being a fun hustle, was far exceeding expectations. There must have been nearly 30 people at the start. Thanks for those who hustled to the end, not everyone made it, but it was a good 23 mile faster paced ride with a few hills. Here are some of the T-Shirts that we made at the start, thanks for bringing the yellow, black, and silver paint ridaz!

Full Moon Ride T-Shirt Front - May 2009 Full Moon Ride T-Shirt Back - May 2009 Full Moon Ride T-Shirt Back - May 2009 Full Moon Ride T-Shirt Back - May 2009

P.S. Sorry for the late post, should have been posted on the 9th.

FRIDAYFULLMOONRIDE No.3 May 8, 2009

May 7, 2009

[Full Moon Ride]

MEET at 1st & Grand on the TOP OF THE PARKING STRUCTURE @ 8:30pm RIDE at 9:30pm This is (usually) a chill 20 to 30 mile ride, with one or two long stops.

I HAVE MADE A STENCIL, BRING T-SHIRT OR BAG TO PAINT. ALSO BRING A CAN OF SPRAY PAINT (OR ANOTHER STENCIL) SO WE HAVE SOME OPTIONS FOR COLORS. I HAVE BLUE AND BROWN.


Koolu Android on Neo Freerunner Video

May 1, 2009

There are many different distributions of software you can install on the Neo Freerunner mini-computer & phone. Android has been patched to work on the Freerunner by a few different parties. This is a video of the Koolu Android for the Neo Freerunner. While I have been able to make and receive calls, I haven't tried SMS messages yet. The WiFi seems to make a connection okay, however when I pull up the browser I don't get a connection. Also for wireless networks with passphrases, the dialog box that comes up to enter your password overlays the keyboard and changes the mode away so you can't enter a password. I had also experienced several error messages saying "com.android.phone" process quit unexpectedly, however after removing all the APN from Settings -> Wireless Controls -> Mobile Network Settings the messages went away and I have a steady, so it seems, connection with the mobile phone towers. The interface on this on seems the best of everything I have tried, however there are still many things that don't work quite right yet beyond it being a phone. It does have the fastest boot time though!

Video is licensed under the Attribution-Noncommercial-Share Alike 3.0 United States License, the audio is by Nine Inch Nails from their Ghost Album.


Video Player for Safari, Firefox, & Flash

May 1, 2009

DOWNLOAD | download tar.gz

Thanks to the help of a few Safari testers; Ryan, Ara, and Dante, I have released version 0.3 of FoxyVideo which adds support for native video playback in Safari! This is an addition to native playback in Firefox 3.5 (b4 currently), and not to forget that it also works for all other browsers if they have a Shockwave Flash plugin installed such as Gnash, Flash, or swfdec! An example is to the right, it's diagonally moving colored bars with ~700hz sound tone. No browser left behind!


FoxyVideo 0.2 : JavaScript Library for HTML5 Video using Canvas controls w/ parallel ActionScript implementation

Apr 29, 2009

UPDATE: I need some help with debugging this on many different browsers, Safari 4 in particular. You should see color bars moving diagonally with a ~700Hz sound tone. Thanks for the help from a few Safari testers, we now have Safari support! I have removed the example from this page, please go to Video Player for Safari, Firefox, and Flash for an updated example.

DOWNLOAD | download tar.gz

I have released version 0.2 of FoxyVideo with the following changes:

  1. JavaScript is used to insert the elements based on the capabilities of the browser, the previous method of putting the fallback within the video tag did not work because some browsers, like Safari, implement the video tag, but with limited API, and do not support OGG without installing Xiph Quicktime components, so it would show up with Quicktime controls and no video.
  2. Added Canvas element for the controls instead of using Firefox's built in controls, this will mean that once there is an API available in other browsers the interface will remain the same. It also means that we can now change them to be custom.
  3. Added some fixes to the ActionScript implementation with how mouse events where being handled which improves some weird behavior in the the proprietary player.

Here is how you could use it on your site:

<!-- here we need to include the JavaScript Library -->
<script type="text/javascript" src="video.js"></script>

<!-- here is our div element that the video will be inserted into.
     place inside it what you want you would want people to see 
     if they have javascript disabled -->
<div id='testvideo' style="width:320px; height:240px;">
    <a href="test.ogv">
        <img src="test.jpg">
    </a>
</div>

<script>

// Here we use the Video constructor to insert the video 
// into the "test-video" element

vid = new Video({
    'id':'testvideo',
    'width': 320,
    'height':240,
    'sources':[['test.ogv','video/ogg']],
    'flash':{
         'swf':'video.swf',
         'video':'test.flv'},
    'poster':'test.jpg',
    'autoplay':false
});
</script>
To get a copy of the project with all the history, you can use git:
git clone http://braydon.com/foxyvideo.git

Fixed Gear Bicycle

Apr 23, 2009

from copy import copy

class FixedBike():
    def __init__(self, wheel, chain_ring, sprocket):
        """
        wheel =  the diameter of the wheel in inches
        chain_ring = the number of chain teeth
        sprocket = the number of chain teeth
        """
        self.wheel = wheel
        self.chain_ring = chain_ring
        self.sprocket = sprocket
        self.skid_patches = self.skid_patches()
        self.gear_inches = self.gear_inches()

    def skid_patches(self):
        """
        Determines the number of points of contact there are during
        non-switch skidding.
        """
        remainder = int(self.chain_ring) % int(self.sprocket)
        if remainder != 0: x = float(self.sprocket) / 
                               float(remainder)
        else: x = 1
        y, c = copy(x), 1
        while int(y) != y:
            y = x * c
            c += 1
        return int(y)

    def gear_inches(self):
        """
        Determines the gear inches.
        """
        return float(self.wheel) * float(self.chain_ring) / 
                                   float(self.sprocket)


a = FixedBike(27,48,15)
print a.skid_patches
print a.gear_inches