Skip to content

A good guide for using cocoon and paperclip in rails.


Creating a nested model web form in Rails using Cocoon

I’ve recently been working on learning Ruby on Rails for the past few weeks and it’s been a lot of fun.  However, a few days ago I ran into a huge roadblock which was how to make a web form for a nested model.  After several days of rooting through StackOverflow and even searching page 2 of google, I found one tutorial which finally led to a great deal of success.  If you want to check out the original post head on over to and check it out.  Below is a very similar guide which is pretty much just updated for Rails 4 and also includes the migration and controller code.

Now, the primary goal is to have a single form in which we can create data for multiple models which are nested within eachother.  For the purposes of this project we are going to be making a form that will manage user access on a set of projects.  We will have many projects and any number of users can work on a set of projects.  There will be three models we will create, Project, User, and the model which will connect those two will be Contributor.

Read more…

Installing Pithos

This is just a little note for me on the items I need to install to get my version of pithos running.

Python 2.7
– eyeD3

Using GStreamer with Python Part 3

For the final GStreamer guide I have we will be learning how to split data so we can do different things with it.  This project will be showing you a

few new elements which allow us to split incoming data.  We will also be working with Request pads along with everything we’ve learned in the previous two guides.

Splitting Multimedia Project

This project is pretty hefty project because we will be splitting the audio through three different element chains.  Playbin2 will stream the multimedia and automatically play the video. We will pass the audio to a series of elements until it reaches our splitting element, called a tee. That tee will send the stream to three queue elements each of which leads a different chain of elements.  One chain will play the audio normally, one will create a wavescope and output that to the monitor, and one will save the audio as an mp3 file.

The tee element does not do anything aside from splitting the data to multiple pads.  The pads it uses are Request pads.  In order to use these Request pads we need to manually request them through a method call and manually link each pad to the elements they will interact with.  We will need to use separate Queue elements in each branch to provide separate threads for each branch. Otherwise a blocked dataflow in one branch would stall the other branches.  Luckily implementing Queue elements is rather simple.  If you have a good understanding of our previous projects, this upcoming project will be simple.

Read more…

Using GStreamer with Python Part 2

Now that you’ve gotten a taste of what you can do, it’s on to learn some better functionality of GStreamer.  There is really a lot you can do with GStreamer, especially when it comes to video processing.  In this guide, we will be focusing on streaming with the playbin2 element. We will also be working with Pads that have Sometimes along with GhostPads and Bins.

Playbin2 Project

Playbin2 is a great element for GStreamer 0.10.  I believe that in GStreamer 1 and up Playbin2 has been renamed to Playbin. Playbin2 is a single element that can stream media from the internet and play it with little configuration.  Ontop of that, it has several built-in features that let you do a lot with the single element.

Now for our next project we will be streaming video from a website and changing the video using another element and then outputting that product.  To do this, we will be using 5 elements.

  • playbin2 which will get our multimedia from the internet, play the audio on speakers and feed the video to the rest of our elements.
  • decodebin which will decode the video to raw media.
  • autoconvert which we use mostly to connect decodebin to solarize (I’m not sure what its doing behind the scenes)
  • solarize which adds a neat video effect to the video.
  • autovideosink which outputs the video to the monitor.

Now we will take a moment to look at all of our elements Pad Templates.  run gst-inspect-0.10 on each of our elements.  First off, you will notice that playbin2 has no elements.  This still has be a little dumbfounded since we will be giving it a pad in this project.  This will require us to build the project a little differently that our previous one.  Next look at decodebin, it has an Always Sink pad and a Sometimes Source pad. Here the Sometimes pads will only be created when the stream is ready.  It takes some time for that to happen so it will require a callback function which I will explain later.  This Sometimes pad will make connecting to the autoconvert element a little more difficult but we can do it. Autoconvert has Always Sink and Source pads.  Solarize has Always Sink and Source pads with some different capabilities but we wont need to pay attention to that because the next element, autovideosink has an Always Sink pad with ANY capabilities.

Read more…

Using GStreamer with Python

You have probably noticed by now that working with GStreamer and Python is quite difficult, mainly because of the lack of real documentation and examples.  In this guide I will be showing you how to create a Python program which will allow you to Stream video from the internet, split the audio into different elements which will Play the audio, show a waveform of that audio, and save the audio as an MP3 file.  I will also show you tools and resources I found that have been helpful in allowing me to understand how GStreamer works.  Please note that in this guide I will be working with GStreamer 0.10.

You may want to have a look through these pages which I have found to be quite useful in learning GStreamer:

Getting Started

As you may already know, GStreamer is a framework for creating, manipulating and playing multimedia.  With Gstreamer you will be creating and assembling several objects called Elements which handle the data and pass it off to the next element in line.  Sounds pretty simple, right? Well it actually is when you understand how to attach these elements.  First, lets use GStreamer in the terminal to play some music.  Install GStreamer-0.10-tools:

sudo apt-get install gstreamer0.10-tool

Now in the terminal navigate to an mp3 file on your computer and type in:

gst-launch-0.10 filesrc location="myfile.mp3" ! decodebin ! autoaudiosink

Your music will now be playing.  What this is doing is creating a filesrc element which gets the mp3 file.  It then passes it to a new decodebin element which converts it from an mp3 file into audio data. It then passes it to a new autoaudiosink file which is intended to play it through your speakers.  So as you can see, the first element takes the media, does somthing to it and passes it to the next element. That process repeats.  Lets try something else

gst-launch-0.10 audiotestsrc freq=220 ! wavescope shader=0 style=1 ! ffmpegcolorspace ! autovideosink

When you run this, no audio actually plays which is fine.  We didn’t tell it to play any audio.  What this does is create an audiotestsrc Element which merely emits a tone.  We have told it that its frequency will be 220Hz.  It passes that audio to a wavescope element which will create a visual representation of the audio.  The waveform element passes that media to the ffmpegcolorspace element which does something to it (I just know that without this, it will fail).  It then sends that data to autovideosink which outputs the waveform to the monitor.

Read more…

Setting up Kubuntu my way.

I just installed Kubuntu on my home computer.  There was a few steps I needed to take to setup my computer the way I like.  Now this doesn’t apply to pretty much anyone except for me since I’m weird about needed a taller taskbar, numlocks on by default, and Pithos to play Pandora.


Setting up kubuntu:
+ Update System setting defaults
    – Goto System Settings > Input Devices > Keyboard > NumLock – Turn on
    – In Input Devices: Goto Mouse > Icons – Double-click to open files
+ Update Taskbar:
    – Increase the height of the taskbar with the icon to the far right.
    – Add two rows to the taskbar by right clicking > Task manager settings > 2 rows and Force row settings > Apply AND OK
+ Installing software
    – Install any additional browsers you may like.
    – Install Sublime-text by following the steps at
    – Install Python 2.7
    – Install Pithos for Pandora
        ~ Move files
        ~ sudo apt-get install python-gtk2
        ~ sudo apt-get install python-gst-1.0 <<- Maynot need
        ~ Installed stuff for gst. Try: sudo apt-get install python-gst0.10 gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly
        ~ Install eyeD3: install ver 0.7.4 using the guide: