# Setting up SublimeText 3 for Ansible

I love using Sublime Text 3 for Ansible work, especially after some minor tweaks. The packages I have installed are: Ansible syntax highlighting, ApplySyntax, Jinja2 syntax support, SublimeLinter, and SublimeLinter-pyyaml.

For ApplySyntax you want to change the user settings to contain something like the following below. It's based on the best practices for Ansible directory layout, but with one change, I prefer to have playbooks in their own subdirectory.

{
"syntaxes": [
{
"syntax": "Ansible/Ansible",
"rules": [
{ "file_path": ".*/defaults/.*.ya?ml$" }, { "file_path": ".*/handlers/.*.ya?ml$" },
{ "file_path": ".*/meta/.*.ya?ml$" }, { "file_path": ".*/tasks/.*.ya?ml$" },
{ "file_path": ".*/vars/.*.ya?ml$" }, { "file_path": ".*/inventory/group_vars/.*" }, { "file_path": ".*/inventory/host_vars/.*" }, { "file_path": ".*/inventory/.*" }, { "file_path": ".*/playbooks/.*.ya?ml$" }
]
},
{
"syntax": "Jinja2/Syntaxes/Jinja Templates",
"rules": [

# Eclipse and TestNG

I was playing around with Eclipse and TestNG, the thing you need/want to do is, after you have installed testng via de Eclipse market place and restart Eclipse to go to the project build path.

So right click the project and select from the popup menu Build Path » Configure Build Path...

In this window, make sure you have selected the Libraries tab in the right-hand side of the window.

Next select Add Library... and from the resulting window that pops up select TestNG (or JUnit).

When you select Next or Finish (depending whether you picked TestNG or JUnit), you will then see TestNG under the JRE System Library entry as another library entry. If you expand this you see the testng.jar being included and pointing to the right jar file that's in Eclipse's plugins directory.

When you now press OK you should see the imports getting resolved.

You will need to remove any external jar dependencies for TestNG or JUnit of course, because it's double and will most likely lead to problems.

Now, when you go to Run » Run Configurations... you see a TestNG (JUnit) entry. When you select that entry and create a new configuration underneath it, it should already resolve everything you need (classes, packages, and so on).

Oh, do keep in mind that you will have to mark the test folder as a source folder for it all to work. Right click the folder, select Build Path » Use as Source Folder.

# JetBrains IntelliJ IDEA and Monokai

I'm a fan of the Monokai colour scheme for my source code editing and thus set up it whenever I can in the IDEs I use.

For JetBrains' IntelliJ IDEA I use Long Cao's Monokai colour scheme. Grab the XML file and drop it, on Windows, in your %HOMEPATH%.IntelliJIdea11configcolors directory. Restart IDEA and the Monokai colour scheme ought to be present in the dropdown box under File » Settings » Editor » Colors & Fonts » Scheme Name.

# Setting up Eclipse 4.2 as I like it

Download Eclipse 4.2 Classic 64-bits version from the Eclipse website. Extract the contents to a location, such as C:Eclipse. Adjust the eclipse.ini in that directory according to my post in order to pin it to the taskbar.

Go to Help » Install New Software... » Work with, select the Juno entry and from the resulting list of software select General Purpose Tools » Marketplace Client followed by Next » Next, accept the license and Finish. Restart Eclipse when done. Now under Help is an entry called the Eclipse Marketplace.

Open the Eclipse Marketplace and search for and install the following: "code recommenders", "MercurialEclipse", "mylyn" (not selecting the Bugzilla connector). It might ask if it is OK to install unsigned content, acknowledge it.

# Pinning Eclipse to the Windows taskbar

I pin programs that I use frequently to the taskbar of Windows. So I was a bit surprised to see that the newer version of Eclipse, Juno, doesn't seem to support this by default. After some searching I find out that you can force this by adjusting the eclipse.ini by starting the file with something akin to:

-vm C:Program FilesJavajdk1.7.0_05bin

Then after starting Eclipse with this in place, you can, once fully loaded and past the splash screen, pin Eclipse to the taskbar.

# Visual Studio editor rulers

If you like to have a visual cue for, say, where the 80th column is then this page over at Stack Overflow details the various registry keys you might need to add as well as showing which extensions can do it for you. For VS 2010 Professional and up you can use the Productivity Power Tools, but it seems that Visual Studio 2010 Express has no guides support.

# Sublime Text with 80 and 120 column rulers

For many programming languages we still like to use either 80 or 120 columns in our editors to ensure it fits easily on print, as well as to use it as an aid for ensuring concise code.

In Sublime Text you can set vertical rulers for this by going to Preferences » User File Preferences and add rulers 80 120 and save the file.

For Sublime Text 2 it's under Preferences » Settings — User, but the configuration file is now in JSON format, so you need to add "rulers": [80, 120] and maybe you need to append a comma at the end if you have more configuration directives following it.

Addition 2013: in Sublime Text 3 it is still under Preferences » Settings — User and the file is still in JSON, so simply add "rulers": [80, 120], like in the example for Sublime Text 2.

# PyCharm and external lint tools

PyCharm already has a number of features present in various tools to lint/check your source code with, but offers a way to hook up external tools. Under File > Settings is a section called IDE Settings. One of the headings here is called External Tools. Select this heading and then press the Add... button on the right hand pane to configure a new external tool.

In the Edit Tool window that now appeared fill in a name, e.g. PEP8 and a group name Lint and add a description. Next point the Program to the location of the pep8.exe executable, e.g. C:Python27Scriptspep8.exe. For Parameters you need to use \$FilePath and Working directory should be filled in by default. Once done, you can close it by pressing the OK button.

Now, pyflakes has no .exe or .bat file to accompany it. You will need to add a pyflakes.bat in your Scripts directory inside Python with the following contents:

@echo off
rem Use python to execute the python script having the same name as this batch
rem file, but without any extension, located in the same directory as this
rem batch file
python "%~dpn0" %*

Within PyCharm you follow largely the same settings as for pep8, however make sure to point to the batch file of pyflakes under Program. Close the external tools configuration windows by clicking OK twice. Under the menu heading Tools you should see an submenu heading Lint which, in turn, should contain two menu items: PEP8 and Pyflakes.

Now open a Python file, go to Tools > Lint > PEP8 and you should get output like the following in your Run (4) window:

D:\Python26\Scripts\pep8.exe D:\pprojects\babel\babel\tests\__init__.py
D:\pprojects\babel\babel\tests\__init__.py:16:1: E302 expected 2 blank lines, found 1

Process finished with exit code 1


# Shobogenzo colorscheme for vim

I published my vim Shobogenzo colour scheme today. It is called Shōbōgenzō (<span lang="ja">正法眼蔵</span>) after the famous collection of Zen Buddhist fascicles (a discrete section of a book).