Featured Post

Sidekick 3 now available but is it as good as the 8125 Windows Mobile

Remember 2002 in terms of what was available for Smart Phones? Not a whole lot to be honest. Palm was just starting to add phones to their PDA line up and about the only other phones available were Java based. I bought one of the first Sidekicks and used it for awhile. I loved the flip around keyboard...

Read More

Erlang – Hot Code Loading on Nodes For Dummies

Posted by Keith Elder | Posted in Erlang, XBOX 360 | Posted on 20-02-2014

Hot code loading across nodes in Erlang is a fantastic feature. After hearing about this feature it peaked my interest early on about Erlang and got me to dig in more.  But, I couldn’t get it to work because of my newbyness to Erlang! Hopefully this blog post will help others. 

Imagine You Are a .NET Windows Service

To understand how hot code loading in Erlang works let’s picture for a moment a Console application or Windows Service or Web Service deployed to three different machines. As an Engineer we need to do a simple fix and redeploy code. What do we have to do? Well we have to make our change locally then build the solution, run unit tests, etc. Now it is time to deploy our simple change. This is where things start diverging fast between Erlang and other technologies.  In .NET/Java we have to copy the entire library to each server and then cycle through stopping and starting each process on each server so the new code will get picked up. Whether this is Java or .NET doesn’t matter the same thing applies. Even if your language of choice is a dynamic language like PHP/Ruby/Python you still have to copy the file you changed to all servers. The server or process doesn’t have to be restarted in dynamic languages but you still have to copy the file(s) to the various servers either way. In Erlang we can simply connect to a node and then network load the new code across all nodes in the cluster! 

See this is the big difference. Erlang is distributed out of the box. It was built to be distributable and continue running, even during code pushes. Erlang was designed with the purpose in mind that a system had to keep running. Think about it for a second. What if the phone company said you couldn’t make a call between 9:00 PM and 1:00 PM on a Saturday night because of maintenance window? Yeah that wouldn’t go over very well. There are numerous reports of uptime in systems written in Erlang. Many fans of Erlang use the terms of 9 9’s (and there is even a company called Nine Nines) which his 99.9999999% uptime. If you do the math that is about 30 milliseconds of downtime a year. What? Yeah. That. 

Here’s a quick walk through on how to do this. I tried several times to get it to work and kept running into errors and getting errors so I’ll cover them so you won’t have to struggle at first as much as I did. Here we go.

Install Erlang 

I assume you wear big boy pants and know how to install software but here are a few quick ways to get Erlang installed and up and running. 
  • Mac – use brew and “brew install erlang”
  • Windows – Download Erlang from Erlang.Org
  • Debian Linux – sudo apt-get install erlang
  • CentOs Linux – sudo yum install erlang

Open a terminal / cmd prompt window after it is installed and type “erl”.

If you’ve gotten this far, good, you have Erlang installed. By the way to exit type “ctrl-g” and then “q” (for quit). 

Now let’s write a simple program that will add two numbers. 

Our Program – demo.erl

-module(demo).

-export([add/2]).

add(A, B) ->
   A + B.
Copy the above code into a file named demo.erl. Note: it has to be named demo.erl because the first line declares the module name as demo. This is based on a convention as the name of the module and file have to match. 
While Erlang is a dynamic language it is still compiled. To compile this from the cmd line type: “erlc demo.erl”. If there are no errors the command prompt should just return. If there are errors they will print to the screen. If you are typing by hand be sure each line ends with a dot (period). 
The above file isn’t magical, it simply adds to numbers. For those coming from a .NET/OOP background think of the export line as making the function add public. Since Erlang is a functional language there are no classes! This is a good thing as Erlang programs are a lot smaller than languages such as C++/.NET/Java. 

Setting Up Our Nodes

Because Erlang is distributed we can create multiple nodes and run our module demo across three nodes. Typically you’ll do this on completely different servers but because Erlang runs within a VM we can start three instances of the VM locally, connect them, and we have a distributed program. To do this open three terminal windows or command prompts. I’m using a Mac so I will be using tmux in iTerm2 for these examples. 
NOTE: BE SURE WHEN YOU RUN THE FOLLOWING COMMANDS YOUR demo.erl FILE IS IN THE DIRECTORY FOR THE FIRST NODE YOU START!
If you want to follow along with my screen shots be sure to install tmux (brew install tmux). I’ve created three cmd prompts inside of tmux and each one I’m going to run the following command to start an Erlang instance in each one:

