Quick Hit: HockeyViz – Incredible Infographics for Hockey Fans

Steven NgDaily Debug BlogLeave a Comment

I stumbled on a game summary for a recent game involving the Toronto Maple Leafs, and was super impressed by the visualization used (see below).

I’m a much bigger fan of great visualizations than I am of hockey, so I felt that hockeyviz.com deserved a shoutout.

The chart is simple, easy to read and has a high degree of information density. Mathematician and freelance data visualizer Micah Blake McCurdy has done a fantastic job of creating these game summary infographics. In the example above, I especially love how he uses varying line thicknesses to show comparisons of how much time players spend with each other.

I don’t know how he manages to produce these for every game (I assume he’s figured out how to automate the process), but this is top notch work. Simply outstanding.

 

Quick Hit: Designing Complex Tables for the Web (Smashing Magazine)

Steven NgDaily Debug BlogLeave a Comment

For the data nerds out there, Smashing Magazine has a pretty good article on how to design complex tables for the web.

In this age of multi-sized screens, designing tables that can provide the right amount of information density is very hard.

I’ve been recently tweaking some reports for Assign It To Me, and deciding what to hide and show on small screens is no easy chore. When your users have diverse reporting needs for a project, you’re simply not going to get it right for everyone.

Quick Hit: Invisible Formatting (XKCD)

Steven NgDaily Debug BlogLeave a Comment

My favorite web comic, XKCD did a post that sums up one my biggest pains with online rich text editors:

To avoid errors like this, we render all text and pipe it through OCR before processing, fixing a handful of irregular bugs by burying them beneath a smooth, uniform layer of bugs.

In fact, stuff like this still happens with the very editor I’m using to write this post. To be fair to online rich text editors, I still occasionally get these issues with Microsoft Word, so now you have some insight into why I prefer pure text based markup styles like Markdown over WYSIWYG editors.

Power Up Your Productivity on Windows with AutoHotkey Macros

Steven NgDaily Debug BlogLeave a Comment

AutoHotkey, which is on my big list of my favorite tools for Windows post, is something I rely on daily to boost my productivity.

While I primarily use it for text expansion, it is super powerful and can do just about anything.

In this post, I’m going to give you a little taste of what you can do with AutoHotkey.

Getting Started

  1. Go to AutoHotkey’s download page, and download the AutoHotkey Installer for the current version. At the time of writing, the latest version is v1.1.30.01 – November 11, 2018
  2. Run the installer and install the software.
  3. When that’s done, create a new text file called AutoHotkey.ahk in your Documents folder. You can actually call it whatever you want, but AutoHotkey.ahk is pretty self explanatory and a good place to start.
  4. Create a shortcut of your AutoHotkey.ahk file in Windows File Explorer. Copy the shortcut to your clipboard.
  5.  In Windows File Explorer, browse to your Start Menu folder. Your Start Menu folder is usually in this location (if you’re using a recent version of Windows):
    C:\Users\{your user name}\AppData\Roaming\Microsoft\Windows\Start Menu
  6. Substitite {your user name} above with your actual Windows user name so that you get the right path. Paste the shortcut in your clipboard to this location. This ensures that your AutoHotkey.ahk file starts your AutoHotkey script every time you log into your computer.

AutoHotkey Basic Concepts

The AutoHotkey.ahk file that you created in your Documents folder is your AutoHotkey script. It will contain all the code that AutoHotkey uses to listen for input events (whether it be from your keyboard, mouse or other input device) and fire off an activity.

Currently, your AutoHotkey.ahk script is empty, but I’m going to provide you with some samples to get started with. Detailed documentation on writing AutoHotkey scripts can be found on their website.

Unless you’ve rebooted or logged in and out since installing AutoHotkey, AutoHotkey is not running right now. To launch AutoHotkey, double click on your AutoHotkey.ahk file. Even though there’s no code, it should launch. You’ll notice a small green square in your taskbar with a white H in it like the screenshot below.

