# How to Convert Between Decimal and Binary in T-SQL

For the past six months, I’ve been teaching night classes in database programming and my students are just about ready to take Microsoft’s 98-364 exam. Now, we’re transitioning over to C# programming for the next phase of the program but I have to keep their SQL skills fresh for the exam.  Tonight, it was time to teach them to understand the binary number system.  I dropped some hints on it a couple of months back to brace them but now it was time to get it done with once and for all.

Then, as I like to do with this class, I came up with a lesson plan that would incorporate the best of both subjects …

# Primes in the Key of C#

Yes, prime numbers are a go-to challenge for me that I’ve been casually playing with since my earliest programming days. I’m not alone; prime numbers are important and popular enough that there’s an entire distributed computing project dedicated to finding the highest Mersenne Prime number (primes such as 31 and 127 that are one less than a power of 2). A decent grounding in math is also important for programmers and prime number algorithms are a much better programming exercise than “Hello, World”.

That’s why, during a holiday trip to a local Barnes & Noble, I was looking through their collection of quick and shallow knowledge books (“100 Factoids That Will Make You Sound Knowledgeable  …” ) and found one called Math Squared: 100 Concepts You Should Know. I wasn’t expecting a degree out of this small, 256-page book but it’s been awhile since math class, I thought it might give me some good ideas for programming exercises and I like the feel and smell of new books.

# My First Steps with Python – Prime Numbers

I recently started studying the Python programming language. I’m getting ready for a new programming-related position next year and one of my colleagues suggested using Python as part of it. I’ve heard of Python more and more over the past several years and I figured now would be as good a time as any to finally learn it.

I can definitely recommend Udemy’s Complete Python Bootcamp by Jose Portilla. This course is written for complete programming beginners and does an excellent job of introducing the fundamentals and guiding the student through various programming concepts. It’s probably more basic than I actually need but it never hurts to go back to school.

# Power Up! Weekend – Ocala’s First Hackathon

Ocala’s Chamber and Economic Partnership (CEP) and the Ocala I.T. Professionals are sponsoring Ocala’s first hackathon at the Power Plant Business Incubator on October 15 & 16, 2016!  For complete details and to register, visit http://powerupweekend.eventbrite.com. Attendance is limited to the first 100 people registered so be sure to sign up early!

Both days will start at 10 a.m.. Attendees are welcome to stay until 10 p.m. on the first day when we’ll be forming teams and beginning to code. The event will wrap up at 5 p.m. on Sunday, Oct 16, when each team will present what they’ve made.

This is an awesome chance for you to put your coding skills to use, build something great and meet other area programmers. Again, attendance is limited to the first 100 people registered so sign up now at http://powerupweekend.eventbrite.com.

# Calculated Fields in CiviCRM

One of CiviCRM’s strengths is the ability to add custom fields to hold specific information about your contacts. One thing it doesn’t offer (yet) is a calculated field type that will present the results of calculations of other fields.  While calculated fields are generally discouraged in relational database design, they are sometimes necessary within a user interface. One suggested method is to add custom code hooks within CiviCRM’s PHP code but as a database guy, I decided on a back-end solution.

# MySQL User Defined Function Example: Data Cleanup

(Updated June 9, 2016)

### The Challenge

One of my current projects involves migrating a large amount of data away from an old custom Borland Paradox application into a new CiviCRM system. As with too many quickly-constructed apps, this old Paradox database wasn’t especially well designed and, among other the other challenges in salvaging the data, there were no restrictions on how dates could be entered. This means that, in multiple fields within each of the 20,000+ database records, I might see any of the following:

```03-14-96
5/20/1975
10/02/83
09051975
07.19.1995
19830211121500```

While CiviCRM does have a utility for importing data from CSV and other SQL tables, it was having quite a time with this collection and many of the dates were being mishandled. That’s if the records weren’t rejected entirely for other reasons. Data migration doesn’t often happen with just a few settings adjustments and a click of the Import button.

# Coding Basics – Deceptively Simple Programming

In my last post on coding basics, I talked about turning an algorithm into code and used Euclid’s Algorithm as an example of programming a sequence of steps. There’s an even simpler type of algorithm that I want to look at this time. A formula, such as the one for converting Fahrenheit to Celsius, is also a series of steps that must be performed in order to achieve the needed result. These calculations can be represented within C# or other programming languages to include the formula as part of a larger program.

If you’re doing a one-time conversion from Fahrenheit to Celsius, you’re probably going to pull out your pocket calculator or find a good conversion website and enter the necessary numbers. You can do that because either of those resources has the necessary interface to get the necessary input from you. If you’re including this calculation in a program, you need to design your own interface, process that user input from it and return the result to the user in some way. In the case of the pocket calculator or website, other programmers pondered these issues at some point and now it’s your turn.

I’ve been working on a number of different projects lately, from I.T. networking to a book on MySQL, so I haven’t had as much reason to break out the programming tools as I used to. If not used regularly, programming skills can get a little rusty or even disappear like old friends from your college days that you lost contact with.

So, I’ve decided to delve back into the subject and update my status as a .NET programmer. The first step is a quick review of the C# language.  One resource that I can recommend for this is The C# Programming Yellow Book by Rob Miles. It’s just \$0.99 for the Kindle version on Amazon.com and you can even get a free PDF version from the author’s website.

# From Algorithm to Code

In previous articles, I’ve talked about the importance of finding the right algorithm, or series of steps to follow, when coding a solution. Efficiency in terms of the amount of memory used and the amount of time taken by the operation are key factors for the program. Sometimes an appropriate algorithm is already available and in wide use and it’s just up to the programmer to turn it into code. There’s always the option of running to StackOverflow and grabbing some code but that does nothing to further your talent.

# Adding Passswords to Microsoft Access Switchboard Options

The Switchboard Manager in Microsoft Access makes it easy to create a system of menus that will enable your users to navigate through your application. It also relieves you of the need to manage multiple menu forms and macro calls.

Figure 1 – Example Access Switchboard

Sometimes, however, you might want to keep all but a few users out of specific areas, even if it’s just a password to discourage the curious. This is one thing the Switchboard Manager doesn’t offer and I’d like to show you one method for achieving this here. I want to stress that this method is not truly secure.  On it’s own, it won’t prevent a user from hitting F11 and browsing through the database. A power user who wants to see those areas could defeat this method pretty quickly. It will keep the merely curious and inexperienced users out, however, and could be combined with other measures to add more security.