erl -name {flintstonecharacter}@127.0.0.1 -setcookie dino

As you type each one in your command prompt change the name of the flint stone character. I’m using the following: fred (node1), bambam (node2), betty (node3). After doing so you should have three Erlang prompts that look like this if you are using tmux. 

So what did we just do? Well the -name gives each instance their name of course. The -setcookie option is super important as this is what really connects all three Erlang VM’s together. That cookie has to be named the same.

Running Our Code
Now that we have al three started let’s load our demo program into the top one and run it. 
To do that we are going to type the following:

c(demo). 

The result of running that command should be: {ok,demo}. That means our code was compiled. Again be sure the demo.erl is in the folder of the first Erlang shell when you launch it. To run it simply type:

demo:add(34,34343).

Press enter and you’ll get back those numbers added together. 
So far our other two instances know nothing about our demo module. But let’s clue them in so they can run it too! To do this we are going to ping the nodes so all three are communicating. In your first Erlang shell type: nodes(). This should return [] which means there are no other known nodes. Let’s add them though.
To do this we are going to type the following into the first instance (fred):

net_adm:ping(‘bambam@127.0.0.1’).
net_adm:ping(‘betty@127.0.0.1’).

Now type nodes(). and you should get back a list containing both bambam and betty. 

At this point all three are connected. We can now hot load some code for them all to run. Let’s push our demo.erl program to all of the nodes (this works if you have 3 or 30). To do this we are going to use the function nl() which means network load. Run this command in your node1 instance (mine is fred). 

Notice we get back “abcast”. Now we can go to the other nodes and run demo:add(4,5). and it works! We just hot loaded code to all the nodes in our cluster. 
If you aren’t sitting back in your chair right now scratching your head going *holy cow* you should be. This is amazing. Take it from me. To do this in other technologies would be mountains and mountains of work. Trust me, I’ve done it. 
In the case above we basically deployed new code to new instances. What if we want to change it will it is running? Basically the same thing is just as simple. Edit the demo.erl file and add the following line above the A + B. line. 

io:format(“Calculating like a boss!\n”).

This is the equivalent of doing “Console.WriteLine()” for those .NET folks. We can test this out on our first node by running c(demo). again. Run demo:add(1,2). in the shell and you should get something like this:

 

Great it worked. Now let’s push our change to all our nodes! Simple. Just re-run nl(demo). and then re-run a calculation on each node. Boom! Hot code loading. 

Hopefully this little walkthrough will give you some encouragement to look into Erlang. I left out a lot of details about how things worked intentionally as if I didn’t the article would be just too long. Thank for reading and more Erlang articles to come. 

Back in Mac, I typed in Bash

Posted by Keith Elder | Posted in Apple | Posted on 15-02-2014

Tags:

I was trying to think of a title for this post and the first lines to “Back in Black” by AC/DC kept popping in my head. I was going to try to write a witty pun or play on words on the lyrics to “Back in Black” but I couldn’t think of a word to rhyme with *ash for the second verse. However, the lyrics are somewhat fitting.

Back in black I hit the sack

I been too long I’m glad to be back

Yes I am

Let loose from the noose

That’s kept me hanging about

I keep looking at the sky cause it’s gettin’ me high

Forget the hearse cause I’ll never die

I got nine lives cat’s eyes

Using every one of them and runnin’ wild

Cause I’m back

What am I trying to say you wonder? Well, last week I switched back to using the forbidden fruit, a half-eaten fruit if you will, Apple. The sky isn’t falling for those that only know me as a long time Windows user and Microsoft MVP because I’ve owned a Mac since 2002. I’m not going to suddenly start writing IOS apps and get all hipster so don’t worry. I’m still going to be heavily involved in the .NET community so this isn’t a “I’m leaving .NET for {insert technology} post” because the last time I checked there are still millions and millions of Windows PCs that need software. It is just that I firmly believe a Mac (being Unix based) opens the polyglot programming language door more so than running a Windows PC. Let’s face it, most of the technologies being developed aren’t being built on Windows. They are mostly being built on Mac or Linux and run very consistent on both of those platforms with just a recompile. If you’ve ever tried to run PHP, Python, Ruby, Node etc on Windows you know what I’m talking about. These technologies aren’t native and while Microsoft has made some great strides (especially with Node in Azure recently) they don’t feel or act *native* and that’s important.

2014 is about a different journey for our team. It is a journey that I have been pondering since last fall and that is how to build fault tolerant highly distributable concurrent high availability systems. While .NET, Node, Java, PHP, Python, Ruby are all great I have a burning necessity to build a highly concurrent highly available distributable system (system being the keyword). After a lot of research, thought, discussions, reading, and playing all roads led us to look at Erlang. It isn’t a flashily super hot technology like Node but it is a super powerful platform to build robust systems with as other companies like Huffington Post, WhatsApp, Facebook, Heroku, and Zynga have figured out. 

I work with some amazing team members. Their open mindset and willingness to learn new things to solve our challenging problems in new and unique ways is what really makes this shift possible. As a matter of fact the whole team got Macs this week. While our team has always considered ourselves polyglots and prided ourselves on solving the right problem with the right tool we’re ramping up our polyglotness to DefCon 1 this year. 

Where this new journey leads I don’t know but I have a vision and a plan. It could be a bust or a genius move, time will tell. We’ll figure out the how as we go and I’ll gladly share the ups and downs with those that read this blog in the coming days, weeks, months. I hope to blog about what led us to this decision over time to look at Erlang in a very serious manner but in the mean time I challenge you to get uncomfortable and crazy with us and Learn You Some Erlang for Great Good

NYC Code Camp Saturday / MIGANG Wednesday

Posted by Keith Elder | Posted in .Net, Asp.Net, C#, Presentations, SignalR, Speaking | Posted on 13-09-2013

NYC Code Camp Saturday 9/13/2013 – Simplicity Is Genius

Saturday I will be attending my first New York City Code Camp (@codecampnyc ). I’m traveling thousands of miles to help you make you a better you. I’ll be doing the talk “Simplicity Is Genius”. Looking at the list of sessions this is the ONLY real Soft Skills session on the menu so I really encourage the New York faithful to attend. If you don’t come you are doing yourself a disservice. Putting technical content in the brain is great but you need to work on YOU some as well.

In this session we’ll take a break from code and focus on the other skills developers need called Soft Skills. We’re going to go deep on what "Simplicity is Genius" really means from the eyes of Forrest Gump and look at many of the life lessons Forrest was trying to teach us in the movie. After attending this session you will learn the value of providing value, how to better communicate with team members, the importance of being nice, and how to leverage techniques used successfully by salesmen backed by scientific research so you can ultimately… tell IT like Forrest Gump.

MIGANG Wednesday 9/18/2013 – Web Applications Re-Imagined for Today’s Demanding End Users

After CodeCampNYC I’ll be heading to Detroit to work onsite for the week. The timing works out so I can make the MIGANG on Wednesday night. I’m really looking forward to it and stressing at the same time as I’m giving a brand new talk entitled “Web Applications Re-Imagined for Today’s Demanding End Users”. If I can pull everything off I want this should be fun, enlightening, dangerous, scary, exhilarating all at the same time.

In this talk we are going to take an extreme departure from a typical three-tiered web application and look at how we can leverage asynchronous messaging, queues, and events in exciting ways.  We’ll be architecting a web application utilizing SignalR, TopShelf, Asp.Net, RabbitMQ, and ServiceStack to create a scalable, highly available, buzzword filled, real-time web application.  We’re going to look at how we’ll handle long running business processes that cross service boundaries using command queues and events to push notifications back to our end users. We’ll learn that we’ve actually made our application stronger, faster, and simpler to write (even transactional when we need it). In the end we’re going to try to break our application to find out if it is truly Engineered to Amaze.

If you are in the area I hope to see you at either event, don’t forget to say hi!

Surface Pro Running Four Screens– My New Personal Workstation

Posted by Keith Elder | Posted in Technology, Windows | Posted on 14-08-2013

No One Believes Me

The other day on Twitter I mentioned I had my Surface Pro running four screens (technically 5 if you count the screen of the Surface itself) and that it was my new workstation. Then I got this tweet from Eric:

 

image

I swear this is not Big Foot, it does exist so let’s get that done and out of the way.

The Proof

image

Tada! I will note this configuration isn’t new. As a matter of fact I’ve had this setup with four screens since 2009 as noted in this article that also discusses what is holding up the screens.

In the picture above you’ll notice one single cord plugged into the Surface in the USB 3.0 slot that runs in behind a speaker and into a Plugable USB 3.0 docking station. The docking station is the secret and provides all of the magic. What’s running on the Surface is TweetDeck (top left), Skype (top right), playing full screen Youtube video (bottom left) and Outlook 2013 (bottom right). The screen on the Surface is just showing the standard desktop.

UPDATE

FIrst of all thanks for the interests in this article. My Twitter feed @keithelder has been blowing up with questions all day. For the many of you asking about lag I recorded a quick video so you can see everything working live.

This should answer those questions about lag.

UPDATE 10:30 PM

I created another video. This time because there seems to be a lot of misinformation in people’s heads about the Surface in general and especially the Pro. Look folks, this thing is a full blown Windows PC. But it has a touch screen and is also a tablet. Someone wanted me to push it a little further than doing just one video. So here is a video of the Surface Pro streaming FOUR YouTube videos at the same time full screen while also downloading Visual Studio 2012, and running Tweet Deck, Outlook 2013, Skype, Chrome, IE, Live Writer and Adobe Audition. I think it was also washing dishes at the same time I can’t remember. The point is this little itty bitty device isn’t slow. It is a full blown PC packed into a tiny form factor so don’t let what you may have read in media previously fool you.

Four YouTube videos streamed over USB 3.0 Docking Station

Another thing I should point out is the performance rating of the Surface Pro. People keep asking me if it can run Visual Studio. The answer is yes yes yes yes. I just installed it. Don’t take my word for it though. Compare performance information with your existing development machines and see how you stack up against the Surface Pro. Don’t get me wrong, there are way faster computers out there. It just that not many people realize what this device is really capable of. I just can’t wait to see what they do with the Surface Pro 2!

SurfacePro-PerfIndex

UPDATE 8/15/2013 5:25 PM

More questions have come in as this story continues to spread.

@RockyLhotka asked this a bit ago:

Hey @keithelder does your multi-mon setup run Netflix? I found the DL drivers weren’t signed, so couldn’t play DRMed content?

Rocky is talking about the Display Link drivers that the hard you’ll read about below uses. To answer Rocky’s question the answer is Netflix works without a single problem. I ran Netflix in the browser and then installed the Netflix app from Windows Store and ran that. They both work without a problem. Matter of fact I was watching the Netflix video while playing Angry Birds Star Wars which is combining desktop apps while also running Windows Store apps at the same time. It is getting crazy!

The Setup

I know. Your mind is blown. Full screen Youtube playing with four screens all from one USB 3.0 cable!? Answer. Yes. And it also provides sound, mouse, keyboard and has a HD video cam plugged into it.

Here is a closer pic of the Plugable Docking Station:

image

The docking station is just one of the pieces to the puzzle. It has a DVI port in the back of it so one of the screens is plugged directly into the DVI port. That leaves three other screens to go. For that piece of the puzzle all we need is a converter to go from DVI or VGA to USB 3.0. Just so happens Plugable also has the answer to this as well with their UGA-3000 product.

UPDATE 8/16/2013 4:53 PM

@Plugable just as of a few minutes ago drop a brand new docking station, the 3900 model that supports dual monitor support with one DVI and one HDMI. If you are going to get one, this may serve you better than the one I have.

http://plugable.com/2013/08/16/new-plugable-usb-3-0-universal-docking-station-with-dual-monitor-support 

Note the new unit is regular $129 but if you use Amazon promotion code 63P25IGM at checkout it is only $109!

The USB 3.0 UGA adapter will work with anything you have. It works with VGA, DVI and HDMI and includes the adapters in the box. They even support resolutions up to 2048×1152 (which I’m no where close to).

There are two USB 3.0 ports on the front of the docking station so I plugged the other big screen on the bottom plus one of the screens up top into the front USB 3.0 ports. That leaves one of the smaller screens plugged into a USB 2.0 port in the back. I thought I may notice a difference in the screens up top since one was plugged into USB 2.0 but honestly I can’t tell you which screen is plugged into which. To my eye there is no difference.