Every time you save a change to your AutoHotkey.ahk file, you will need to reload the script. To do that, right click on the taskbar icon and select Reload This Script. This will load any changes you have into memory. If there’s an issue with your script, you’ll get an error message. To fix this, you’ll need to go back to your text editor, fix the broken code, resave, and reload the script again.

If you ever need to edit your script, you can right click the AutoHotkey icon in the taskbar and select Edit This Script. It will open the text editor that is bound to the .ahk file extension, which by default is Notepad.

Now that you’ve got the basics, let’s dig a little deeper.

Text Expansion

Do you ever get tired of typing out your e-mail address, or a long path/command in your Windows Command Prompt? Well, this is where Text Expansion can save you a lot of headaches.

Let’s do your e-mail address first. Paste the bit of code below into your AutoHotkey.ahk file, save, and reload it into AutoHotkey.

::@email::my.name@mydomain.com

Now, open up a new instance of Notepad, and type in @email followed by the space, period (.) or return key. You’ll notice something magical happened. @email disappeared and was replaced by my.name@mydomain.com.

That was easy! So let’s break the code down so you can understand it. Take the first part of the code:

::@email::

In AutoHotkey, the text that triggers a text replacement is called a hotstring. A hotstring starts with a pair of colons. In this case, the hotstring is @email. The last pair of colons separates the hotstring from the replacement string that will be fired. Hotstrings are fired when you hit the space, period (.) or return key.

The second part of the code:

my.name@mydomain.com

That’s the replacement text that you want to replace the hotstring.

So following this pattern: ::hotstring::replacement text, let’s create another example.

Let’s say that you’re typing in some long path to get to your development folder in your Command Prompt, and you want to use @path to trigger it. Notice that I prefix my hotstrings with an @ character.

This isn’t required, but using a special character as a prefix prevents you from accidentally firing a trigger when you don’t want it to. Let’s say you decided to use the as your hotstring. Every time you typed the with a space, return or a period (.), it would fire your hotstring. Since @the followed by a space, return or (.) is uncommon, it’s less likely to fire your hotstring by accident.

Add this bit of code below into your AutoHotkey.ahk file, save, and reload it into AutoHotkey.

::@pf::C:\Program Files

If you open up your command prompt and type in:

cd @pf

And then hit return, the command

cd C:\Program Files

Will appear and execute. Not bad! What I’ve shown you is only the basics. You can do multiline text expansion and more. Check out the AutoHotkey docs for more advanced functionality once you’ve grasped the basics.

Application Launching

Another handy thing you can do is use AutoHotkey to launch applications.

Let’s do a quick example. Paste the bit of code below into your AutoHotkey.ahk file, save, and reload it into AutoHotkey.

#z::Run cmd

Now hold down the Windows key plus the Z key. The Windows Command Prompt should launch in a new window.

So let’s break the code down so you can understand it. Take the first part of the code:

#z::

