Category Tutorials

Getting Started With Git and TortoiseGit on Windows

Version control is essential to the success of any software project. It provides the ability for multiple developers to work on the same codebase simultaneously and allows projects to be versioned for release. However, a great deal of programmers fail to leverage the great benefits of version control for their personal projects, typically due to laziness or complacency (myself included).

Luckily, for us lazy programmers, Git and TortoiseGit are extremely easy to install and configure on Windows. Now, there’s no…

OSGi Development with Knopflerfish – Part 3: The Execution

Now that the hard parts are finished, all that’s left is to run our bundle in the Knopflerfish Desktop.

Click File -> Open Bundle File (Ctrl+O) and select the bundle we created in Part 2 (the default is:
/out). Note, the bundle .jar file gets built automatically through Eclipse.

Once the bundle has been loaded into the Knopflerfish OSGi Desktop simply hit the Start Bundle button and watch it go!

And that’s it! You have just created your very first OSGi bundle using Eclipse and Knopflerfish.…

OSGi Development with Knopflerfish – Part 2: The Code

Now that we have Eclipse and Knopflerfish installed let’s get into some code. This OSGi bundle will roll a random six-sided die every second and print the result to the Knopflerfish Desktop console.

Creating the RandomRoll Project

Click File -> New Project and select OSGi Bundle

Fill in the project information, I am going to call this project RandomRoll.

This is the OSGi specific information, make sure you check the “Create Activator” class box (More on this later.)

bundle.manifest

The manifest file contains all of the OSGi required…

OSGi Development with Knopflerfish – Part 1: The Setup

The OSGi framework allows Java developers to create a dynamic component model for their applications. Developers create “bundles” that can be deployed and executed remotely and provide distributed services. The OSGi Framework can act as a Install New Software
Next, click the “Add” button and add the Knopflerfish update site: http://www.knopflerfish.org/eclipse-update/

Once the update site has been added, you should automatically see an option for the Knopflerfish plugin. Check the box and hit “Next” to install. Read the license terms and complete the…

An Introduction to Ruby [Part 7 - File I/O]

You can already read and write to the screen (gets/puts) now it’s time to learn how to read and write to a file, so you can persist important data past a single execution of your Ruby script.

I set up a file called test.txt in the same directory as my ruby script, let’s see what it says, and then add some more information to the file.

Opening and Closing Files

First we need to learn how to open and close a file. Remember…

An Introduction to Ruby [Part 6 - Getting Closure]

Closures allow you to pass around functions or create new functions in your program.

calculate_tip = lambda { |bill_total, tip_percentage| bill_total/tip_percentage }
tip = calculate_tip.call(30.0, 10.0)
puts "You should leave $#{tip}"

Blocks were created to provide loop abstraction. That is, you can create a block and use it to iterate over a set of items.

awesome_shows= ["Doctor Who", "Lost", "The Office"]  

awesome_shows.each do |show|
    puts show
end

This is part 6 of An Introduction to Ruby.

An Introduction to Ruby [Part 1 – What is…

An Introduction to Ruby [Part 5 - Essential Classes]

I thought it would be a good idea to map out some of the more commonly used classes in Ruby. This way, if you do decide you like Ruby, you can hit the ground running.

Arrays

Arrays were discussed briefly way back in Part 2 of this tutorial, but I thought it would be a good idea to include more details now that we have more knowledge of Ruby.

Arrays store collections of data. You can dynamically access any element of an array by…

An Introduction to Ruby [Part 4 - Adding Some Class]

Now is a great time to dive into some basic Object Oriented Programming principles in Ruby.

This is the anatomy of a Ruby class. Remember, a class is simply an abstract definition. The concrete implementation of a class is called an object. Objects are what get used, stored, and passed around your program. For example, my class might be a Person but my object’s name is Robert (lame, I know, but hopefully you get the point.)

class Student

    #instance variables
    @name…

An Introduction to Ruby [Part 3 - Program Control]

Control structures are what gives your application its intelligence. Without the ability to make decisions a program would be effectively useless. Each of the following sections contains straightforward self-sustaining code that demonstrates the desired control structure.

if/else if/else

The if/else control structure was demonstrated briefly in Part 3 of this tutorial when a more user-readable letter grade needed to be determined from a numerical GPA value.

Here is the most simple case, an if statement by itself.

name = ""

#the condition in the if…

An Introduction to Ruby [Part 2 - Back to Basics]

I’ll be using irb for this tutorial to show as much detail as possible on what is going on behind the scenes. You can run irb by opening up a shell (command prompt) and type “irb” after Ruby is installed. irb> denotes user input and => denotes system output.

First off, it is important to note that everything in Ruby is an object. This means you can call methods on anything.

irb> -11.abs
=> 11

Variables

A variable holds data (specifically, for Ruby, it holds an object.)

irb> name =…