Saturday, April 6, 2013

The Big Move

Growing up

I have recently decided to start playing with the grownups. In the past few months, I have moved from using a Raspberry Pi for my webserver, to using a remotely hosted Virtual Private Server(VPS).

My previous post on OwnCloud on the Raspberry Pi has garnered a bit of attention, and seems to have helped a few people out. I couldn't be happier about that! Unfortunately, the Pi has gone dormant for the past few months as I had moved my OwnCloud instance to an old laptop with a bit more RAM and beefier processor.

On to the VPS

Alas, I have also managed to outgrow the laptop. I feel that the laptop was always a stopgap measure, because it is eventually going to be converted into a digital picture frame, but since I keep messing with these web-services, the start date keeps getting pushed back for that little project. This past week, I moved to VPS. I found it on for $3.95 per month, from Now, this isn't the most powerful VPS, but it has 512MB of RAM, two CPUs, and 60GB of storage. It also runs CentOS, which seems to be a bit of a Fedora derivative. I also get 1TB of bandwidth a month. I am pretty impressed, for $4/month.

Now, I have managed to set up a new instance of OwnCloud, and have also tacked on an instance of Tiny Tiny RSS(TT-RSS). I was heartbroken about Google's big spring cleaning news, so I took it upon myself to make sure that no one can take my RSS reading addiction away again.

A Real Database

I did something a little different this time 'round. Instead of relying on SQLite for OwnClouds database, I decided to do a full jump into MySQL. Either MySQL or PostreSQL is required for Tiny Tiny RSS, so I figured it was time to step into the big database world. It was not too difficult to run some searches to figure out how to build the tables required, to create MySQL users for each service, but I am starting to look into database optimization.

Why optimize something that is only used by one person? Well, on day 2 of using the services, particularly TT-RSS, I noticed a major slowdown. It didn't really seem that the server was under any kind of load, but I was worried that there was something wrong with the MySQL database. After running, I found out that, compared to the instance on my laptop, that there was no caching being done of any of the queries or threads. So, I managed to set those up and have been noticing a steady increase in speed. I also learned that since TT-RSS uses innoDB that I should look into a few other issues. I have not had a chance to try the steps listed in that guy's threads, but I hope to do it soon.

To the Future

Another reason that I decided to implement a more robust database service is because I am planning to start offering these services to friends and family. I am getting ready to start what I am dubbing an 'Internet Services Cooperative.' 

On a Quick Side Note

I have also managed to finally move away from using GoDaddy for my domain registrar and moved to NameCheap! It was an amazingly smooth transition.

Thursday, October 25, 2012

ownCloud on a Raspberry Pi

This is a project that I have wanted to do for quite a while now. I finally got a free day this previous weekend, so I thought I would dedicate a little time to playing with the Raspberry Pi. The Raspberry Pi, for those not in the know, is a $35 ARM powered computer that is about the size of an Altoids Tin. I only had a day for my project and decided that setting up ownCloud would be interesting. ownCloud is an alternative to many different cloud services, such as file storage (Dropbox, Google Drive, SkyDrive, etc.), calendars (Google Calendar, etc.), music player (Google Music), personal picture viewer (Picasa, flickr,etc), and others. It has quite a few interesting features and is very actively developed.

Setting Up the Raspberry Pi

The Raspberry Pi is surprisingly easy to set up with Raspbian, and I was off and running in no time. I would go through the details, but I followed the Raspberry Pi Wiki article on SD card setup. I was able to use SSH to login after the first boot, so I did not even have to plug it into my TV. I did not do anything special with the configuration of my Pi, but I plan on activating the turbo setting in the firmware, so I can get the processor speed up to 1Ghz.

Setting Up nginx and PHP

In order to run ownCloud, you need a webserver and PHP. Apache can be a bit big for the Pi which only has 256MB of RAM (they now come with 512MB), so I chose to install nginx and PHP-FPM
aptitude install nginx php5-fpm php5-sqlite php5-gd
 Then, create a file in /etc/nginx/sites-available/. I called mine owncloud.vhost:
# redirect http to https.
#server {
#  listen 80;
#  server_name;
#  rewrite ^ https://$server_name$request_uri? permanent;  # enforce https

# owncloud (ssl/tls)
server {
  #listen 443 ssl;
  listen 80;
  #ssl_certificate /etc/nginx/certs/server.crt;
  #ssl_certificate_key /etc/nginx/certs/server.key;
  #server_name localhost;
  root /usr/share/nginx/www/owncloud;
  index index.php;
  client_max_body_size 1000M; # set maximum upload size

  # deny direct access
  location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
    deny all;

  # default try order
  location / {
    try_files $uri $uri/ @webdav;

  # owncloud WebDAV
  location @webdav {
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param HTTPS on;
    include fastcgi_params;

  # enable php
  location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param HTTPS on;
    include fastcgi_params;
I actually got the majority of this file from Then create a soft link to /etc/nginx/sites-enabled:

ln -s /etc/nginx/sites-available/owncloud.vhost /etc/nginx/sites-enabled/

Note: I removed the default server in sites-enabled.

I then modified /etc/php5/fpm/php.ini to include the following:

Installing ownCloud

I downloaded the gzipped tar of ownCloud 4.5 from, then decompressed it and copied it to /usr/share/nginx/www/owncloud.


sudo chown -R www-data:www-data /usr/share/nginx/www/owncloud

You should now be able to start nginx and php-fpm, then using your web browser to go to the IP address of your Pi, and BOOM! ownCloud!

Wednesday, October 10, 2012

A Simple Pump: The Idea

The Premise

Fig. 1: A Piston Pump (left). Wikipedia
Atlanta is hot in the summer, so have a cool drink can become very necessary (especially when wearing a costume at Dragon*Con). Now, a steampunk would not be caught carrying around a CamelBak, and a canteen, while practical, is a bit boring. Why not use a pump to bring fluid from my backpack to a dispenser and maybe find a way to cool it in the process.

I want to create a piston-cylinder device (see Figure 1) to pump fluid through a cooling medium and out of a dispenser. The pump will also be powered by my flywheel. After, a bit of searching, I think I have come up with a simple, easy to build pump.

The Proposed Method

My current idea is to take an empty wine bottle, lop off the bottom, machine an airtight piston to fit inside the bottle, then run the piston using a crank arm. Figure 2 is a conceptual drawing of the idea.

Figure 2: Conceptual Sketch of A Pump.
Bottle(Green), Piston(Black),
Crank Arms(Blue), Liquid(Teal?)
As the left-side arm rotates, the piston will create pressure, forcing the fluid out of the mouth of the bottle to the right. It should also be reversible, in order to draw the fluid back into the bottle, for storage.

To cut the bottom off the bottle, I will try this tutorial from They get a bit long winded in the video, but thanks to the Wadsworth Constant, you can use this link instead and skip over the fluff.

As for the piston, I have not decided on how to make that yet. I am stuck between two different options:

  1. Machine metal into shape, and use some rubber grommets to create the seal
  2. Use a 3D printer to create a piston out of ABS, then machine it to fit

I am leaning more toward #2, but then again, I just really want a Solidoodle.

The interface with the flywheel is probably going to be a combination of a pulley and belt connected to the flywheel shaft, and a worm drive connected to the crank arm. There will also need to be a reversal option available, but that might take the form of a crossed belt drive.

The Concerns

I am concerned about efficiency with this design. The input is coming from a very high rotational velocity(the flywheel) and trying to convert it to a very slow linear velocity(the crank arm). I have a feeling that this mechanism will be more of a metering device than an actual pump. It will take a bit more thought to understand how this system will function.

I will be creating another post about the math behind the pump, after a few considerations for placement and orientation. I primarily wanted to get this information out of my head.

Thursday, October 4, 2012

Mind Mapping

Since leaving Dragon*Con, I have been doing my best to keep track of all the ideas that I want to implement in my costume. In order to do that, I have been using a technique called Mind Mapping. It is a wonderful concept generation tool. If you have never tried it, then you should take a look at the Wikipedia entry, and Dr. Dobb's takes a look at the technique from a software development point of view.

The Process

Fig. 1: My Collapsed Mind Map
To outline the basics: you start with a central topic, then expand outward getting more and more detailed. As you can see in Figure 1, my central topic for this map is my Con costume. It then radiates out into the main parts of the costume. The map gets more-and-more specific about what will go into
each section, as your radiate further away from the central topic.

The Software

Fig. 2: SimpleMind Free version of my Con Costume mind map.
When I said that I have been working on this project since leaving the Con, I truly meant it. While my wife was at the wheel, I had my phone out creating the initial map. Figure 2 is a screenshot of the current (as of posting). I used SimpleMind Free for Android. It makes some very pretty mind maps, and the paid version can sync with Dropbox and export to the Freemind file format, which is kind of a universal format for mind maps. 

Once I got the initial map settled down, I went to work transcribing it into FreePlane, which is the successor of Freemind. I feel that FreePlane does not make as pretty of a mind map, as SimpleMind does, but it is opensource as well as usable on PC, Mac, and Linux. Below, in figure 3, is an example of what the FreePlane output looks like.
Fig. 3: FreePlane version of my Con Costume mind map.
Yes, I did obfuscate the further branches on both figure 2 and 3, but only to keep those subjects for later discussion.


Mind maps are wonderful to help document concept generation. I find myself prototyping ideas using mind maps all the time. I tend to think about all aspects of a project at once, so mind maps help me capture all of those thoughts in a coherent manner.

Wednesday, September 26, 2012

An Introduction to Flywheel Energy Storage Principles

Editorial Note: This is a very math heavy post. They won't all be this way, although it is a very engineering heavy project. Once I get to the prototyping phase, things should settle down a bit. Also, if the math fonts look bad, right click and set the math renderer to SVG.

Preliminary Flywheel Sizing

Before I get too far into the design of my Dragon*Con costume, I need to do a bit of a study in feasibility. The biggest unknown for my costume is: How big of a flywheel will I need to power my contraptions? In order to start answering this, I need an approximation. Since I want to be able to charge my cell phone using the energy stored in the flywheel, I figured that would be a good place to start. The charger explicitly states the output and barring any gross inefficiencies in any of the electrical circuits, I have calculated the information below.

Energy Needs

At the peak, my cell phone charger's output is 5VDC @ 1A. Therefore the energy required to run the charger for 1hr is:

E_{req.} &= 5VDC \cdot 1A \cdot 1hr\\
E_{req.} &= 5watt \mbox{-} hours

5watt-hours does not seem like much.

Flywheel Energy Storage Equations

The rotational energy stored in a flywheel is calculated using the following equation:

\[ E_{k} = \frac{1}{2} I \omega^{2} \]
  • \(E_{k}\) is the rotational energy, in Joules.
  • \(I\) is the mass moment of inertia, in \(kg \cdot m^{2}\).
  • \(\omega\) is the angular velocity, in radians per second.
Since these calculations are primarily to determine viability of having a spinning ~5lb mass of steel on my back, I decided to assume that the mass moment of inertia could be approximated using the equation for a thick-walled empty cylinder:

\[ I = \frac{1}{2} m ( r_{external}^{2} + r_{internal}^{2} ) \]
  • \(m\) is the mass, in kilograms.
  • The \(r\)'s are radii, in meters.

The Exciting Conclusion

Since I have an idea of how large of a diameter I want my flywheel to be, then my unknown variable becomes \(\omega\). In order to find \(\omega\), I started by defining my variables:

r_{internal} &= 0.1143 m ( 4.5in )\\
r_{external} &= 0.1270 m ( 5.0in )\\
M &= 2.268kg( 5lb )\\
E_{k} &= 1800J( 5watt \mbox{-} hours )\\

Then, substituting the equation for the mass moment of inertia into the rotational energy equation, we get:

E_{k} &= \frac{1}{4} m ( r_{external}^{2} + r_{internal}^{2} ) \omega^{2}\\
18000J &= \frac{1}{4} \cdot 2.268kg \cdot ( 0.1270^{2}m + 0.1143^{2}m ) \cdot \omega^{2}\\

Then, we need to solve for \(\omega\):

\omega^{2} &= \frac{18000J}{\frac{1}{4} \cdot 2.268kg \cdot ( 0.1270^{2} + 0.1143^{2} )}\\
\therefore \omega &= 1042.8 \frac{radians}{second}\Rightarrow 9958.02RPM\\

From these calculations, I have estimated that in order to charge my cell phone for 1 hour, I need to spin a 5lb flywheel at ~10,000 RPM. Well, that does not sound too bad at all! Of course, the energy storage requirement will be dependent on number of contraptions that I will be engaging at once, and how much energy they will require to perform their tasks. These calculations merely show that the idea is achievable.

Boy, getting a gear ratio that high is going to be another interesting problem.

Extra Credit

I have created a crude SolidWorks model in order to double-check my mass moment of inertia calculations. Since they seemed to be correct, I decided to play with material types for the same shape. It turns out that for the same shape, a flywheel made of 6063 aluminum would only weigh about 1.79lb. That sounds like it would be much nicer to carry around a convention all day. So, I ran the calculations again with the new material in mind and found out that I would have to spin the flywheel at ~18,000RPM. My preliminary finding on bearings seem to indicate that 20,000RPM is going to be my max, so aluminum might be an option!

After looking at bearings, I also reran the calculations for the steel flywheel spinning at ~20,000 RPM and determined that it would be storing ~20watt-hours. This really demonstrates the power of the squared angular velocity term in the rotational energy equation.

Saturday, September 22, 2012

Dusting Off the Old Blog

This blog has long laid dormant. I have brought it back from the brink, in order to capture some of my upcoming projects. I am doing some home improvement, restoration of furniture, and I am most excited about building my costume for next year's Dragon*Con.

As a teaser, my costume for D*Con will fight the Steampunk track. A friend and I were disappointed with the functionality of most of the Steampunk costumes at this year's con and have decided to remedy that by creating our own function costumes. I have decided to base my costume around a backpack that will house a flywheel, which will act as a mechanical battery, storing energy to be used in various mechanisms attached to the pack. Calculations and design ideas are to follow.

Only 341 days left!

Friday, May 15, 2009

Now I can highlight code snippets!

Having recently lost my thumbdrive, I've decided to store more ideas and interesting projects in a more locatable place. At least for now...

I got the syntax highlighting from this site. It details how to edit the layout template.

Here is a sample of code, just to try it out:
def parseStatsFile():
   """Parse the stats file, or create it initially"""
       statsFile = open(fileLoc + "stats.log", "r")
       for s in statsFile:
           statsTemp = s.strip("\n").split("=")

I really hope that I am able to find my thumbdrive. I only managed to back up a couple of important files, before I lost it right after that.