Notice that unlike the hotstrings, the command does not start with a pair of colons. Instead, we see a hash (#). The hash is the Windows key. So #z means Windows key + z. Because this command executes something instead of replacing text, it’s called a hotkey in AutoHotkey speak. The two colons at the end separate the hotkey from the command to be executed.

The second part of the code:

Run cmd

Run is a Autohotkey command which launches whatever follows it. cmd is the Command Prompt, but you can replace it with Notepad to launch Notepad.

Now the reason why cmd and Notepad work without knowing the full path to the executables is because those apps are in the PATH environment variable. If you’re trying to run an application that is not in the PATH, then you need to put the full path to the exe after the Run command.

Another trick you can do with a hotkey is to launch a URL. Paste the bit of code below into your AutoHotkey.ahk file, save, and reload it into AutoHotkey.

^!+Z::Run https://assignittous.com/daily_debug_blog/

Now hold down ctrl + alt + shift + z altogether. You’ll notice that this very blog will launch in a new browser tab/window (depending on your settings).

Once again, let’s break down the code in pieces:

^!+Z::

The special characters ^!+ are Autohotkey’s notation for the modifier keys Control, Alt and Shift, respectively. The Z represents the z key on your keyboard. The two colons at the end separate the hotkey from the command to be executed.

The second part of the code:

Run https://assignittous.com/daily_debug_blog/

You’re already familiar with the Run command. The second part is simply the URL to this blog. When you fire the hotkey, AutoHotkey will launch that URL in the default browser specified in Windows.

Context Sensitive Hotkeys and Hotstrings

Everything I’ve shown you above are global hotstrings and hotkeys. That means they fire no matter where you are in Windows.

Sometimes you want to limit where hotstrings and hotkeys can run. You can do this by creating context-sensitive hotkeys and hotstrings. It’s a little more complicated, but it’s easy to get started.

Let’s take this example from the AutoHotkey documentation:

#IfWinActive ahk_class Notepad
^a::MsgBox You pressed Ctrl-A while Notepad is active. Pressing Ctrl-A in any other window will pass the Ctrl-A keystroke to that window.
#IfWinActive

Add the code above to your AutoHotkey.ahk file, save and reload.

Open up an instance of Notepad, and hold down control+a

A popup with the message “You pressed Ctrl-A while Notepad is active. Pressing Ctrl-A in any other window will pass the Ctrl-A keystroke to that window.” should appear.

Let’s break down the code line-by-line:

#IfWinActive ahk_class Notepad

#IfWinActive is an AutoHotkey directive to set the context of an active window (i.e., an application in the foreground).  That means all hotkeys/hotstrings below that directive will apply to the context set by this #IfWinActive directive until it is closed with an empty #IfWinActive directive (this is an oversimplification as I’m trying to keep the examples appropriate for beginner level users).

ahk_class is a Window Class. To oversimplify, a Window Class is Microsoft Window’s secret name of the window. Sometimes the names are obvious (as in the case of Notepad), sometimes they’re not. Fortunately, AutoHotkey gives you a tool to figure out the name of a Window Class, and I’ll show you how to use it after I finish explaining this code.

Using plain English, the directive #IfWinActive ahk_class Notepad translates to “If the active window (in the foreground) is a Notepad window, then the following hotstrings and hotkeys will only apply to that window until I close the directive”

Now for the second line:

^a::MsgBox You pressed Ctrl-A while Notepad is active. Pressing Ctrl-A in any other window will pass the Ctrl-A keystroke to that window.

^a:: is the hotkey notation for control+a  The two colons at the end, separate the hotkey from the command to be executed.

MsgBox You pressed Ctrl-A while Notepad is active. Pressing Ctrl-A in any other window will pass the Ctrl-A keystroke to that window. — This is the command to be executed. MsgBox is an AutoHotkey command that will open up a popup with a message. All of the text after the MsgBox command is the text that will be put into the popup message.

Finally, the empty #IfWinActive closes the first directive. All of the commands below the empty directive will be global unless you use another #IfWinActive directive to specify a new context.

How To Determine A Window’s Class Name

Thanks to AutoHotkey’s Window Spy tool, it’s easy to figure out a Window’s class name.

From the taskbar, right click the AutoHotkey icon, and select Window Spy from the context menu.

A Window Spy popup will appear:

If you start clicking on application windows, the contents of the “Window Title, Class and Process” box at the top of the pop-up will change.

The contents of the box are split into 3 lines.

The first line is the Window Title, which matches the title on the top of the window bar (if your window has one). This helps you identify if you clicked the correct window.

The second line, which is the one you care about, contains the Window Class. In the example above, I clicked on a Notepad window, and the class is ahk_class Notepad. If you click on a Chrome window, that second line will probably say ahk_class Chrome_WidgetWin_1 (depending on what version of Chrome you’re using).

To create a context sensitive directive for Chrome for example, you would use this:

; lines that start with a semi-colon are comment lines and are
; ignored by the AutoHotKey script parser
; the line below sets context for Chrome
#IfWinActive ahk_class Chrome_WidgetWin_1 
; hotstrings and hotkeys go here:
^a::MsgBox You pressed Ctrl-A while Chrome is Active!
; the line below ends the context for Chrome
#IfWinActive

Now Try It Yourself

Now that I’ve given you a taste of what you can do with AutoHotkey, give it a shot!

Keep in mind, I’ve only scratched the surface of what AutoHotkey can do. It’s incredibly powerful, and I strongly suggest you take a look at the AutoHotkey docs to learn more about its features.

 

 

 

Make Your Life Easier With This Software On Your Windows Cognos Server

Steven NgDaily Debug BlogLeave a Comment

Whenever I have to troubleshoot a Cognos Server issue, I always find myself wanting or asking for permission to add some software to make it easier for me to do root cause analysis. So if you’re setting up a Cognos server on Windows, you should consider adding the following software to make your life easier when problems arise.

This post is a subset of my post on my favorite Windows software, but it applies specifically for troubleshooting problems on Cognos servers (and probably other types of servers too).

Built-In Software / Microsoft Software

  • Event Viewer – It’s always handy to check the Application and System events for errors that might be related to a Cognos problem.
  • Task Manager – Use this to identify processes that are creating CPU, Memory and Disk I/O bottlenecks.
  • Steps Recorder – While far from perfect, Steps Recorder is a handy tool that will create an HTML archive file of screenshots to document the steps you took to reproduce a problem. It doesn’t always work, but when it does, it can be very useful.
  • Process Monitor / Process Explorer – Microsoft’s Sysinternals tools Process Monitor and Process Explorer are incredibly useful for checking what files are being locked by the system, or if Cognos is able to find a file it’s looking for.

Essential Software

  • Cmder – Yes, if you like the built-in DOS prompt or Powershell, you can use that instead, but I like Cmder because it is more UNIX-like. When checking logs, you can you use the head or tail command natively. You can also use tools like curl to verify if http requests are being responded to, etc.
  • PilotEdit Lite – If you have a huge log file that you want to look at (after looking at them with head or tail), most editors are going to choke on a large file. PilotEdit Lite (you can pay for more powerful versions of this software) is handy for opening up very large log files for reading.
  • Winmerge – If you are trying to compare multiple copies of a text file, like a config file, then this is a fantastic tool.
  • Atom – While Notepad++ is the go-to text editor for a lot of people, I actually prefer Atom. It’s a lot more flexible and easier to use. The main drawback is that it has a much larger disk footprint than Notepad++, but when you’re trying to analyze a whole bunch of files at once, I find that Atom is a much more stress-free experience. Other viable tools are Visual Studio Code and Sublime Edit.
  • Chrome – This is an opinionated choice, but I feel every server needs a copy of Chrome installed. It is now the most-used browser, but it also has good debugging tools. I use Chrome’s Inspector to check that remote API requests to the Cognos server are coming back in a reasonable amount of time and to check for errors related to web server configuration.
  • DBVisualizer (Free version) – A multi-platform database query tool is always handy if you’re trying to see if a database is having problems.
  • Greenshot – If you need to take a lot of screenshots and send them to Cognos support, Greenshot is very handy because it can save some additional steps of having to paste shots into Paint, etc prior to saving.
  • Windirstat – Sometimes problems are related to drive space. Windirstat is helpful for assessing what files are taking up the most space on your hard drives.
  • 7zip – While Windows has ZIP file support built in, it’s clunky at its best. 7zip is very handy for expanding things like JAR files.
  • Keepass – If you have trouble remembering the various passwords you need to administer your server, Keepass is a good secure password manager to use.

Web Sites / Other

  • VirusTotal – VirusTotal lets you upload a file to check it for viruses against several antivirus software engines.
  • Let’s Encrypt – If you need SSL certificates for your Cognos installation, Let’s Encrypt offers free certs.