Tools of the Trade

Introduction

This post points to a few outstanding tools for developers. It’s a short list of things that I’ve found really helpful as I’ve tried to teach myself to code. Obviously any resource is helpful, but right now these are some of the most popular and widely-used resources. You’ll get more deeply embedded into the culture more quickly by getting familiar with these tools early. As I’m a .NET developer above all else at the moment, these tools skew that direction.

Scope of Application

This applies to anyone looking to learn to code who has access to online resources. As of April 2014, most of this was pretty hot stuff and on the list of what the cool kids are using.

Stackexchange

As far as I know, this is the #1 place for Q&A information for programmers online. Stackexchange is an umbrella Q&A site that includes a long list of sites divided into general categories. It’s the coolest forum-like technology that I’ve seen. Specifically, you want an account on Stackoverflow.com. But Stackexchange users are protective of the site’s format and rules. Stackoverflow isn’t the right place for all questions. You might also want to link an account to Superuser.com, for example.

Generally, the community there is incredibly helpful. It’s mostly other developers hanging out, both asking and answering questions. Like any other online forum, it has its abrasive users, so if you “break a rule,” you might get bullied around just a tad. However, as long as you ask articulate questions and show yourself making an effort, you’ll be fine. And once you get a few tricks under your belt, you’ll also be able to answer other people’s questions. It feels good both because you’re giving back and because then you know you’re smarter than you were when you were asking the same question.

GitHub

To really understand GitHub, you have to learn a little bit about version control and open source. This article by James Bruce provides a pretty good overview. But to give you the elevator pitch – GitHub is a place and a way to store and share your code. Just as importantly, it’s a place to browse through tons of open source code.

(If you don’t know what open source is, I would describe it as code that anyone is allowed to download and read. Programs and services that run on open source code are not necessarily free, though the majority are. The opposite of open source is proprietary code, which is code that is only distributed in encrypted or compiled formats and isn’t intended to be read by humans. A good example is Microsoft Windows. The code used to build the Windows OS is proprietary and not freely distributed. However, many flavors of the Linux operating system are open source and can be reviewed by anyone who is interested in taking a look.)

Even if you don’t have any code to share yet or don’t feel quite ready to contribute to an open source project, this is a great place to dig into cool programs and libraries and start learning how they work.

GitHub does offer private hosting for a fee, but with a free account, you can host unlimited open source projects.

Gist

GitHub hosts a Pastebin service called Gist, as well. There’s not a huge difference between the overall concept of GitHub and Gist, but Gist has a more narrow scope. You use it to post single text files rather than entire projects or groups of files.

Visual Studio Express

I haven’t included a lot of actual downloads here, but I think this one is important. I started learning to code on a Windows machine and was tasked early on with developing solutions in a Windows environment. Visual Studio isn’t the only way to do that, but it’s the most powerful and the most convenient. When I first looked at the sticker price on Visual Studio, though, (and before I realized that most companies will purchase it for you if they expect you to use it (What can I say? I’m a dummy)), I was pretty intimidated. It’s an expensive tool. But Visual Studio Express is a free version that offers more than enough functionality for beginners. There are similar tools out there for programming to other environments, but I just wanted to point out for the total noobs that you can get your hands on Visual Studio and start using it now for $0.

Nuget

Nuget is a plug-in for Visual Studio that gives you quick and easy access to tons of cool code. If you decide to program for Windows, you will hear about Nuget, and you will quickly come to love it. Basically, Nuget makes it really easy to host and consume code libraries. If you don’t know what those are yet, get Nuget anyway. As soon as you find out what code libraries are, you’re going to want it.

Chocolatey

Chocolatey is Nuget’s Windows programs counterpart. What Nuget does for code libraries, Chocolatey does for programs. Quick snapshot: You know how when you want to download a program like Skype you have to go to the website, download the file, find the file, then run the installer? Well, Chocolatey makes it so you can just type the line “cinst skype” into the command line to do all of that automatically. In a lot of cases, you don’t even have to interact with the installer. It does everything for you.

Chocolatey doesn’t host every single program for Windows, but it hosts an impressive number. I’ve only found a handful of programs that I use that I can’t get through Chocolatey.

Boxstarter

Boxstarter is something I’m still figuring out, but I’m absolutely sure it’s awesome. Basically, Boxstarter works with Chocolatey to make setting up a Windows system a one-command process. Quick snapshot: You just got a new computer. Now you have to go find all your programs, download them, install, etc., etc. Boxstarter allows you to write a pretty simple PowerShell script (which you can host on Gist, by the way–see how things are coming together?), which will then do all of those things for you.

I haven’t traditionally been a PowerShell user, and I just got started on Cocolatey a few months ago, so I’m still trying to get a handle on Boxstarter. But again, I’m absolutely sure it’s awesome, and it’s going to change the way I spin up a new computer.

