Blogs

Code editor: Sublime Text 2

I have been looking for a decent code editor for a long time, as my favourite was previously Smultron but it's been slewed with problems in newer OS X releases ever since it was discontinued (and then subsequently forked and re-started as a closed-source application). I tried Eclipse, TextWrangler, Coda, and Xcode at different times but each had little things that I didn't like about them so I kept putting up with Smultron's little glitches.

I came across this thread in r/apple on reddit that suggested Sublime Text 2 and I absolutely recommend it to everyone! I have been using it ever since I first installed it.

The UI is very simple and clean and there's no button toolbar giving it a minimalistic feel (which I prefer in text editors; this is where Eclipse failed me). I should also mention that the whole program is very snappy and it responds very quickly to any query, even complex regex finds across several files or editing large files.

It has some really nice features (some very unique) which are worth mentioning (for simplicity's sake I use Ctrl below as the modifier of choice, on OS X simply substitute with Command):

Cross OS with per-user license

This strictly speaking isn't a "feature" but it certainly is worth mentioning. ST2 merits its $59.99 pricetag based on its features alone but what makes it even more attractive is that it runs very well on Windows, OS X and Linux with portable editions available and the licensing is per-user... Use it at work, at home, on the go, on any number of your computers with any OS. Oh, and did I mention you can even sync your packages & settings across all these machines and OSs via Dropbox? Awesome sauce.

Multi-line editing

After trying it in ST2, the feature now seems so obvious and natural that I wonder how I ever got by without it. Each line receives to receive its own cursor and copy/paste buffer, so you can very easily perform multi-line edits or variable renames. There are also several ways to create several cursors:

  • Select a block of text and then use Ctrl+L to select the whole lines, follow up with Ctrl+Shift+L to split each line give each selected line its own cursor.
  • Hold Ctrl and click where you want to place a new cursor
  • Highlight a text symbol (variable, associative array index or other) and matches will be highlighted. Press Ctrl+D to select them in sequence
  • Open the Find Text (Ctrl+F) and enter your query then click Find All

There's a good animated demo of this feature on the ST2 homepage.

Command palette

Press Ctrl+Shift+P to bring up the Command Palette, where various ST2 or plugin actions such as setting file syntax, changing themes, inserting code snippets. The menu updates as you type and displays the best matches to your query. Enter confirms and Esc cancel.

It is particularly handy for add-on packages, as a package may provide some custom snippets or git integration (yes, you can diff and commit)!

Function search

Hit Ctrl+R and start typing a part of a function name. ST2 will filter through all function names in your file and jump to the best match as you continue typing. Enter dismisses the search, Esc cancels.

Package management

ST2 has built-in package management via the Sublime Package Control extension. Simply copy the command from the page and enter it into the Console (opened via Ctrl+`) and it auto-installs. From there, hit Ctrl+Shift+P/Command+Shift+P to install, list or remove a slew of extensions right from with ST2 itself. There's even no need to restart it after installing or removing a plugin, it reloads what's necessary to get you going straight away.

Build system

Although ST2 is a text editor, not an IDE, it does have limited support for compiling & running files directly from within the editor. Its pluggable build system system allows add-ons to supply details on how to compile or run different file types. Ctrl+B runs the one associated with the current file type/syntax. SublimeREPL is a great extension that provides a build system plugin and can also run interpreters as a new tab inside ST2.

Extremely customizable preferences

The ST2 preferences file is simple a JSON-like file where you place the parameters. Getting it set up the way you like may be a bit tricky since there is, at the moment, no preferences UI. That said, ST2 is one of the most flexible text editors I have encountered and practically every aspect can be tweaked provided you can find the configuration parameter's key name.

Edit single file in many places

Smultron had this feature as well but it was horribly buggy so I never was able to use it much... It works flawlessly in ST2. Just select File > New View Into File... and it opens up a new tab of the current file. You can view and edit in different portions, both buffers update simultaneously and undo/redo history works across views into the same file.

Layout customization

Alt+Shift on Windows or Command+Alt on Windows allows you to layout the window in various configurations such as right/left or top/bottom. Triple column/row or 2x2 grid modes are also supported. These prove to be very useful in combination with the multi-view feature mentioned earlier, as you can setup to have 2+ views editing same file at different locations in a single window.

Rating: 

Solving the IRQL_NOT_LESS_OR_EQUAL BSOD on UEFI motherboards with two GPUs

Gigabyte recently released a UEFI BIOS (which is awesome, by the way) for my GA-Z68A-D3H-B3 motherboard and so far it's been working really well. However, I noticed that Windows was having some problems starting my dedicated graphics card after the BIOS flash; the i5's integrated HD 3000 graphics work fine, but my nVidia card said "This device could not start" in the device monitor and its display output was dead.

After reinstalling Windows 7 64-bit in EFI mode, things were running a bit more smoothly as the device was now properly detected but missing drivers. After installing the HD 3000 and GeForce drivers, I rebooted and immediately got a BSOD: IRQL_NOT_LESS_OR_EQUAL.

For those in the same situation, fortunately it can be solved very easily: don't install drivers right away. Instead, perform Windows Update repeatedly until you have SP1 installed. SP1 seems to resolve the device driver conflict that occurs and then both the integrated and dedicated GPU drivers can be loaded simultaneously.

Reference: http://communities.intel.com/thread/20515

Rating: 

Reset sync history in OS X Lion without using iSync

In previous version of OS X, the iSync application could be used to reset sync history. This technique often resolved a bunch of miscellaneous bugs and sync-related problems. The iSync application has since been removed in OS X Lion and Apple's support documents aren't of much help. This one claims that resetting sync services can be performed from iSync in Leopard and from the Sync menu extra in later version of OS X. This document describes how to enable the menu extra in the MobileMe settings. Besides the fact that MobileMe is deprecate and no longer in use, the option described in that document to enable the Sync menu extra only appears after signing in to MobileMe... Which is deprecated.

Fortunately, there's a hidden folder you can open to enable any menu extra manually! Open Finder and select Go > Go to Folder (or press Command+Shift+G). In the prompt that appears, type: /System/Library/CoreServices/Menu Extras/. This should bring you to a folder with a bunch of menu extras that you can double-click to add to the menu bar. The one of interest in this case is Sync.menu, which should appear in your menu bar a second or two after opening it.

Once it's in your menu bar, hold Alt/Option and click on it to expose the advanced options and click "Reset Sync Services". After that's done, you can remove it from your menu bar if you'd like by holding Command and then clicking & dragging it out from the menu bar.

Rating: 

Keyboard not present; press F1 to continue.

I've gotten ^ this error ^ multiple times while booting up a client's computer for troubleshooting and forgetting to plugin a keyboard. I chuckle every time.

Blizzard Entertainment's support system seems to follow a similar design philosophy. I recently went to my friend's place with my PC to play some games and when I tried to sign on to Diablo III I was informed that my location did not follow my regular usage pattern so my account had been locked. I was genuinely happy and impressed that Blizzard was proactively protecting accounts from hack attempts, but that happiness faded quickly when I tried to unlock my account.

To unlock it, I needed to reset my password by either answering my secret question or entering the first 6 keys of one of my Blizzard games attached to the account. Easy, right? Well, I don't have any of the CD keys; I purchased my copies online and so the keys are all saved in my Battle.net account game listing, which I was locked out of. Blizzard, in their infinite wisdom, also decides does not send you the game key in the online purchase confirmation email so this reset option is not viable if you've made online purchases. I proceeded to answer my secret question instead and their page says I would receive a confirmation email shortly. Cool.

I waited, and then waited some more; nothing came in. I checked my spam, nothing in there either. I even opened up my server logs and checked all incoming mail only to find nothing from Blizzard at all. Blizzard hadn't sent the message.

My next logical step is to submit a trouble ticket with their support team, so I went to the trouble ticket manager and it asks my to type a few words related to my problem. I enter 'can't login'. It offers me a few suggestions (including the password reset page which doesn't send emails) and then says if my issues are not resolved to sign in to create a ticket. Wonderful. So (1) I am locked out of my account, (2) the system detects this and (3) their recommended course of action in this context is to sign in to my account.

I try their phone support and find out that not only are they busy, but their hold queue is full so they are refusing to take my call. I tried calling a couple hours later with the same result. That brings us to today, where my calls are still being refused. Here's a really easy solution Blizzard: hire more support staff.

I've also tried email support@blizzard.com and got a response saying that the address is ignored and to sign in to create a ticket. Fail.

I'm normally a patient person when it comes to this type of thing, because as a software programmer I understand how complex maintaining a beast like battle.net can be. But it was entirely Blizzard's chose to remove single player play from the game in favour of online connectivity to reduce piracy. I get that, and I'm okay with that, but Blizzard has to keep up its end of the deal too. Account hacks are not my problem. I use a strong password and I shouldn't have to worry about getting my SINGLE PLAYER game account locked. If your system is under automated attack, find a way to fix it without inconveniencing your players. Otherwise, I'll take my money elsewhere.

Update 2012-06-25: After finally getting a response on a ticket submitted from my brother's account, they told me I would have to call in. *sigh* I'll just find another game to play for two weeks because realistically I'm not going to speak to anyone before then.

Rating: 

New additions

Just a quick heads up, I wanted to let everyone know that I have added social media sharing buttons at the end of each post as well as enabled a new comment notification system so that you can know when I or someone else has replied to your comments.

By default notifications will only be sent for responses to your comment thread; you can also opt out entirely from the feature when posting a comment simply by unchecking the box.

Rating: 

The US media industry has it backwards

I'm sure I've blogged about it at some point before, but I sincerely believe that the US media industry (particularly, the RIAA and MPAA - collectively the *AAs) have way too much lobbying power and are using their lawyers in substitution of adaptation.

This hilarious TED talk called 'Copyright Math' by Rob Reid just about sums the entire story up. They refuse to change their business plan to meet customer's new needs and then proceed blame any potential lost profits (which were determined based on outrageous projections to begin with) on rampant piracy online and copyright infringement.

Anyways, I'm blogging about his because I just saw this article on TorrentFreak: Student Fined For Running Movie & TV Show Subtitle Download Site. This student had a website where people could upload subtitle files that they themselves had translated, resulting in a movie subtitle database with translations for various local language dialects. Sounds great, even for the copyright owners, right? This community site is offering a way for people who would otherwise not be able to enjoy the movie to view and understand the movie. That means more people consuming the media and more (yes, legitimate) content buyers. That's more money in your pocket, *AAs.

The movie studio's reaction to this? Sue the site owner of course, even after he took it offline willingly.

Hey, *AAs, I'm going to let you in on a little secret. If people are turning away to other services, that's because yours is lacking something. If people are mass pirating your content, that's because the pirates gives a better user experience than the DRM, ad-encumbered media we paying customers have to deal with. And most importantly, if you cut off sites like these and don't cater to that user base, then you're just losing potential revenue. Stop blaming it on piracy. This one's entirely on you.

Edit: A Slashdot story linking to an article called Game of Thrones Crowned Most Pirated TV-Show of the Season just came in... Yet another great example of this concept. Game of Thrones is a excellent TV series but in order to watch it HBO mandates that not only do you subscribe to a cable subscription, but also that you buy HBO on that cable subscription. You cannot pay for HBO Go on its own, nor can you get the media from other digital distribution networks such as the iTunes Store until the next season starts and HBO releases the entire season to DVD/Blu-ray/online distributors (relevant: this Oatmeal comic). HBO's stance on things is that watching TV over the Internet is a "temporary phenomenon"... Yeah, sure.

Rating: 

GEMS at Apps for Energy

** Vote for us here! **

At my work we have been developing a new website called the Green Energy Management System (GEMS) that targets small businesses and helps them perform quick and cost-effective self-energy audits. With the results, they are able to determine their estimated cost savings as well as view recommended energy conservation measures (ECMs) to help lessen their environmental impact.

We have submitted the project in the Apps for Energy contest and could receive additional funding for development if we place! If you have a minute please vote for us, it would be very much appreciated!

Rating: 

Printing ODT documents from the command line (and mass PDF exporting)

I recently had to print a collection of documents I had created over the year and I really was not thrilled at the prospect of having to open the file, Command+P, Enter, Command+W, Command+Tab, open new document, rinse, repeat for some 60 odd documents. All the documents in question were ODT documents created using either OpenOffice or LibreOffice, depending on how old they were.

A bit of research on command-line printing using OpenOffice and LibreOffice led me to some outdated posts that didn't quite give me the information I was looking for, but gave me a good place to start: the Writer application's binary is named 'soffice' and accepts various command-line arguments. A quick search revealed that the file does indeed exist inside the OS X application file:

$ find /Applications/LibreOffice.app -name soffice
/Applications/LibreOffice.app/Contents/MacOS/soffice

(for those that don't know, OS X applications are actually just plain folders that hold the application's metadata, executables and related files)

What's even better is that LibreOffice now has an option to do exactly what I was looking for:

$ /Applications/LibreOffice.app/Contents/MacOS/soffice -h
LibreOffice 3.5

Usage: soffice [options] [documents...]

Options:
--minimized    keep startup bitmap minimized.
[...]
--print-to-file [-printer-name printer_name] [--outdir output_dir] files
      Batch print files to file.
      If --outdir is not specified then current working dir is used as output_dir.
      Eg. --print-to-file *.doc
          --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc

Using the "--print-to-file" parameter will convert any document that LibreOffice can read into a raw postscript file by the same name.

Although I could easily send the resulting PostScript files to the printer using CUPS' lp utility, I wanted to take this one step further. Each of these documents contained the same colour logo and I wanted to avoid wasting any ink. Another search brought me to this question on SuperUser.com, where ysis's answer demonstrated that the gs (GhostScript) utility can do this and even merge all the documents into one file:

gs -sOutputFile=converted.pdf -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibiltyLevel=1.4 -dNOPAUSE -dBATCH input1.ps input2.ps input3.ps

After about 30 seconds of processing all of the 60 files were there, in blank and white, concatenated into converted.pdf. Printed it using OS X's Preview application using the "fast draft" setting and I had all my 60 documents printed with minimal ink used in less than 5 minutes!

Rating: 

Disable Time Machine's local snapshots feature

Lion introduced a new Time Machine feature the OS would automatically create local snapshots of files so that even without a backup disk attached, you could still enter time machine and recover or undo changes to certain files. As your disk space becomes low, this space is automatically freed and the rate of snapshot creation is reduced.

This is great on desktops and I would assume the newer Macbook Pros that have better disks, but on my older MacBook Pro I've noticed that Safari has had trouble loading web pages and during this time, I hear the disk thrashing for about a minute or so and then all of a sudden the page loads. After a bit of researching and some help from the 'fs_usage' command, I discovered that a process called 'mtmd' was accessing the filesystem often and it turns out that mtmd is responsible for creating these local time machine snapshots. A quick Google revealed how to disable the local snapshot functionality:

sudo tmutil disablelocal

We'll see if that helps the disk thrashing! I did immediately recover 1GB of disk space though which is a good sign.

Rating: 

Twitter Integration

After giving it some thought, I think I am going to try and integrate my Tweets (@stewartadam) with the blog posts here since my blog posts tend to be lengthy or technical posts one in a while with nothing in between. I tweet about once a day or so, so even if it's not much at least there will be some new content consistently when you check back to the homepage! Thoughts? Module suggestions? I know that this is easily possible with Drupal, but I haven't begun looking into competing modules yet. If you've done something similar I'd love to hear about the module you used and what you think about it overall.

Rating: