Wednesday, March 7, 2018

March Madness brackets in PHP

It's March, and that means I've written yet another article about a program that helps you fill in your NCAA "March Madness" game brackets. This article is a bit different. Where my previous articles described how to write a Bash script to "predict" March Madness brackets, this year's article walks through a PHP script that generates a full bracket.

For those of you who aren't in the U.S., we have a game here called Basketball. And every year in March, the university level (called the National Collegiate Athletic Association, or NCAA) holds a single-elimination championship of the different university teams. If you follow basketball, you can fill out a bracket to "predict" the championship outcomes at each round.

Some people really get into creating their brackets, and they closely follow the teams over the season to see how they are doing. I used to work in an office that cared a lot about March Madness (although in honesty, the office I'm in now doesn't really follow the games that much—but forgive me that I didn't update my Linux Journal article to say so.) I didn't want to miss out on the fun in following March Madness.

I don't follow basketball, but one year I decided to write a little random-number generator to predict the games for me. I used this program to fill out my brackets. And a few years ago, I started writing about it.

Read the article, and use the PHP program to fill out your own March Madness bracket! Let me know how your bracket fared in this year's games.
image: Wikimedia (public domain)

Wednesday, February 21, 2018

Using groff to write papers

In 1993, I discovered Linux, when I was an undergraduate university student. Linux gave me the same power as the Big Unix systems in our campus computer labs, but on my personal computer. I was immediately hooked.

But in the early 1990s, Linux didn't have a lot of applications. When I needed a word processor to write a paper for class, I rebooted into MS-DOS and ran WordPerfect or the shareware word processor, Galaxy Write. I wanted to stay in Linux as much as possible, but I also needed to write papers for class.

I knew a bit about the nroff and troff text processing systems from our campus computer labs, and I was pleased to find that nroff and troff existed on Linux as GNU groff. So I taught myself how to use the groff macro sets to write my class papers. The first macros I learned were the "e" macros, also known as "groff -me" because that was how you invoked the macros from the command line.

I recently wrote an article for OpenSource about How to format academic papers on Linux with "groff -me." I cover the basics for writing most papers, and skip the really esoteric stuff like keeps and displays, nested lists, tables, and figures. This is just an introduction for how to use "groff -me" to write common documents, like papers for class.

Wednesday, February 14, 2018

What open source software programs I love

Earlier this week, someone asked me what Free software and open source software programs I really love. I thought I'd share that here, too.

As I started to go through my favorite programs, I realized it was quite long. So I'm trying to keep the list short here, just the programs I use the most:

I'll start with Linux. I first installed Linux in 1993, when I was still an undergraduate university student. When I heard about Linux, a free version of Unix that I could run on my 386 computer at home, I immediately wanted to try it out. My first Linux distribution was Softlanding Linux System (SLS) 1.03, with Linux kernel 0.99 alpha patch level 11. That required a whopping 2MB of RAM, or 4MB if you wanted to compile programs, and 8MB to run X windows.

I ran a dual-boot Linux and Windows system at home until about 1998, using Windows only to play games. Then I switched to Linux full-time, and haven't looked back. Today, I run Fedora Linux, with GNOME as the desktop.

My other favorite operating system is FreeDOS, but that's not a surprise because I am the founder and project coordinator for the FreeDOS Project. FreeDOS is a complete, free, DOS-compatible operating system that you can use to play classic DOS games, run legacy business software, or develop embedded systems. Any program that works on MS-DOS should also run on FreeDOS.

I usually boot FreeDOS inside a PC emulator called QEMU. I used to run DOSEmu, which was ideal for writing FreeDOS programs because DOSEmu boots its C: drive from a folder in my Linux home directory. That made it really easy to transfer files between FreeDOS and Linux. In QEMU, I set up a folder that is mapped in QEMU as a D: drive.

I write a lot of articles, and now some books, and I use LibreOffice for all of my finish work. In total honesty, I do my collaboration and initial drafts via Google Docs, but all my final drafts and formatting is done in LibreOffice.

Many of my articles are about writing programs, and I use GNU Emacs as my editor. I'll use vim to write shell scripts, and GNOME gedit to edit web pages, but I prefer GNU Emacs for all my programming work. Emacs was my first Unix editor, even before I learned vi, so I'll always have a fondness for it.

While I could compile and debug programs from inside GNU Emacs, I prefer to do that work at the command line using GNOME Terminal.

For any graphics work, I rely on GIMP. This works great for creating graphics for my websites, or enhancing a personal photo, or creating a new cover for my next book.

And finally, I like to listen to music while I'm working, so I usually have Rhythmbox running in the background. I like to listen to one of several streaming radio stations, or I'll listen to my own MP3 music collection.

Thursday, January 18, 2018

Programming with ncurses

Over at Linux Journal, I am writing an article series about programming on Linux. While graphical user interfaces are very cool, not every program needs to run with a point-and-click interface. So in my "Getting started with ncurses" article series, I discuss how to write programs using the ncurses library functions.

Maybe you aren't familiar with curses or ncurses, but I guarantee you've run programs that use this library. Many programs that run in "terminal" mode, including vi editor, use the curses set of functions to draw to the screen. The curses functions allow you to put text anywhere on the screen, or read from the keyboard.

My article series starts with a simple example that demonstrates how to put characters and text on the screen. My example program is a chaos game iteration of Sierpinski's Triangle, which is a very simple program (only 73 lines).

Follow-up articles in the series will include a "Quest" program to demonstrate how to query the screen and use the arrow keys, and how to add colors.

Linux Journal has posted the second part of my article series: Creating an adventure game in the terminal using ncurses. And part three: Programming in color with ncurses. Soon to come: why the Linux console only has sixteen colors, and how to use windows and frames in ncurses.

Monday, January 1, 2018

Write about open source software

I just wanted to point out that over on the FreeDOS Blog, we're asking people to write about FreeDOS.

It's a new year, and we wanted to encourage people to contribute to FreeDOS in new ways. If you're already working on FreeDOS through code, design, testing, or some other technical way - thank you!

If you aren't sure how to contribute to FreeDOS, or want to contribute in a new way, we'd like to encourage you to try something new: Write about FreeDOS!

Write about something that interests you! Others will want to see how you're using FreeDOS, to run existing programs or to write your own programs. We want to hear from everyone! It's not just about developers, or people who contribute to the FreeDOS Project directly. Tell us how you use FreeDOS.

Post on your own blog, or email your articles to me and I'll put them up as a guest post on the FreeDOS Blog. If we can gather enough articles by Spring, we'll try to collect them in a "how-to" ebook in time for the 24th "birthday" of FreeDOS on June 29.