Pluralsight

This is the first thing on the list that has no free version–but it is worth ever penny. Pluralsight is web site that hosts training videos on a huge range of topics–everything from coding to professional development. It is heavier on the .NET technologies than open source, so you’ll probably get the most value out of it if you’re going to program for Windows. The training is well-composed, and they have a couple different subscriptions. One just gives you access to watch the videos. The next tier gives you access both online and on a mobile device, includes pre- and post-assessments of the various courses, and provides exercises. They also do an excellent job of labeling the material appropriately for your skill level. Beginner? Well, then don’t take the “Advanced” course to start out.

Coursera

You’ve probably already heard of this one, but I recommend getting an account. This is an awesome online learning center that is adding topics all the time. Unlike Pluralsight, which I would say is more like vocational training, Coursera is structured as an online academic institution, offering courses on everything from robotics to anti-terrorism to business management from schools such as Princeton, Stanford, and the University of Copenhagen. They just added a feature they call “Specializations,” which allows you to earn a series of certificates that demonstrate a proficiency on a certain topic. For example, they have specializations on Data Science, Challenges in Global Affairs, and Mobile Cloud Computing with Android, among several others. Whether or not future employers or academic institutions will recognize these credentials is debatable and beside the point. The courses here are challenging and offer you opportunities to grow your knowledge and skillset with a more academic mindset.

Khan Academy

I’ve found Khan Academy to be a little hit-or-miss, but it’s a force to be reckoned with. The range of topics is huge. It has some programming and computer science modules, but I’m actually recommending it for the math. As I’ve mentioned, computers were designed to do math. I didn’t come from that background. As a matter of fact, for better or worse, I spent a lot of my time in school figuring out ways to get out of doing math. Majoring in English helped a lot. Not a lot of my programming requires much more than basic math skills, and I handle that just fine. But every now and then a topic comes up that requires me to know just a little bit more than I really do. The nice thing about Khan Academy is that I can usually go straight to the module that I need and figure out where that sits in the spectrum. For example, I didn’t have a great grasp of logarithms, so I went to Khan Academy, found a great tutorial on it, and was able to see from there that this was an Algebra II topic. (Sometimes I don’t know when a problem is algebra, trig, or calculus. I don’t get the differences.) So Khan Academy is a big help in showing me knowledge dependencies.

Miscellaneous

These are a few others that I either know by reputation only or have used only lightly.

  • Udacity – like Coursera but more like Udacity
  • Plunker – like Github but can actually run code live for demos and such
  • JSFiddle – cool web dev tool let’s you test HTML, JavaScript, and CSS. The advantage is that you can manipulate all three files and see the output on a single page.
  • JSLint and JSHint – JavaScript parsers that will let you know how good a shape your JS code is in
  • Regexpal – Simple tester for regular expressions that will give you immediate feedback by highlighting matches in sample text. Especially useful for learning regular expressions.
  • Safari Books Online – Unrelated to the Safari browser, Safari Books is a subscription service that gives you access to a library of books on tech. The library is exhaustive and often includes books that have yet to go to press. They’re also starting to add videos, which might make it more valuable than Pluralsight in the long run.

 

 

The Cheater’s Code, Pt. III: Wildcards

Introduction

Time to finish off this Find and Replace macro by introducing wildcards. This post is the last in a three-part series. If you want to know how we got here, check out Part I and Part II.

Scope of Application

Today’s post relies on Microsoft Word 2013 running on a Windows 8.1 machine. But what I’ll cover applies at least as far back as Word 2007 and Windows XP and the equivalent versions of Word for the Mac. If you don’t have Word, you can get a trial copy from Microsoft’s website.

Where We Left Off

I’ve had a bit of a lull here. Things at work got pretty busy, and I spent several nights working on a library to help analyze lists of files against collections of files to see if they match up. It’s called VennDexer, and the source code is up on GitHub if you’re interested. (If you don’t know what GitHub is and don’t understand what Google is trying to tell you about it, I’ll help you out in an upcoming post where I talk about tools of the trade you’ll want to know.) I also built a lot more macros, so I’ve got a lot of material to post in the near future. I won’t be analyzing them in depth like I have our Find and Replace macro, but I think some of them are good use cases for programming basic repeatable tasks.

But to get back to where we left off, a quick recap:

  • In Part I, we recorded a macro that found a period followed by a space and replaced it with a period followed by two spaces. We also covered what a macro is, in general terms, and why they’re useful. However, our macro had a slight problem. Even when a period was already followed by two spaces, it added a space.
  • The recording process in Part I automatically generated some code for us, so in Part II we examine that code in detail to gain an understanding of how it worked.
  • At the end of Part II, we looked at the source of the problem in our original macro–our logic. The computer was doing exactly what we told it to: finding a period followed by a space and replacing it with a period followed by two spaces. The computer takes our instructions very literally. We didn’t tell it to look for a period followed by one space and only one space. So whether the period is followed by 1, 3, or 100 spaces, our macro is going to find the match and do its job.

Knowing that the computer is going to take you literally to a fault is an important understanding in programming. Sometimes the programming language will help make up for this a little bit, but generally speaking the computer does exactly what you tell it to do–not exactly what you expect it to do. It’s like the old communication exercise where you try to explain to someone how to make a sandwich. Every time you say something, it’s wrong.

You: Get the bread.

Student: Where is it?

You: In the cupboard.

Student: What’s a cupboard?

Really, dumb dumb?

But it gets worse. You have to explain to the student to go to the cupboard, open it, grab the bag with the bread (and you have to explain which bag that is), and so on and so forth. It’s a really useful technique for teaching us how much we take for granted in our communication, and that’s really good to remember when you’re programming. If the computer isn’t doing something you want it to do, you should double check that you told it to do that thing. If it’s doing something you don’t want it to do, make sure that you didn’t tell it to do that. It won’t always be your fault, but I’d say at least 85% of my programming problems are a result of miscommunication problems. The computer is always doing what I say instead of what I mean. (The other 15% of my programming problems stem from the computer being incapable of making a sandwich.)

So we need a way to go tell the computer to look for a period followed by a single space and only a single space. Another way to put it is that we need the computer to look for a period followed by a space, followed by any character that is not a space.

I’m not going to run you through the logic of all the bad options. Obviously it doesn’t make sense to tell the computer to search for “. A”, “. B”, “. C” one after the other until we’ve accounted for every possible set. Not only is that terribly inefficient, but it would be be almost impossible to account for every single character. Also, and this is another key to programming logic, we can safely assume that we are not the first people in the history of coding who have had this problem. Just like we didn’t have to make up a computer language to enjoy automated find and replace functionality, we don’t have to make up the solution to matching large, vague sets of characters. A tool exists.

Wildcards: Not Just for Poker Anymore

You’ve probably already used wildcards, whether you knew them by that name or not. If you’ve ever gone into a file folder to look for all your JPEG images, you might have typed *.jpg in the search bar. The asterisk, or star, tells Windows that you don’t care what comes before the dot. You want to match anything file whose name ends in .jpg. So if you had the following files in a directory

hippopotamus.jpg

todoatthezoo.docx

penguins.jpg

passwords.txt

tigers.jpg

directions.docx

zoobudget.xlsx

and then you searched for *.jpg, you’d get back the following list:

hippopotamus.jpg

penguins.jpg

tigers.jpg

The star (*) is a wildcard. In short, that just means it stands in for something else. Specifically, in this context, the star stands in for anything else. I won’t be covering all the wildcards or how they could be used, but here’s an article that expands on the topic. Also, I found a really well-done blog post on how to do advanced Find and Replace in Word, which includes some info on using wildcards. For something a little more advanced, read this.

You’ll often see wildcards mentioned in the same breath as regular expressions. Just to be clear, Word’s wildcards do not function the same way as the wildcards in regular expressions. There is some overlap, but it is minimal. As you get deeper into programming, you’ll likely come across some regular expressions.  They may look a lot like some of Word’s wildcards, but don’t get the two confused. It is best to think of them as estranged cousins who don’t play well together–who maybe even give each other the evil eye on occasion. Don’t invite them to the same barbecue.

There’s More Than One Wildcard

Just to get another pet peeve off of my chest, the star or asterisk is not the only wildcard. A lot of folks get the impression that it is. The question mark, at sign (@), and angled brackets (<>) can also be wildcards, in addition to other characters. This is more of a snotty nerd issue, but armed with this knowledge, when someone tells you to “use the wildcard,” you have enough snotty nerd clout to say, “Which one?”

But I’ve Searched for the * Before and Found It

Remember that Word’s Find and Replace has additional settings. If you hit Ctrl+F in Word and search for the asterisk, it will match only the asterisk–not any character. But when you hit the “More>>” button, you’ll see an option to use wildcards.

advanced-fr-usewildcards

When that option is turned on, searching for the asterisk will match everything.

How Wildcards Solve Our Problem

My gut instinct might be to immediately add the star to the string we’re trying to find.

.Text = ". *"

Of course, it will only take you a second to recognize the flaw in my dummy logic. The star matches anything. That means it will match another space. So as soon as Word finds a period followed by a space, followed by anything–including another space–it will consider it a match and substitute our replacement text.

