Twitpocalypse is Nigh

2,147,483,647

In many programming languages, that’s how large your int variable can be. Anything past that returns a “Hey! That’s not 32-bit!!” error from the CPU.

I’m trying to think if I’ve seen a video game with a higher score than that. What about that Steve Wiebe Donkey Kong guy recently? He just needed to listen to Rush, right?

Why a Twitpocalypse? The number of Tweets is approaching 2,147,483,647. Each Tweet is assigned a number. Once the Tweets go past that, it may go into negative numbers, it may cause a core dump, it may even kill Spock.

I always got that error when I was working in C++ (the core dump, not the Spock death). If I could go back in time, I would fix my integer definitions. That’s right – nothing life-changing, just better code.

What does it mean for you? Programs like TweetDeck or Twhirl or Twslapmeintheface may freak out and not update properly. We may also see a visit from the Fail Whale.

Check here for more details on when the Twitpocalypse shall arrive: http://www.twitpocalypse.com/

Much like my samurai counterpart, I blame Oprah. But can you imagine being the last tweet to send it over the edge?

AppleScript: Watching your computer do your work for you

I put this script up to help anyone out trying to learn AppleScript to automate a repetitive process (like typing a different set of numbers into a website 3,000 times).

For those not interested in code or macros, check out this dancing Macross:

I’ve messed around with Automator on the Mac a little bit, and it’s creepy watching my computer do work without me.

I just finished running my first AppleScript. Here’s the story:

When I scanned a section of my library into my inventory, the scanner saved all of those barcodes as a text file. But here’s a mistake I had made (did I mention 13,822 barcodes?): I had closed all of the previous librarians’ inventories. It asked me what to do with books I hadn’t inventoried yet. I said to mark them as lost, since when I manually scanned a book in, our catalog responds, “This copy had been marked as lost, but will now be found” (or something to that effect). After scanning all of the books, what was left would be truly lost books.

Little did I know that when you use a portable scanner to store up a list of barcodes, when you import that list it says that lost books had now been found, but didn’t update the copy status (they’d still be considered lost until someone hand-scanned them in)(even though I just got done scanning them with a portable scanner).

Since it was already 9pm, I didn’t want to type in 3,000 barcodes by hand.

This morning I wrote my first script in AppleScript. What makes AppleScript different from other programming languages is that it is set up specifically to automate programs that you already have.

I wrote a program that would check the file from the scanner, type in a barcode, press enter, and move on to the next line and repeat the process (like a robot typing in each barcode, line by line).

I set it up so that you run the code, choose the text file holding your barcodes, and then have time to click on the place in your catalog where you type in for books to be checked in. You have to manually click on that text box in your catalog at the start, but I set it up like that so that if your catalog wasn’t set up exactly like mine, you could still use my script.

Here’s the script:
-- variable for carriage return/enter key
set CR to ASCII character of 13

set the source_file to choose file with prompt "That freaking file is located here:"
--give me time to switch back to the circulation
delay 5

-- get file data
set fp to open for access source_file
set barcodes to read fp
close access fp

-- types each line in and presses enter/carriage return
set single_barcode to every paragraph of barcodes
set AppleScript's text item delimiters to ""
repeat with thisBarcode in single_barcode
tell application "System Events"
keystroke thisBarcode & CR
delay 5
end tell
end repeat

Feel free to run it in your AppleScript editor (located in Applications on, I think, every new Mac). I have not found something like this on a Windows machine, but I haven’t really looked.

I’m a Mac fan because my MacBook has sped up my workflow considerably, and this is another example adding to my fanboy-ness. The Apple language is very easy to understand. I saved myself hours just by creating a script this morning.