11/17/2014 @ 20:52 (about 1 month ago)

Open All Merge Conflicts in vim

I came across this handy trick in a chat room, and thought I would share because it's quick and subtle:

git diff --name-only | uniq | xargs vim

End of line.

commentsread more→
09/25/2014 @ 14:34 (3 months ago)

Shell Shock

So there is a pretty nasty bug in BASH right now. Some of the code responsible for loading environment variables processes trailing strings (strings that could be executable code). You can check if you're machine is vulnerable with this little script

env X="() { :;} ; echo better patch" /bin/sh -c "echo stuff"

If you see "better patch" you should upgrade your bash version. Most modern version of Ubuntu will not have this problem since they actually use dash, but still check.

commentsread more→
06/20/2014 @ 14:42 (6 months ago)

Protect your images in the UI (x-post from isotope11.com/blog)

I decided to cross-post this from my blog page over @ isotope11.com. It is what it is... You can try it some time!

This may seem trivial, but over the years of web development, I've been requested more than three times to make it so that images cannot be saved through the UI of a client's web page. I've seen different approaches to this, but I think the most effortless and yet most effective approach relies purley on UI events.

The Important UI Events

  • onMouseDown - Can be use to prevent users from right clicking to save image

  • onMouseMove - Can be used to prevent users from dragging an image to their HDD

  • onContextMenu - Can be use to prevent the context menu from showing that has the "Save image as..."


Click here to fiddle!


<img src="http://i.imgur.com/fNJSyq2.gif" 
  alt="Try to save me!" 
  onmousemove="return false;" 
  onmousedown="return false;" 
  oncontextmenu="return false;" 

Rails Helper:

<%= image_tag "http://i.imgur.com/fNJSyq2.gif", {onmousemove: "return false;", onmousedown: "return false;", oncontextmenu: "return false;"} %>

End of line.

commentsread more→
01/31/2014 @ 16:55 (11 months ago)

Fixing Stubborn JavaDoc Error

I've recently started taking a class at the university on Java. (Yuk!) And I've been running into some problems getting my JavaDocs to generate in NetBeans. The error message I get says:

No source files and no packages have been specified.

If you look in nbproject/build-impl.xml file, you'll find some XML and a node containing information on javadoc which by default looks something like this:

You can replace this node with the following node to generate your JavaDocs:

Hope this helps someone!

commentsread more→
12/27/2013 @ 21:58 (12 months ago)

Orbital Mechanics - Part 1

I'm in the process of writing a new RubyGem. The Gem was inspired by a post I made on Isotope11's Blog. At the time I wrote the inspiring blog post, the news of the huge meteor that exploded above Russia this year was just announced. I was searching for something to write a blog post on for Isotope11's Blog. I decided to code some stuff I learned from physics to calculate trajectories of projectiles.

Source Code From Inspiring Blog Post:

It was pointed out in the comments that the algorithms I implemented in Ruby are less related to meteors hitting Russia. For meteors hitting a celestial body, orbital mechanics algorithms are more related.

Introducing Orbital Mechanics

Orbital Mechanics is a RubyGem that is currently in development at the time of this writing. It aims to provide a nice clean Ruby library for solving common problems encountered in astrodynamics, ballistics, and celestial mechanics.

Circular Orbits

It's all explained in the tests and code comments. What I've implemented so far in the Gem are presented in the following files lib/orbital_mechanics/circular.rb and spec/lib/orbital_mechanics/circular_spec.rb, respectively.

This is all I really have to share today. Once I have more free time I will do a write up on part 2 which could include more stuff on circular orbits or new stuff on elliptical orbits.

commentsread more→
12/26/2013 @ 21:31 (12 months ago)

Styling Changes

I've given up on trying to make crazy fonts a thing for my blog. I've found that it just scares readers away more than it intrigues them. Therefore I present you readers (or lack thereof) with some soothing gray colors, smoother, and less annoying fonts.

The main font on the site is a Google Font called Droid Sans.

To include it on your web-page add the following in the header tag:

<link href="http://fonts.googleapis.com/css?family=Droid+Sans" media="all" rel="stylesheet" />

To apply it on your web-page add the following into your CSS:

body {
  font-family: 'Droid Sans', sans-serif;

I also want to point out that my social icons at the top of the page are now invisible. No this is not a new feature, but a bug with either foundation, the foundation-icons-sass-rails ruby gem, or my CSS. I didn't spend a horrible amount of time on the problem, but enough to make me move on with what I was doing. Hopefully ZURB Foundation will fix it or something.

Enjoy the Changes!

commentsread more→
12/20/2013 @ 3:47 (about 1 year ago)

Download Youtube Videos From Your Terminal

Install the binary:

sudo apt-get install youtube-dl


$ youtube-dl <YOUTUBE-URL>

That is all.

commentsread more→
12/12/2013 @ 14:59 (about 1 year ago)

Happy Holidays!

So if you're feeling the holiday spirit running through you, there are tons of open source projects that need your help! There's a thing going around this season called "24 Pull Request". It's a play on the 24 days leading up to Christmas, so be nice and help Open Source for the Holidays!

commentsread more→
10/05/2013 @ 3:08 (about 1 year ago)

Why It's Not Hard To Solve Differential Equations

What I have noticed is that students starting out in math, physics, or engineering are usually scared of differential equations. I know I was when I was starting my engineering courses. The trick with differential equations is that the complexity is all in your head. Just because you see some squigglies and squagglies and a bunch of math and so on you say, "Oh, that must be hard." Differential equations are actually the simplest thing there is because in a large majority of cases the way you solve them is you assume you know the answer. So someone tells you the answer and then all you are left to do is shove the answer into the equation and find out the constants that make it the answer. It's just a matter of psych. You should psych yourself that differential equations are easy because you're given the solution! You just have to plug it into the equation and verify.

commentsread more→
09/18/2013 @ 14:48 (over 1 year ago)

Quick Script To Get A Ubuntu Machine Up And Running For Ruby Development (v1.0.2)

I've got another minor release ready for everyone using Ubuntu 13.10. Read more about the details in my original post.


Remember to always read the contents of a script before running it like this:

    wget -q -O - http://goo.gl/8cgGYg | bash

Source Code

commentsread more→
08/19/2013 @ 15:53 (over 1 year ago)

Elixir Sips!

A person I know (Josh Adams) has created a website to help you learn Elixir. If you're interested in learning the language, I can guarantee this guy knows what he's talking about when it comes to programming.

Check out: elixirsips.com

commentsread more→
08/12/2013 @ 13:35 (over 1 year ago)

Rails Controller: Using head To Build Header-Only Responses

In your rails controller, you can use the head method to build header-only responses. This could be useful when you want to hit a controller action using AJAX from the UI.

Here's a quick example:


def create_dirty_user
  user = User.new(email: params[:email])
  if user.save(validate: false)
    head :created and return
    head :internal_server_error and return


function createDirtyUser() {
  var email = $("#email-input").val();
    url: '/users/create_dirty_user',
    data: "email=" + email,
    type: "POST",
    success: function(data) {
      return true;
    failure: function() {
      return false;

Click here for a reference list of different status symbols you can use.

commentsread more→
07/29/2013 @ 14:56 (over 1 year ago)

Uncle Bob's Clean Code/Tests

If you haven't checked out code casts before, you totally should checkout Uncle Bob's Clean Tests episode.

This episode will cover:

  • the anatomy of a test
  • the problem that setup functions can grow to become unmanageable
  • how hierarchical tests are natural in Ruby using Rspec
  • how to implement hierarchical tests in C# and Java
  • how to create truly clean and readable tests by using the technique of test composition

So go checkout Clean Tests.

commentsread more→
07/25/2013 @ 22:54 (over 1 year ago)

How to view the technologies behind any website...

It's actually really easy. There is a service called build with. It provides a comprehensive listing of the exposed technologies used to build a website. Just follow this synopsis:


where domain.name is the targeted website.

This website, for example, would be:



commentsread more→
07/24/2013 @ 19:04 (over 1 year ago)

The Start-Up Trap

I just read an amazing article by Uncle Bob Martin regarding start-ups and young programmers. In my opinion, the best advice for start-ups and young programmers is what he describes in his article; discipline. Disciplining yourself to write tests before you start writing code for example. It's so important that you follow your disciplines in programming from the start or you're going to fall into so many maintenance nightmares.

There, now I've added my unremarkable prerogative, so go read The Start-Up Trap.

commentsread more→
07/24/2013 @ 4:30 (over 1 year ago)

Changing Column Type in PostgreSQL && Rails

On Heroku I had a project returning the following error:

2013-07-24T04:03:20Z app[postgres.16315]: [NAVY] value too long for type character varying(255)
Query: INSERT INTO "some_records" ("some") VALUES ($1) RETURNING "id"

It's of course obvious that our primary key on the some_records table has grown too fat for its own data column...

I was not too happy with my search results on Google regarding this issue. I needed to just alter the table, and I didn't find any search results that did just that. Most were pointing out to do the following:

class CreateSomeRecords < ActiveRecord::Migration
  def self.up
    create_table :some_records, :id => false do |t|
      t.integer :id, :limit => 8

You could see that this is starting from scratch...

My quick and dirty solution:


It doesn't feel good to do it this way, but it does exactly what I want it to. It's also a good idea to change the migration to match the example above when starting from scratch so this kind of thing doesn't happen again.

The Rails Way:

rails g migration change_column_of_primary_key_for_some_records

Then your migration should look like this

class ChangeColumnOfPrimaryKeyForSomeRecords < ActiveRecord::Migration
  def change
    change_column :some_records, :id, :integer, :limit => 8
commentsread more→
07/23/2013 @ 15:40 (over 1 year ago)

Clean Ruby

If you're beginning Ruby and want to focus on writing good clean Ruby code, then I would recommend the book Clean Ruby. The book will teach you how to write Ruby code that is clear on its intent which in turn makes your project more manageable as time goes on.

Checking out the SOLID design principles by Uncle Bob will also change the way your day of programming goes. Your code will be tight and manageable.

That is all.

commentsread more→
07/22/2013 @ 22:43 (over 1 year ago)

Ubuntu Edge

The folks at Ubuntu are raising money for their latest project, The Ubuntu Edge. The Ubuntu Edge is the next generation of personal computing: smartphone and desktop PC in one state-of-the-art device. Their goal is $32,000,000, and they have already raised $1,881,642 at the time of this post. I think any little bit of money is for a good cause. I can't wait to see where they go next.

commentsread more→
07/19/2013 @ 19:31 (over 1 year ago)

Starting From Scratch with Rails 4.0 and Ruby 2.0 (x-post from isotope11.com)

This is a repost here from something I wrote for the blog at work. Here's the original.

Getting a website going from scratch with Rails 4.0 and Ruby 2.0 can be done in a day; including getting it deployed to Heroku! Don't believe me? Let's just do it.


First you'll need to install RVM:

curl -L https://get.rvm.io | bash -s stable

Install Rails 4.0

gem install rails -v "4.0.0"

Building a Website

For example purposes let's just get a blog and users. To get this going I will use a nice little tool called RailsWizard.

Items choosen from RailsWizard:

Now let's run the generated script:

rails new SampleApp -m http://railswizard.org/0cfe7ed4fdea698dc4e3.rb -T

From here you'll be guided in setting up the database you want to use with ActiveRecord and creating your Heroku server,

Making a Blog

Change into your project's root directory and run the following:

rails g scaffold Post title:string body:text

Run the migrations:

rake db:migrate

We now have the core part of the website complete! But let's not stop here; let's make our URLs a little nicer with friendly_id.

Add the following to your Gemfile:

gem 'friendly_id', github: 'FriendlyId/friendly_id', branch: 'rails4'

Add an index to the slug column on the posts table:

rails g migration add_index_on_slug_to_posts slug:string:index

Run the migrations:

rake db:migrate

Now make your Post model look like this:

class Post < ActiveRecord::Base
  extend ::FriendlyId
  friendly_id :title, use: :slugged

  validates :title, uniqueness: true
  validates :body, presence: true

Let's push it live!

git add .
git commit -m "Adds a blog"
git push heroku master

That's it?

It's kind of hard to believe isn't it?

commentsread more→
07/18/2013 @ 19:21 (over 1 year ago)

It's about time...

I've finally got this website thing going. I'll update it when I have the time. If you're interested in contract work, please check out my GitHub. Feel free to shoot me an email!

commentsread more→