Let’s recap. To make this work get a Plugable USB 3.0 Docking Station for $99 (or something similar). Then pickup as many UGA-3000 adapters as you need. All total you’ll be in for about $250 if you have four screens which is the cost of a typical docking station.

Side Benefits

A side benefit has come out of my efforts to get multiple screens working with the Surface Pro and that is my Dell notebook I found out has USB 3.0 on it. While I had a Dell docking station for it running two screens, I think we all agree that four is better than two! I’m now using the Plugable Docking Station on the Dell at work which gives me four screens to work with as well. A whole new level of productivity at work has opened up.

Switching between the Dell and the Surface is dead simple. There is only one cable to plug / unplug. Everything runs off of the one USB 3.0 cable. Let me just go ahead and say this: USB 3.0…. I love you.

So Long Gigantic Desktop

In the article I mentioned at the beginning I stated my four screen setup isn’t new. In that article is the picture below of a custom gigantic desktop sitting besides the four screens.

That desktop now sits below the desk collecting dust. As a matter of fact I’m loaning it out to a buddy of mine who’s computer died. I’d rather it get used than sit in my floor. It is still a great machine but it doesn’t travel very well. The Surface Pro has plenty of power in all honesty to do anything I really need at the moment.

I blogged after Windows 8 was announced in September 2011 about the up and coming hardware revolution and how Windows 8 was a transformer OS. The Surface Pro is just the tip of the iceberg and I don’t see me buying a desktop ever again. If I can’t take whatever I buy with me it is useless in today’s world as far as I’m concerned.

I can’t predict the future but I assure you the Surface Pro isn’t going to last forever as my workstation as I’m just waiting on the new line of Ultrabooks to come out with better battery life and slimmer design. Whatever I wind up with will have USB 3.0 and it will be running these four screens. Being able to just unplug and go is super powerful. Moving from workstation to tablet with touch and then back is great. So far I’m enjoying the ride.

The next time you are looking for a new machine don’t leave Ultrabooks or the Surface Pro off your list. As long as it has USB 3.0 you’ve got something that can transform into a workstation and then to a tablet. Best of both worlds in my opinion and Windows 8.1 plus the new line of Intel processors is going to make it even better.

So long gigantic desktop… you’ve served me well.

Speaking at SQL Saturday #234 Baton Rouge August 3rd

Posted by Keith Elder | Posted in .Net, C#, Speaking | Posted on 30-07-2013

Prepare the crawdads and gumbo because I’ll be in Baton Rouge, LA this coming Saturday doing some talks at the SQL Saturday #234 event!

I’m planning on doing two talks Saturday as well as recording some http://deepfriedbytes.com episodes if time willing.

Here’s the talks I’ll be giving and more about them.

Channeling Your Inner Forrest Gump – Simplicity is Genius

In this session we’ll take a break from code and focus on the other skills developers need called Soft Skills. We’re going to go deep on what "Simplicity is Genius" really means from the eyes of Forrest Gump and look at many of the life lessons Forrest was trying to teach us in the movie. After attending this session you will learn how to better communicate with team members, provide value not only to your business but also your profession, the importance of being nice, and how to leverage techniques used successfully by salesmen backed by scientific research so you can ultimately… tell IT like Forrest Gump.

That’s right, I’m bringing the GUMP to Baton Rouge. No prerequisite required to attend this talk and you don’t even have to be a developer! I gave this talk at DevLink a few years ago as the keynote and I’ve given in another time or two in smaller settings and each and every time I give it it hits home with many in the audience. You don’t want to miss this one I promise.

Building an English-Based Rules Engine using the Dynamic Language Runtime and IronRuby

In this session we will explore writing an English-based rules engine that allows developers to create domain-specific rules for an application that can be easily understood by anyone. We will use a combination of C# and the DLR (dynamic language runtime) with IronRuby on the .NET platform to create a way to write, manage, and process rules for an application.

If you’ve ever wanted a simple way to store and process business rules whereby you can still read them come to this talk. It is geeky, it is fun and practical. We’ve already created four different interfaces to this at work and are using it in production (with some enhancements of course) so it isn’t just theory.

Hope to see you there and feel free to follow http://twitter.com/sqlsatbr via Twitter.