But the problem is a little bigger than that. This would also match “. A” or “. t”, or any combination of period, space, letter. When it replaces that text, it will also replace the letter we found.

Poo.

To solve this problem, we need to learn one more wildcard feature. I think it might be a little easier to see the solution and work backward from there. The solution will look like this:

.Text = ".*<"

.Replacement.Text = ".  "

The angled brackets are wildcards that represent the beginning (<) or end (>) of a word, respectively. So what we’re saying here is “Hey, Word! Find a period, followed by anything leading up to the beginning of a word. Replace it with period, space, space.”

Why Does It Work?

The wildcard expression works because it stops matching when it gets to the beginning of a word, which Microsoft Word considers to be any character. It doesn’t match on the character. Just everything leading up to it. This actually means that the expression is pulling double-duty. Not only will it find the combination period-space-character, but it will find period-space-space-space-character. In fact, it will find any number of spaces between a period and the beginning of the next word. So it will ensure that periods with too many spaces are also replaced by a period followed by two spaces.

Actually, It Doesn’t Work… Yet

If you try to run the macro now, you probably won’t get any matches. You definitely won’t if you’re using the source text I was in Part I. You know why, though. We have to turn wildcard matching on:

.MatchWildcards = True

Now it works. If it doesn’t work, have a couple Oreos to calm yourself down and go back through the posts.

We’ve Still Got One Problem

Let’s say this sentence is in the third paragraph of our document:

Dr. Smith called Ms. Johnson and asked her to come in for an appointment the following Monday a.m.

Dr. Smith and Ms. Johnson are going to give us a problem. We’re going to end up with some added space between “Dr.” and “Smith,” as well as between “Ms.” and “Johnson.” Other abbreviations show up in the middle of sentences all the time, too: Inc., Rd., St., Mr., Jr., etc. Again, the computer is going to take us absolutely literally. If we want it to do something different with abbreviations than it does with the end of sentences, we have to give it specific instructions. But I think I’ve given you enough ammunition at this point to leave you with two hints. The first is this: in all but a few rare cases, there are more sentences than there are abbreviations. Fix the spaces after a sentence first. The second hint is the solution:

.Text = "([DIJMNOPRS][cdnoprst]{1,3})(.  )(<?)"
.Replacement.Text = "\1. \3"
.MatchWildcards = True
.MatchCase = True

That wildcard expression isn’t perfect. I was still learning how to use wildcards efficiently when I put that together. But it works. I’ll leave it to you to figure out why it works. If you really get stuck and have no idea what’s going on, feel free to leave a comment or two. I’ll be happy to point you in the right direction.

Love and kisses,

Tyler

Make a Mobile Game without Programming — Yes… For Real

Last week I saw a great presentation on a tool called Construct 2 that let’s you make mobile apps (mostly games) without any programming know-how. Will programming know-how help? Absolutely. Can you make a pretty outstanding game without any programming know-how? Yes! It’s actually kind of amazing. In under two hours, I watched this guy build a mobile game from scratch without writing a single line of code. Granted, he’d prepared a practiced presentation and already had all the tools downloaded and ready to go. But you could build a game from scratch in a week easy if you knew what you wanted to do.

I’ve been kicking around an idea for a mobile game for a couple of years now, but I haven’t ever had the patience to get into building it. Mobile is a different environment. Games are a different kind of work than the business application programming I usually do. It takes some getting used to. I’ve tried starting a couple of times, but I always run out of time or patience before I get into anything interesting. Construct 2 made it a piece of cake. I came home from the tutorial and within a couple hours I had a working prototype of the game I want to build… without writing a single line of code!

Now, of course, I like to code. I’d really like to understand the code that Construct 2 built for me. But I’m not a game programmer by trade. I don’t have 10 more game ideas ready to go. I only have the one idea, and that’s part of the trouble. It’s hard to motivate myself to learn how to program games to build one idea. I’ve got other stuff going on, after all. Justified isn’t going to just watch itself every week. Now I can build my game without the slow drudge of learning a whole new skill set. I just tell Construct 2 what platform I want to build for, and it gives me drag and drop tools. Call it lazy if you want, but when my game hits the app stores, you’ll be glad there’s a lazy entrance to game programming! (No. I can’t reveal the game idea yet. Now that you know about Construct 2, you could beat me to the punch.)

Construct 2 has really good documentation, tutorials, and an active user-base. Plus, it’s free. Well, the free version is free. There’s a paid version with some extra features. I’d start with the free one and see if you need the extra features first, though.

If you want to program games and you want to build something you can put in the Windows Store or Play market today without learning how to call the APIs in a physics engine, give Construct 2 a try. (Especially if the phrase “call the APIs in a physics engine” sounds like total gobbledygook to you.) And let me know when your game is ready to download. I want to see if you put my name in the credits!