I know I am about two years late to the 2048 Clone Wars, but I finally got around to finishing my variant, 2048 Chess. Originally I wanted to have multiple chess pieces on a larger 2048 board. What I ended up developing was simply the kings. The gameplay doesn’t lead to terribly interesting strategy. It’s ultimately a game of button mashing and luck. Whatever, I’m calling it done: http://danielbank.github.io/2048-chess/.
Making a GitHub page for a forked repository that already has a gh-pages branch:
My biggest hurdle in finishing this project was when I attempted to view the GitHub page for the repository. GitHub was overriding the game’s index.html with an automatically generated GitHub page. I found this incredibly useful StackOverflow question for fixing that problem. The prescribed steps were to:
Make a file called index.md.
Edit the contents of index.md to be:
---
layout: index
---
Make a file called _config.yml.
Edit the contents of the _config.yml to be:
markdown: redcarpet
Create a _layouts folder.
Move your index.html into the _layouts folder.
Commit the changes and push them to the gh-pages branch of your repository on GitHub.
The automatically generated page should be replaced by your page when Jekyll generates it.
Recently I discovered Google Apps Script, a comprehensive system for automating your Google accessories (Gmail, Drive, Calendar, Tasks, etc.). It includes a web IDE for writing JavaScript code and easy-to-use API’s for each Google accessory. When you finish writing your scripts, you can save them to your Google Drive and set up triggers to have them run automatically. Within a few hours of discovery, I had written my own Google Apps Script, which I will now share with you.
First a little background on the problem I needed to solve. I use the Google Calendar extensively. In addition to the regular events I put on my calendar (lunch with friends, doctor appointment, anniversary), I also put reminders for tasks that need to get done. I realize that Google already has a Tasks list for this very purpose. Call me crazy but I find it easier to whip out the Calendar app on my phone and insert a new event. The only problem is that I also procrastinate. Weeks will go by and the task’s calendar event is still languishing on my Calendar. At the end of every month, I have to clean up my Calendar and decide which tasks are actually important or not. The ones that are all have to be moved to the next month.
Enter my new Google Apps Script, Calendoo. Calendoo looks at yesterday’s calendar events and either advances them into the future, if they’re important, or moves them off the Calendar and into a Tasks list (called TasksFreezer), if they are unwanted. In order for Calendoo to recognize which events belong where, you simply add a Calendoo symbol in the name of your calendar event. The Calendoo symbols are as follows:
:. (colon period) = Unimportant event, advance yesterday’s unimportant events to next month.
:! (colon exclamation-point) = Important event, advance yesterday’s important events to today.
:? (colon question-mark) = Semi-important event, advance yesterday’s semi-important events to next week.
:- (colon dash) = Unwanted event, take it off the calendar and put it in the TasksFreezer Tasks list.
:+ (colon plus) = Wanted task, take it off the TasksFreezer Tasks list and put it on the calendar today at noon.
If you want to use the Calendoo script, read on for an explanation of how to set it up.
Google Apps Script: Make a copy
1. Import the script into your own Google Drive
Click on the link at the bottom of this blog post. The Google Apps Script IDE page should open up showing the Calendoo code. Click the [File] menu and choose [Make a copy]. The Calendoo script should be downloaded to your own Google Drive. Access it by going to drive.google.com. The Calendoo script file should be in your root folder. Click on it to open it. At this point, you may have to go through a wizard for installing Google Apps Scripts in Google Drive if this is your first time using them. The Google Apps Script IDE should open again, this time with the Calendoo script installed in your own Google Drive.
Advanced Google Services Dialog
2. Set up APIs and Permissions for the script
Next, click on the [Resources] menu and choose [Advanced Google services]. An Advanced Google services dialog will appear. Next to Tasks API, click the radio button to turn it on. This allows the code to access Tasks API functionality (used for managing Task lists in your calendar).
Google Developers Console Page
Now you will need to enable the services. Click the [Google Developers Console] link at the bottom of the dialog. The Google Developer Console website should open. In the list of APIs, click the radio buttons next to Calendar API and TasksAPI to turn these services on. Now close the Google Developers Console page and the Advanced Google services dialog.
Run the processEvents Function
Back in the Google Apps Script IDE, we need to run a function in the Calendoo script so it can request permissions from you the user (yes, this step is a little strange, I know). Click on the [Run] menu and choose the [processEvents] function. A dialog will appear saying, “This app would like to: manage your calendars, manage yours tasks, view your tasks”. Accept the dialog and it will close. The Calendoo app is ready for action, we just need to pull the trigger.
3. Set up a trigger for the script
Current Project’s Triggers
To create a trigger to run the script periodically, click on the [Resources] menu and choose [Current project’s triggers]. A dialog will appear with a link, “No triggers set up. Click here to add one now”. Click on that link. The dialog will now show the options for our new trigger.
New Project Trigger
Choose to run the processEvents function. This is the main function that drives the entire Calendoo script. Make the event Time-driven and set it to run everyday at Midnight to 1am. This will cause the processEvents function to be executed everyday at midnight, pushing yesterday’s events forward. Click Save. The Calendoo script is now completely configured for your Google account. Hurrah!
An online friend of mine recently brought to my attention PCE.js, a browser-based emulator of the Macintosh Plus. Click the link and experience it for yourself. This emulator is solid gold. The machine it is emulating is solid gold. It’s a throwback to a world of computing almost 25 years ago. Those were the days of System 7 (which, in my opinion, is still a more intuitive interface than every other Mac OS since then). At the time, I was three years old. The Macintosh Plus was the first computer my family owned and it will always have a dear place in my heart. Between the ages of three and seven, I was inseparable from the Macintosh Plus. I fondly remember playing games like Dark Castle, Dungeons of Doom, Rogue, StuntCopter, and more. By the way, for anyone who saw the Angry Video Game Nerd’s review of Dark Castle for CDi, the Macintosh version was much easier to control with a mouse and keyboard.
Firstly, when you open the emulator you might be astonished by the specs of the machine. It has 4MB of memory and about 20MB of disk space. Really powerful stuff for 1986. Now I can run System 7 in a web browser on my computer while I simultaneously listen to music and write this blog post in another window. And my computer is still only using 12% of its CPU. I know it’s not a fair comparison, but I always have two feelings when I reflect on this. One feeling is, “How did I think that was so awesome back then?” The other feeling is, “What if I could see then how powerful the computer I use now is?” There is also a third follow-on feeling, “How awesome are computers going to be thirty years from now?”
Erase Disk next to Empty Trash
Now for a little side lesson in Human Machine Interaction. Open the PCE.js emulator. If you go to the Special Menu of the Finder, you will see it has some familiar options: restart, shut down, empty trash, and… erase disk? Wait a second, are we sure we want to put that potentially disastrous functionality next to all these other innocent ones? Well why not? Every computer user can read the options can’t they? Not if you are three-year old Daniel Bank who likes computing even though he can’t read. Three-year old Daniel memorizes where things are physically on the screen and clicks OK until dialog windows go away. Maybe you can see where this is going (hint: I was trying to empty the trash and I accidentally reformatted my dad’s external hard drive… he was not happy).
Lastly, this post wouldn’t be complete if I didn’t talk about HyperCard. Essentially, it was a stack of “cards” that you could add scripting to. You could save your stack as a file and share it with others who could then open it with a HyperCard viewer. The scripting really made things interesting because you could transition to different cards when a part of one card was clicked, you could prompt the user for input, you could keep track of variables, and so on. Sadly, you won’t be able to experience HyperCard in the emulator because it only has a viewer.
Clock Tower in Dark Castle
HyperCard actually represented probably 80% of my play time on the Macintosh Plus. Sometimes I played other people’s stacks, but mostly I was creating my own. I created dozens of HyperCard games and finished maybe a handful of them. Mostly my stacks consisted of just a title screen and maybe the first few cards of an actual game. I was learning the fine art of creating VaporWare. The first words that I actually wrote with a pencil were go next, a command from the HyperCard scripting language to move to the next card. This was the start of a mad desire to create my own software gaming studio that lives on to this day.
So ends my nostalgic reflection on the Macintosh Plus as experienced through PCE.js. Tremendous kudos to James Friend for making this emulator. I have no idea how he did it but it is an awesome example of running a virtual machine in a browser.
I created a new JavaScript library called OfflineSaveQueue. The purpose of this library is to temporarily save JSON objects in HTML5 Local Storage in the event that an internet connection is not available.
The creation of this library arose out of my need to save data to Parse.com from a PhoneGap application. The app was not guaranteed to have internet connectivity so I needed a way to put the data in a temporary queue where it could be kept until I got a success callback from Parse.
OfflineSaveQueue is not being maintained anymore and I don’t recommend using it. However, if interested you can still take a peek at the GitHub repository.
Usage of OfflineSaveQueue is simple:
Instantiate an OfflineSaveQueue object:
var offlineSaveQueue = new OfflineSaveQueue();
Set the callback function which is executed when the queue is processed:
I created a new jQuery plugin for handling simple pop-ups. The plugin is called jquery.tent. It is available here (https://github.com/danielbank/jquery.tent). It is based off a tutorial by Keith Wood for making jQuery plugins (http://keith-wood.name/pluginFramework.html). I highly recommend this tutorial because it explains things quite well and the code itself is really well written.
Usage of jquery.tent is simple:
1. Initialize a DOM element as a tent.
$("#pop-up").tent();
2. Set the tent options to control the location where the popup is shown.
You must be logged in to post a comment.