Evil_Dragon_ASCII_ART_by_machocr

It’s no secret that I’ve always been a bit of a nerd. I guess Exhibit A would this blog. The thing that really brought me into the nerd fold, however, wasn’t programming. It was Multi-User Dungeons. What is a Multi-User Dungeon, you may ask? Well, a MUD (see what I did there?) is an online, text-based roleplaying game. Think of the next evolution of Dungeons and Dragons. In fact, think of the previous evolution of World of Warcraft.

When I was in the 7th grade, I was introduced to an online world of magic and mystery. Unlike any other game I had previously played, Dragonstone had the mechanics of a video game, but was built on imagination and creativity. I loved creating a character backstory and participating in the constantly evolving storyline of the realm. It didn’t take long before I wanted to learn how to make my own MUD, which is how I got started in software development.

Now, 15 years later, I still like to hack around on some old MUD codebases (partly for nostalgia, and partly to remind myself how to program in C). Recently, I started working through my favorite codebase, Entropy of the Storm (EotS), and one of the most valuable features of a MUD is the hotreboot functionality. Hotreboot is essentially a way to reload the game executable without having to kick all of the players off, thus preserving the flow of gameplay. It is an excellent feature that was written into EotS, however, when the codebase was released, it was partially unfinished.

Fortunately, getting it working is pretty straightforward, but for more novice coders out there, there isn’t any information on Google about how to actually accomplish this. I’m going to be using the stock EotS codebase to demonstrate how to accomplish this, and have made the current version I am hacking on available on GitHub.

Initial Setup

Before we can use the hotreboot functionality, we fist have to declare some constants.

Hotreboot Recover Connection State

If you take a look at hotreboot_recover() in comm.c, you’ll see that all character descriptors are set to the CON_HOTREBOOOT connection state. Unfortunately, this constant isn’t defined anywhere. To define it, open up merc.h and find the following line of code:

1
#define CON_PLAYING 0

Once it has been found, add the following line of code above it:

1
#define CON_HOTREBOOT_RECOVER -15

Executable File Path

Another missing constant in the do_hotreboot() function in comm.c is EXE_FILE. This constant defines the location of the executable file. To add this, open up merc.h again and fine the following line of code:

1
#define NEWBIE_FILE "newbie.dat"

Below that, add this:

1
#define EXE_FILE "../src/tmp/envy"

Fixing Bugs

Now that we’ve defined the necessary constants, there are a few bugs that need to be cleaned up.

Fix Descriptor Variable

While the code to initiate a hotreboot is in relatively good shape, the code to recover from the hotreboot needs some bugs to be cleaned up. The one that prevents us from recovering from a hotreboot is the use of the wrong variable for referencing character descriptors. To fix this, we’ll have to make a few changes. First, find the following block of code in hotreboot_recover() in comm.c:

1
2
d = alloc_perm (sizeof(DESCRIPTOR_DATA));
init_descriptor (d,desc); /* set up various stuff */

Once you’ve found it, cut that block of code out, and move it below the following block in the same function:

1
2
if (desc == -1)
    break;

You should now see something like this:

1
2
3
4
5
if (desc == -1)
    break;
 
d = alloc_perm (sizeof(DESCRIPTOR_DATA));
init_descriptor (d,desc); /* set up various stuff */

Now, within the same hotreboot_recover() function, find all references to the variable desc (below the line of code we just moved) and replace with d. For example, this call:

1
write_to_descriptor ("\n\rUnable to find your character.  Sorry.\n\r", 0, desc);
1
write_to_descriptor ("\n\rUnable to find your character.  Sorry.\n\r", 0, d);

ANSI Persistence

If you use ANSI in your game, one thing that wasn’t added in the original hotreboot functionality was ANSI persistence. That is, saving the player ANSI preferences. To do this, find the following line in the do_hotreboot() function in comm.c:

1
fprintf (fp, "%d %s %s %s\n", d->descriptor, och->name, d->user, d->host);

Once found, replace it with this:

1
fprintf (fp, "%d %s %s %s %d\n", d->descriptor, och->name, d->user, d->host, d->ansi);

This stores the player ANSI settings (d->ansi) in the hotreboot file, which is used to rebuild the player descriptors.

Next, we need to tell hotreboot_recover() how to read the new ANSI data. In hotreboot_recover(), first find this line:

1
char host[MAX_STRING_LENGTH];

Then add this line below it:

1
int ansi;

Now, look for the code that reads the hotreboot file:

1
fscanf (fp, "%d %s %s %s\n", &desc, name, user, host);

Once you’ve found it, replace it with this:

1
fscanf (fp, "%d %s %s %s %d\n", &desc, name, user, host, &ansi);

As you can see, we updated the parser to be able to read the ANSI preference.

Permitted Connection States

The final bug that needs to be fixed is a minor one, however it will ensure that only players in the proper connection state will be brought with the hotreboot, while the others will be dropped. Find this line in do_hotreboot():

1
2
3
if (    !d->character           /* drop those logging on */
    ||  d->connected != CON_PLAYING     /* check if there playing */
    ||  d->connected != CON_CHATTING    /* check if there in the chat room */

As you can see, when dealing with negatives in an if-statement, an OR switch will not work (everything will always be NOT one thing OR NOT another). To fix this, change that block of code to the following:

1
2
3
if (    !d->character           /* drop those logging on */
    ||  (d->connected != CON_PLAYING    /* check if they're playing */
      &&  d->connected != CON_CHATTING) /* check if they're in the chat room */

Enabling Hotreboot

Now that we’ve worked out some of the kinks, all we have left to do is to enable the hotreboot functionality in the code! To do this, open up merc.h and add the following line right at the top of the file, below the initial comments:

1
#define HOTREBOOT

That’s it! To get everything going, make sure to do a make clean and when you next reboot, type hotreboot in-game to use your new reboot!

C, Code, MUD

Read more

Recently, I set up a Vagrant box that was running Django, the Python-based web framework. One thing I quickly learned is that Django cannot run as a daemon. After hours of Googling and stressing out, I remembered one of my favorite tools: GNU Screen. GNU Screen is a terminal-based window manager that lets you detach running processes, and connect back to them later. Unlike nohup, screen is an excellent way to manage long-running scripts, as you can interact with them later.

The setup for this is pretty easy. All you need, in addition to the Vagrant+Puppet setup you will already require to run Django (which I won’t go into at this time), is to install the “screen” package. Assuming your manage.py file is in the shared /vagrant directory, the following Puppet command will run Django as the default “vagrant” user, listening on all interfaces on port 8000.

1
2
3
4
exec { "start-django":
    command => "/bin/su -c 'cd /vagrant ; /usr/bin/screen -S runserver -d -m /usr/bin/python manage.py runserver 0.0.0.0:8000' vagrant",
    require => Package["screen"]
}

That’s it! It’s quite simple, and this same technique can be used for other methods as well (for example, running “grunt watch” on your /vagrant folder under the “vagrant” user upon startup).

Read more

I’m not an overly paranoid person. While I appreciate the rush that comes with secrecy, I honestly prefer to be more open about my life. That being said, it is always exciting to come up with new ways to hide things. Whether it is through software tools, such as TrueCrypt, or hiding USB drives inside of innocuous items, it is fun to occasionally feel like a spy. Recently, I was working on modding my first-generation Xbox and needed to be able to access an Xbox memory card. While there are a lot of options out there for doing this, I chose to rewire the controller dongle to connect to a USB port.

Step One. The Wiring.

Unfortunately, in my haste, I did not document this process, but here is a screenshot of the chart I used to do this.

xboxcablemodpaint

One thing to be sure when you are wiring this up is to rewire the detachable dongle at the end of the Xbox controller, rather than the cable attached to the controller. This will allow you to use any Xbox controller, and will also allow you to still use the controller with your system (although I’m not sure who still plays an original Xbox).

2014-01-04 11.35.48

Step Two. The Memory Card.

Now that you have your controller wired up, connect it to a USB port on your computer. You may get a notice about the card not being a proper format. That’s okay. If that happens, pop open “Disk Utility,” click on your memory card in the left selector (it will be labeled with the size of the memory card, which in my case is 16.4 MB), and then click on the “Erase” tab. I chose the MS-DOS (FAT) format because it will allow the memory card to be readable on both Windows and Mac OSX. You can use any name you want. I chose TOPSECRET for the purposes of this example.

Screenshot 2014-01-04 11.37.03

Click “Erase” and your memory card will be erased and formatted. You will now be able to pop open the new memory card from your desktop and start adding files to it! Once you’re done, be sure to throw it in with the rest of your Xbox memory cards so it doesn’t stand out, and tuck the USB dongle somewhere safe!

Screenshot 2014-01-04 11.37.31

Happy hiding!

Read more

IMG_5tagbundle_clean

A few months ago, I made the switch from the iPhone to the Moto X and have been blown away by how far Android phones have come in the past few years. One of the coolest things about the Moto X (apart from the touchless voice controls, killer app integration, and automation ability) is the Near Field Communication (NFC) functionality. NFC is a set of standards for smartphones to “establish radio communication with each other by touching them together or bringing them into proximity” (Thanks Wikipedia). What this means is that your phone can run tasks or communicate with other devices simply by touching things.

As cool as this is, I am never satisfied with something unless I hack with it a little bit. One of the first things I bought when I got my Moto X was buy a set of NFC tags. These little buggers can be programmed with your Android phone (using an app called Trigger) to run tasks. Automatically check you in on Foursquare, silence your phone, pull up apps, send text messages… You can do basically anything you want within the scope of your phone. The one thing you can’t do with NFC tags and Trigger is control your computer.

Say, for example, you couldn’t remember if you locked your computer when you left the house. Maybe the screen doesn’t automatically lock itself, or you left Caffeine running. Whatever the reason, you just want to a way to always be sure that your computer is locked. This is where an NFC tag (in the form of a keychain) can come in really handy. The ideal would be to simply tap your phone to your NFC keychain, and your computer will be locked down. No fuss, no muss.

To accomplish this task, there are a few tools we are going to need:

  • IFTTT - The best way to build triggers based on input you determine
  • Dropbox – The very best place to store your files
  • Hazel - My favorite folder action automator
  • Trigger - A must when working with NFC tags

Step One. Setting Up IFTTT.

Before we program our NFC tags, we first need to get the automation workflow set up. The way we are going to control our computer from our phone is to send a text message to IFTTT, and if that message contains a hashtag we define, a file will be put into our Dropbox that Hazel will then pick up and run our AppleScript on.

Screenshot 2014-01-04 00.21.46

Now, I won’t go into the details of setting up IFTTT, but I have created a public IFTTT recipe that you can use at https://ifttt.com/recipes/138065. To use this recipe, simple send a text message to your IFTTT SMS number with the tag #lockitdown in it. This will create lockitdown.txt in your Dropbox folder at /Automation/actions/lockitdown.txt.

Step Two. Setting Up Hazel.

In order to act upon the lockitdown.txt file, we need to set up some rules in Hazel. First, open up Hazel and add the Dropbox/Automation/actions/ folder to it.

Screenshot 2014-01-04 00.23.33

Now, add a rule for that folder called “Lock It Down!” This rule will be matched if Name is lockitdown. When a file matches, set it to “Run shell script” and then move the file to the trash.

Screenshot 2014-01-04 00.30.50

Edit the embedded script, and add the following code to it:

1
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

Screenshot 2014-01-04 00.30.45

What this does is lock your computer (not start the screensaver), which will require your password to unlock.

Step Three. The NFC Tag.

Now that we have the automation down, let’s tie it to an NFC tag. Open up Trigger on your Android phone and create a new task and select NFC as the trigger.

2014-01-04 07.34.19

 

Add an action that sends an SMS message to your IFTTT phone number with the message “#lockitdown.”

2014-01-04 07.34.59 2014-01-04 07.35.24

The final step is to pair this task with an NFC tag.

2014-01-04 07.36.06

2014-01-04 07.36.12

Once you do that, you’re all done! Now, every time you tap that NFC tag with your phone, a text message will be sent to IFTTT, which will then create a file in your Dropbox folder, causing Hazel to run a shell script that will lock your computer! It’s a bit Rube Goldberg-y, but the functionality is there, and it’s kind of fun seeing all of the steps come together!

Read more

At some point in my life, I would love to hit the reset button on my career and give another one a chance. Here are a few jobs that I would like to try in my future. All of these jobs have been added to my Impossible List.

1. Computer Forensics Investigator

I know it’s not exactly like CSI, but in college I took a tour of the Rocky Mountain Regional Forensics Laboratory in Centennial, Colorado and was super impressed at the work they did there. They do good work and put away bad people, and that is something I would love to be apart of some day.

RCFL3

2. Cartoon Voiceover Actor

I am in no way an actor. While I’ve always viewed acting as just very convincing lying, and a convincing lie is just a lie that you truly believe (thank you Seinfeld), I am a bit of an introvert, and find being on film or in front of a crowd terrifying. Voiceover acting, however, sounds like a blast. Ask anyone that knows me, and they’ll tell you that I am full (to the point of irritability) of distinct voices and accents. While doing a voiceover for a cartoon character or video game is already on my Impossible List, it is still a career I would love to take a crack at.

Bill-Farmer-Interview-Opening

3. Disney Imagineer

What job could be cooler than being one of Disney’s Imagineers? Part imagination, part engineering, these guys are responsible for some of the most amazing Disney inventions and creations (Smellitzer, anyone?). Unleashing my imagination on my engineering experience to solve different problems sounds exciting and very free.

Legends-of-Imagineering-i-w

4. Teacher

While not the most glamorous of careers, I think we can all agree that a great teacher can make a world of difference in a student’s life. While I didn’t always have the best teachers growing up, there were a handful that made a profound impact on who I am today, and I would love to pay that gift forward someday.

20845a

Read more

I am by no means an expert in marketing, blogging, or niche sites. Frankly, I feel like half of my time is spent feeling around in the dark for the right light switch. Despite the countless articles devoted specifically on how to blog and make money online, most experts will say that nothing will replace putting knowledge into practice and learning from your mistakes. I like that. I like making mistakes and figuring out what went wrong, and how I could have done better. Even more exciting to me, however, is accidentally succeeding at something and then trying to figure out how the hell I did it.

I recently wrote a blog post about how to post affiliate links to Pinterest. It isn’t an overly complicated process, but it was an interesting trick that I learned and I figured I would share it. That process called for signing up for VigLink. While I have made a couple pennies off of the sample pin I used, I didn’t think too much about VigLink afterwards. At the time, I was more interested in the solution than the implications of it.

A little over a month ago, I decided to install the VigLink WordPress Plugin on my blog. There wasn’t really much of a case for it. I’m not making a huge effort to get affiliate revenue from anywhere, but the thought at the time was “it couldn’t hurt,” since the worst case scenarios is that I make $0.00. What the VigLink WordPress Plugin does is automatically sends all outgoing traffic from your blog through VigLink, so if you link to a supported affiliate, you will get commission on any sales through that merchant. Now, I didn’t exactly make big bucks, but just by installing a plugin on my blog, I made $4.00 in December off of just a handful of clicks to some automatically-affiliated links to ThinkGeek.

Screen Shot 2013-12-30 at 12.35.03 PM

While this will likely not changing my blogging habits (or lack thereof), it is a nice feeling to be able to make a few bucks without doing anything extra. The lesson that I learned here is that doing something may not always give you the results that you want, but doing nothing will guarantee that nothing will happen for you.

Read more

Flower (165 of 890)

My wife is a wedding planner. Being married to a wedding planner has a tendency to put weddings on the brain, which has me thinking about everything from the groom’s perspective on a daily basis. One of the things that I remember from planning our wedding was trying to figure out an appropriate gift for my groomsmen. There are a million options out there, although seeing past the cigar cutters, hip flasks, and cufflinks can be a daunting task. Here are 10 of my favorite groomsmen gift options that I chose between.

1. How to Avoid Being Killed in a War Zone

How to Avoid Being Killed in a War Zone

Nothing is more exciting than a good book that nobody has ever heard of. The unique content of this book may or may not ever come in handy for your groomsmen, but it will provide hours of interest, and give them something to talk about for months. Buy Now – $20.89.

Read more

Pinterest 5

Pinterest. It is a fantastic marketing tool for many companies, both small and big. All it takes is a great idea and an eye-catching product to run a successful marketing campaign on Pinterest. With the right Pinboard theme and product list, affiliate marketers could very easily use Pinterest to create beautiful ad campaigns with very little overhead or buildup. Unfortunately, Pinterest doesn’t like affiliate marketers to market their products on their service. This is understandable, as an excess of the wrong type of products could flood Pinterest with far too much spam, but knowing how to get around this restriction could be very useful for affiliate marketers who have a small number of products, or just one product that they would love to sell.

The Tools

For this tutorial, we are going to use Dropbox to host our product pages, and VigLink as our affiliate program.

The Setup

 

Before we create our special product page, we need to get our affiliate link. For those who are new to VigLink, go to http://www.viglink.com/products/anywhere, put your link in (I’m using this awesome Zombie Shower Gel for this example), and click “Build.” Copy the link, we’ll be getting to it soon.

VigLink_Anywhere_-_Earn_Revenue_Everywhere_Your_Link_Goes

Next, you will need to download the product image. This is necessary for Pinterest to be able to load. Save the image in your Dropbox Public folder, and name it something you will remember. We’ll be using it in the next step.

Read more