Notes on Working with Ubuntu in VirtualBox

Note: This content may be moving. If you have bookmarked it, please update your record to point to http://vdir.us/go/ubuntu-git-vbox.

I have been working with Ubuntu in VirtualBox for a week or two now. At first it was merely an exercise in learning Java, Eclipse and Git but it turns out that with Mono, Linux gets a lot more attractive. More on this later, though! Here are a few notes that I have compiled that would be helpful to those running Ubuntu inside a VirtualBox virtual machine (primarily on a Windows host).

Networking, SSH

If you plan on using Ubuntu as a server of any kind, I suggest using the Bridged network adapter so that the VM looks like a regular PC on the network. Otherwise you will end up fudging with the port forwarding in VBox and inevitably failing (perhaps that is just me). Here is how I set up my Ubuntu VM to enable SSH.

  1. With the VM off, open the Networking settings in VBox…
  2. Use Bridged Networking, and the AMD PCNet Fast III adapter. See Chapter 06 of the VBox manual for more info.
  3. Boot the VM, log on
  4. Run sudo gedit /etc/network/interfaces. Your file should look like the following. Change your address and gateway IP’s to represent your personal network’s specifics.
    auto lo
    iface lo inet loopback
    address 127.0.0.1
    netmask 255.0.0.0
    
    auto eth0
    iface eth0 inet static
    address 192.168.1.118
    netmask 255.255.255.0
    gateway 192.168.1.1
  5. Run sudo gedit /etc/resolv.conf to edit your nameservers. Mine has a single entry: the router.
  6. Edit your hosts file to add your computer to the IP address. Run sudo nano -w /etc/hosts. I commented out the automatic one and added my own.
    # 10.0.2.15  JSUbuntu-Virtual # Added by Network Manager
    192.168.1.118   JSUbuntu-Virtual
  7. Run sudo /etc/init.d/networking restart to apply your changes.
  8. Run ifconfig to see your changes.
  9. Check that your configuration works by browsing to a site.
  10. Now to install SSH, run sudo apt-get install ssh. Note that you may have to run a sudo apt-get update to update the available packages.
  11. If you have a firewall enabled, configure port 22 to be open. This is the default SSH port.
  12. If you want it to be public, enable port forwarding on your physical/network router for port 22 and your Ubuntu’s IP.
  13. On your host machine, download PuTTY
  14. Run PuTTY, enter IP, smash the enter key.
  15. Enter your credentials!

Next I will show you how to get up and running with git.

Continue reading

Custom Wrap Macro for Visual Studio

This content may be moving. Please update your bookmark to http://vdir.us/go/vs-wrap-macro.

As an update to my last post, Using VS Macros to Speed Up Text Entry, here is a block of code that allows you to enter any string as the HTML/XML node name that wraps the current selection. Note that you’ll need to setup the Constants class to hold the shared variable.

Public Class Constants
    Public Shared CustomDefaultValue As String = "p"
End Class

Public Module BasicMacros
    Public Sub WrapInCustom()
        ' Get the input
        Dim str As String = InputBox("Wrap the selection in what?", "Wrap in Custom", Constants.CustomDefaultValue)

        ' Empty string == cancel!
        If (String.IsNullOrWhiteSpace(str)) Then Return

        ' Store the value so that it is easy to repeat
        Constants.CustomDefaultValue = str

        ' Get the current selection
        Dim ts As TextSelection = CType(DTE.ActiveDocument.Selection, TextSelection)

        ' Add the value
        ts.Text = "<" + str + ">" + ts.Text + ""
    End Sub
End Module

Using VS Macros To Speed Up Text Entry

Often times my position requires me to enter fairly large sets of copy into the websites I am developing. These pieces can be anything from press releases to taglines and product information. Regardless of their content, I am always left doing one thing over and over: adding HTML tags. After hours of repeating this task, my hands get cranky – very cranky. Naturally I went looking for a programmatic solution, and found one in using Visual Studio Macros!

For now, here is a quick snapshot to get you started. The below code allows me to quickly add paragraph tags to the current selection in a VS2010 editor/window. To develop a Macro, simply go into the Tools -> Macros -> Macro IDE and open up the code file.

Public Sub WrapInParagraph()
    DTE.ActiveDocument.Selection.Text = "

" + DTE.ActiveDocument.Selection.Text + "

"
End Sub

After building the project, hop back into VS2010 and select Options under the Tools menu. You can now search for your command in the Environment -> Keyboard panel and assign it a shortcut.

On Setting Personal Records

Stagnation is one of my greatest fears; the feeling that I am not learning anything or not making gains in performance ranks above fear of death and public speaking. As such, it should be of no surprise that setting and tracking personal records is important to mark my improvements. With my weight loss, I have a big excel file that lists my weight for the past five hundred or so days. With my personal records on specific courses I am a bit more loose, but they are on my mind as I ride through them, regardless of whether or not I am having a go.

Last week, on 26 August 2010 I left the house on what would turn out to be an awesome ride. At the time, of course, I didn’t really know what pace I was going to keep – I just needed to relieve some stress and energy built up from work. At my first main road I made the turn as a truck was coming my direction and was able to slip into the gigantic draft and go ~38 for roughly one mile. It was awesome to say the least, but I eventually had to make a turn and was forced to back off.

Continue reading

Korkboard 1.1.0.0

Korkboard has been updated to version 1.1.0.0 after a couple changes and fixes. If you have already installed Korkboard, it will check for the update next time you run it. It will install the update the next (next) time it is run. If you do not have Korkboard, you can download it for free!

Korkboard v1.1.0.0 (4092)

Here is a full list of the changes made since 1.0.0.4:

  • Added drag and drop sorting.
  • Added item pinning (will stay at the top).
  • Added settings for turning off (and on) certain data formats.
  • Added a “Clear Korkboard” button to clear all non-pinned and unselected items from the list
  • Fixed current item selection for when items are selected outside the application
  • Fixed text alignment issues in the settings page

I have also changed the download to point to the ClickOnce EXE file instead of the Application file. This should fix any issues with non-IE browsers. Thanks to Long Zheng and MetroTwit for this idea.

Korkboard 1.0.0.4

Korkboard Screenshot

Korkboard is a little tool I have been developing that enables a uniform method of storing multiple items on the clipboard. When Korkboard runs, it hooks into the clipboard chain and attempts to intercept messages as you use the Copy and Cut commands. It then stores the items on its own list so that they may be retrieved at a later time. It is important to note that Korkboard does not mess with the functionality of the clipboard. If you copy an item, the clipboard works as expected without any interruption or user required interception. Check it out, and let me know what you think!

Korkboard is written in WPF/.NET4 and uses ClickOnce to manage the installation and update processes.

Update: Added the Zip file for those having trouble using the ClickOnce method.

Cache Problems with ASP.NET MVC Views?

If you have done any decent amount of work with the ASP.NET MVC platform, you have probably run into the following problem. You have a page where you want to update data on the server without a postback and so you whip out some fancy Javascript to send a request to the server. What happens is the response you get back is a success, and the data is updated, but subsequent requests don’t seem to be updated. This is most noticeable with partial views and content views called via the infamous “$.ajax” call. What you forgot was to make sure the browser isn’t caching the result:

HttpContext.Response.AddHeader("cache-control", "no-cache");

Note that if you have already hit the particular view and it is cached, you can generally clear the cache by navigating to the URI of the view manually and hitting refresh.

Running Settlers 7 in Windowed Mode

Just a quick post here regarding Settlers 7 and windowed mode. Although the in game UI doesn’t say the game supports running the game in a window, you can be changing your settings file. You can find the file in the Settlers7 folder under the “My Documents” folder. Open the “Options.ini” file and change the following.

[Quality]
FullScreen = 0
ScreenHeight = 960
ScreenWidth = 1280

Now, if only someone could tell me why the game still thinks DoF is on when the options file reads it as being set to zero! Happy settling.

Continue reading

FGF 0.1.2.0 Released with Gesture Recognition

New to the input engine within the Focused Games Framework is the gesture recognition capabilities, housed in the GestureTracker class. The gesture recognition class currently supports a small subset of the gestures I plan on supporting, but all are useful none-the-less. The included gestures are press, two fingered press, swipe, two fingered swipe, zoom and pinch. To use the gesture recognition, instantiate a GestureTracker object, add it to the IGame.Modules list and then listen to its GestureTracked even. You will also need an instance of the InputManager class added to the list of modules.

The following is a small sample taken from one of my games that handles some simple menu swiping (a full sample is on the way).

If you do happen to use FGF, I would love to hear what you think! Drop me a line via the Contact form or leave a comment here.

private void OnGestureTracked(object sender, GestureArgs args)
{
    // If it wasn't a swipe, we don't care!
    if (args.Gesture != Gesture.Swipe) return;

    // Get the direction of the swipe to determine what way
    // the menus should move
    if (args.Direction.X < 0)
    {
        // If we are capped at the right side of the menus, return
        if (current == menus.Length - 1) return;

        // Transition the menus
        menus[current].Transition(Menu.MoveDir.OffToLeft);

        current++;

        menus[current].Transition(Menu.MoveDir.OnFromRight);
    }
    else
    {
        if (current == 0) return;

        menus[current].Transition(Menu.MoveDir.OffToRight);

        current--;

        menus[current].Transition(Menu.MoveDir.OnFromLeft);
    }
}

 Download FGF 0.1.2.0 Bin

Continue reading

That’s Twitterific!

Are you new to Twitter? Are you looking for some interesting people to follow? What follows is an introduction to who you should be following on Twitter. It is by no means a complete compilation of who I think is important but rather the beginning.

  • XNA MVP List

    This is a compiled list of the XNA MVPs known to be twittering. If you are interested in XNA, you should be following these guys!

  • Michael Klucher

    Speaking of Klucher, he is the Lead Program Manager of the XNA Development Platform at Microsoft. Follow him for an interesting view of the daily life of a Microsoftie.

  • Paul Thurrott

    Best known for his website, Paul offers a fantastic viewpoint on the industry and is constantly on top of the latest products coming out of Redmond.

  • Bill Gates

    Gates is finally twittering! Follow him to stay up to date on his work and travels related to the Bill & Melinda Gates Foundation.

  • Shawn Hargreaves

    Shawn, famous for his cat based tutorials has one of the best XNA blogs out there. If you are an XNA developer and don’t know him, you’re living under a rock.

  • Sgt. Conker

    Keeping up to date on all things XNA can be a daunting task some times. Thankfully Sgt. Conker has got you covered! Follow these guys for the latest news, articles, videos and releases.

  • Ska Studios

    Dishwasher. Charlie Murder. GAME WITH ZOMBIES. What else needs to be said? The leader in XNA game development. Follow for news not just about their latest creation but gatos as well.