Categories: Utilities

Traffic Travis SEO Tool

For the last few months, I have been checking out the Traffic Travis SEO tool. Researching and investigating tools like this is part of my work as a software development project expert because I want to make sure my clients are on top of the state-of-the-art when it comes to web design, development and internet marketing.

Traffic Travis comes in a free and a pro version. The free version required a simple registration then an email was sent to me with a link to the free download. The pro version costs $97.

In November they released version 4 of Traffic Travis as a free edition and it looks fantastic. It has tools for keyword research, checking out which keywords your competitors are using and seeing which websites are back-linking to yours. It supports the Bing, Yahoo and Google search engines in different countries which is really useful if you are focused on attracting customers in your country.

Traffic Travis is a neat little tool for seeing which keywords you’re ranking at and to see which keywords are similar to yours and to see what the competition is doing with their search engine optimization strategy. I like the product and it’s very simple to use and to get started with.

The only problem I had with the free version was that some of the features that are only available in the pro version are not clearly marked. It’s jarring to be working and then clicking on something and having a big ugly pop-up box appear on the screen. Clicking on “fetch keywords” in the SEO > Competition page is an example of this. It would be better if things that require the PRO version were in a different colour or were disabled entirely. Nagging me to buy the PRO version makes me a little less likely to buy it.

I encountered a technical problem as well. Traffic Travis is Windows-only but that’s fine with me, however it requires at least Internet Explorer 7 to be installed for Google AdWords interaction. I’m a programmer and I’m sure there are other ways to use the Google AdWords API rather than through Internet Explorer. This may not be a problem for most people, but I rarely use IE and when I do use it, it’s for IE6 testing. I was not able to use the research tools due to this problem. To fix this problem I upgraded to IE8, we have other computers that have IE6 anyway.

Note: while I pride myself on using free/open source software, I do not shy away from using proprietary tools such as Traffic Travis which may help my clients and employers.

UPDATE: This book will show you how some other SEO (Search Engine Optimization) strategies and you can use Traffic Travis with those strategies.

Categories: Linux, Utilities

GNU Moe Tutorial/Review

Yesterday I was looking at a listing of updates for free software projects. I commented that the package GNU Moe could be used as a replacement for nano or zile, that is, when you need to quickly edit files from the command-line.

So today I’m giving it a go. I downloaded moe via the GNU project’s FTP server and installed it. The compilation was insanely fast, I think it took less than 10 seconds to get it all built and installed.

This blog post is a small tutorial (and a bit of a review) for using GNU Moe and is actually being written in it. I’m learning as I’m doing and this is usually the best way to learn anything. The manual for moe is, well it doesn’t exist. When you first enter moe you are confronted with a blank screen and a title bar at the top of it.

The title bar lists:

  • the command key being used (if any)
  • the current mode of the text editor, either “I” for “Insert” or “O” for “Overwrite”
  • the name of the file being edited
  • whether it has been modified and needs to be save
  • which line you are on
  • which column you are at
  • the time (in 12-hour clock with no AM/PM indicator)
  • a helpful reminder telling you to press “F1 for help”

In comparison, nano only tells you the version of GNU nano that you are using and the name of the file. Nano also helpfully lists some commands at the bottom of its screen.

Press F1 For Help

The first command key I used was of course "F1", the help key. GNU Moe uses the function keys for saving files, loading files, undo and redo, the options menu, the buffers menu and some other things which I will get into as I come across them.

The second command key that I used was Ctrl+C. If the current file being edited is Modified, it will ask if you want to “lose your changes”. If you press “n” meaning “No I don’t want to lose my changes”, it will save the file. I think this is better than asking if you want to save your changes. The way the question is posed is different and highlights the fact that you will lose whatever you were working on.

GNU Moe Gets Out Of The Way When Typing

In terms of typing, GNU Moe hasn’t gotten in the way at all. In fact, it has provided two useful command keys; Ctrl+Y which kills/deletes a whole line of text, and Ctrl+B which re-formats a paragraph by wrapping it at a certain column (I think column 72). The re-formatting is very useful when you’re on a regular terminal. Right now I’m in the shell that you get before running any desktop system. The screen can only handle 80-character columns right now. You can set the column to whatever you like in the Options menu (accessed by pressing F10).

Okay, I just pressed F2 to save the file. It asked me for a new name or location for the file, but luckily it already provides the same name as before. So saving the changes is a matter of pressing F2 and then the Enter key. You can also save and exit moe by pressing Ctrl+X. After I’m done typing here, I’ll definitely be using that, heh.

To load a file, you press F3. As soon as you open more than one file, they are loaded into separate buffers and then moe gives you access to the buffer menu. You can access it by pressing F11 and it lets you switch between the different buffers by choosing from the menu or pressing a number key. To get rid of the buffer, you press Ctrl+C.

So far GNU Moe is very easy to deal with, it all seems self-explanatory.

One thing to watch out for is the behaviour of whatever terminal you’re using. The GNOME Terminal wouldn’t let me use the function keys properly and the same was true of xterm. Another thing is the key bindings. They’re kinda like Emacs’s key chords, though not all of them are like that. There are four different prefixes for the key chords: “[“, “O“, “Q“, “S“. The first prefix is the most commonly used one, while the other three are used for special commands.

If you’re interested in IDEs rather than simple text editors, I recommend checking out PyCharm if you’re a Python developer and either Emacs or Intellij IDEA if you use other programming languages.

Categories: Life, Software Development

PLATO and the TUTOR programming language manual

I was reading a bit about PLATO, a computer system for computer-aided instruction, and it is astonishingly old. It was around in the 70s, the 80s, etc. The language originally used for creating lessons and tutorials was called TUTOR.

I’ve been extremely curious about the language since I first read about it on the weekend and I’m glad to say that I’ve found the manual.

The manual for the TUTOR programming language used on the PLATTO computer system can be found here. According to the description:

TUTOR is designed to transcend the difficulties of FORTRAN for a computer-based educational system utilizing graphical screen displays. The language consists of about seventy words or “commands”…

…authors are able to write parts of useful lessons after approximately one hour of introduction…

I bet there are a few gems in this manual. History is awesome.

What’s cool to me is that this manual is a predecessor to the interactive tutorials and quizzes that are available for online video courses, platforms like Khan Academy and Coursera and Moodle. While flashcards and quizzes are easy to create, interactive tutorials are difficult to create and there is no one dominant open-source platform for doing so. I think Khan Academy’s code is open source to some extent, but it mainly covers coding questions and math problems.

Categories: Software Development

Relative Timing With Org-Mode

I have been re-arranging my TODO lists using Emacs’s Org-Mode and when I realized that it could calculate the exact hours taken for a bunch of tasks, I felt I should explore the rest of the Org-Mode manual and see what else I had been missing out on.

Org-Mode allows you to use relative timers which, it says, are useful for recording notes during a meeting or video viewing. I did not understand exactly how to use the relative timers, but it looks like they are like timestamps. Here’s a brief run-down and example on how to use them.

Org-Mode: What is a Relative Timer?

A relative timer is one that starts at 0 hours, 0 minutes, 0 seconds. The second time you log the time, it is relative to the first time, so it will be 0 hours, 1 minute, 30 seconds if it has been 1 minute and 30 seconds since you started the timer.

When Are Relative Timers Useful?

Here’s an example. Say you are watching a conference presentation on your favourite programming language, and you want to take notes. First, you would open up a buffer that is using org-mode and find the place where you want to put the notes. Then, you must start a relative timer by pressing C-c C-x . which starts the timer and inserts the current time (which is of course 00:00:00). This timer will continue to run even while you are in other buffers.

Record the time with C-c C-x .

When an interesting point is made, or whenever you feel the need to record the time, you press C-c C-x . again. Then you just make your notes as quickly as you can!

Pause the time with C-c C-x ,

Org-Mode also lets you pause the relative timer with C-c C-x , though I am not sure when you would want to use this. Maybe if the presenter is taking a break or if you were taking a break when watching a video?

Stop the Timer With C-u C-c C-x ,

Finally, to stop the timer, you press C-u C-c C-x , (which is basically just adding a prefix argument).

Here is a sample Org-Mode relative timer file:

* My Awesome Language (presentation)
0:00:00 Start of presentation
0:05:33 5 minutes in and we hit some interesting points
I don't know, Ruby as your Awesome Language? Ugh.
0:06:04 Oh good, he mentioned Python! But where's Lisp?!
0:06:26 jerk skipped over the Lisp slide...
I don't get why people *always* skip over Lisp :-(
0:07:35 Well that was a short presentation (thankfully)

That is the trouble with Emacs and its modes. There are so many useful functions contained that it is hard to use them all or to even know about them unless you read through the manual.

Interested in other Emacs modes? Check out some of the ones I’ve written:


Categories: Software Development

Composable Regular Expressions and Fields

Martin Fowler wrote a brief article about composing regular expressions in order to make it easier to deal with individual “tokens” and to give them structure.

As noted by a reddit commenter, string constants can be a bit unwieldly to deal with and will break. Scheme Shell solves this problem with an s-expression-based structure syntax of regular expressions called SRE. You can click that link to read more about it, but what I’ll do here is convert Fowler’s example to some SREs to show how much more useful structured regular expressions are when you use them in a Lisp-like language.

His structured pattern in the Java language looks like this:

const string scoreKeyword = @"^scores+";
const string numberOfPoints = @"(d+)";
const string forKeyword = @"s+fors+";
const string numberOfNights = @"(d+)";
const string nightsAtKeyword = @"s+nights?s+ats+";
const string hotelName = @"(.*)";
const string pattern =  scoreKeyword + numberOfPoints +
  forKeyword + numberOfNights + nightsAtKeyword + hotelName;

He also has an alternative method that joins strings with whitespace:

private String composePattern(params String[] arg) {
  return "^" + String.Join(@"s+", arg);
const string numberOfPoints = @"(d+)";
const string numberOfNights = @"(d+)";
const string hotelName = @"(.*)";
const string pattern =  composePattern("score", numberOfPoints, 
  "for", numberOfNights, "nights?", "at", hotelName);

Here is what that looks like in Scheme Shell:

(define number-of-points (rx (submatch (+ digit))))
(define number-of-nights (rx (submatch (+ digit))))
(define hotel-name (rx (submatch (* any))))
(define s+ (rx (+ whitespace)))
(define pattern (rx "score" ,s+ ,@number-of-points ,s+ "for" ,s+ ,@number-of-nights ,s+ "nights?" ,s+ "at" ,s+ ,@hotel-name))

Now that I’ve written that out, it looks cumbersome. It wasn’t a huge pain to type out, but all of that whitespace matching looks redundant and I can see why Fowler wrote up the composePattern function.

Let’s try treating this problem differently by assuming that the important data is separated by whitespace, and let’s call the stuff that’s in between the whitespace a “field”. By doing this, we no longer have to use regular expressions. We can now use a tool like AWK or something else to split each string into some fields and then look at each field and turn it into the appropriate data type.

Here is my Python solution:

# fields:    0    1   2  3   4     5   6     7       8
example = "score 400 for 2 nights at Minas Tirith Airport"
fields = example.split() # Python assumes whitespace as the delimiter
numberOfPoints = int(fields[1]) # 400
numberOfNights = int(fields[3]) # 2
hotelName = ' '.join(fields[6:])   # 'Minas Tirith Airport'

There might be a slightly better solution that treats the hotel name differently, but it doesn’t really matter. The point is that this is no longer a problem that requires the use and composition of regular expressions.

Categories: Life

Trying out Compass, a CSS Framework

[Update: 17 November 2018…it’s amazing to look back at this blog post from 2009 and see how much things have changed near the end of 2018. Right now we no longer use CSS frameworks; the last standing framework is Bootstrap, with CSS being written in whatever ways necessary to make React, Angular and other JavaScript SPA (Single Page Applications) look great. The SASS language for CSS now looks like pretty much like CSS and doesn’t rely on indentation by default with SCSS files. Some projects use SASS and Bootstrap supports it. What’s really changed is that I find it very useful to use Stylelint to lint CSS files.]

A week or so ago I decided to finally sit down and try out the Compass CSS framework. When I first looked at it, I was dismayed to find that it required Yet Another Language to learn, but then I quickly saw its advantages when I started using it.

The Compass CSS framework aims to be a real framework that does some heavy-lifting to let a web designer focus on CSS. It compiles a language called SASS into CSS and uses modules to allow integration with other “plain” grid-based CSS frameworks such as YUI GridsBlueprint, and 960 Grid System.

The SASS language is indentation-based and is similar to YAML. When Compass is run, it generates CSS files from the SASS files. This lets SASS provide all sorts of nifty things, such as inheritence, mixins, functions and variables. Inheritence and mixins are important because you can define a general border style, such as a left border that is solid thin and black, and then apply it to whatever CSS selectors you like. Then when you make a change to the border style, you only have to make the change once instead of finding/replacing the styles in all the selectors.

When trying to learn Compass, I decided to convert an old stylesheet to SASS. I wrote less than 100 lines of SASS to generate over 400 lines of CSS. On top of that, I used variables for different colours and added/subtracted to those colour values to generate new colours. Instead of finding/replacing and manually calculated, SASS took care of both of those things.

SASS functions let you calculate things based on the input that you give it. Just like functions in any other programming language. SASS mixins let you combine various styles under a CSS selector.

An example of the SASS syntax:

// example of a variable
!titleColor = #a3a

//example of a mixin/function
  :font-size = (!a + 10) "px"

// inherited css selectors
  color: blue
    :color black
    :color purple

// more inheritence
    // color variable
    :background-color = !titleColor
      // mixin/function call
      :font-family sans-serif
    :background-color = !titleColor + #505
      :font-family serif

And here is the CSS output that was generated by SASS:

a {
  color: blue; }
  a:hover {
    color: black; }
  a:visited {
    color: purple; }

body #header {
  background-color: #aa33aa; }
  body #header #blog-title {
    font-size: 32 px; }
  body #header #description {
    font-size: 18 px;
    font-family: sans-serif; }
body #content {
  font-size: 19 px;
  background-color: #ff33ff; }
  body #content #blog-post {
    font-family: serif; }

You can see how the selectors are nested and inherited. You can also see how the font-size of the various elements that used the minSize function were generated. The best part is the addition of two colours to create the colour for the body #content.

Basically, to summarize why you would want to use Compass:

  • SASS lets you use variables and functions to generate CSS
  • SASS lets you mix styles with different CSS selectors
  • Compass has plugins and modules to support the grid-base frameworks like Blueprint

This was a short post, mainly because as a programmer, the idea of variables/functions and a proper language for generating CSS is instantly appealing. So I’m hoping to create a module/plugin or plain template of my own for the MovableType blogging software and I’m attempting to convert templates and themes to use Compass to learn more about Compass and to improve my not-so-great web design skills.

Categories: Software Development

How I used Magritte, Seaside, and Smalltalk for a class project

For a computer science class, I built a Smalltalk-based web app using the web framework.

In the Human-Computer Interfaces class I have been taking for the last few months, I had to write up a software prototype for a restaurant ordering system. The goal was to design a user interface that allowed a customer in the restaurant to use their iPhone or some other smart phone to quickly order food.

For this prototype, I used Squeak Smalltalk, the Seaside web framework, and the Magritte meta-description framework.
Continue reading “How I used Magritte, Seaside, and Smalltalk for a class project”

Categories: Utilities

Emacs Tip: Word counting with a regular expression

Here’s a word counting function for Emacs that counts the number of words in a buffer by using a regular expression:

The regular expression matches against one or more word characters. It doesn’t move the current point of the buffer so you don’t have to keep re-positioning the cursor every time you run this function.

The reason I’m posting this is because I was searching for “emacs word counting” and the forums and StackOverflow suggested using the “wc” shell command while in Linux, but at the moment was developing in Windows! How can I use it? (Update in 2018: Windows now has an Ubuntu Linux subsystem that allows the use of the wc word counting command). Another thing I found is that people write up functions that loop through words and count them. I’m guilty of doing that, but using the above function is much much easier.

Emacs has most everything that you can think of. The problem is that it’s all hidden away somewhere and you have to take the time to dig around.

Update: The how-many function is defined in replace.el. To find out more about it, press C-h f how-many RET.

Categories: Web Dev Training

Django File Uploads: Validating File uploads in Django 1.0

While working on Clapton, the Django-based Content Management System (CMS), I had to write validation code for file uploads. This is needed because Clapton contains applications specific to media types such as documents which requires Word Documents, PDFs or OpenDocumentFormat files, and podcasts which requires MP3 or OGG files. But how do you guarantee that the right files are uploaded? By using Django’s custom fields and newforms module.

The following code creates a DocumentField class that only accepts Word, Text, RTFs, HTML, PDF or ODF files:

When a DocumentField object is used in a custom form and the form is being validated, the clean method is called.

First, it calls the FileField‘s clean method which validates the field using the FileField validation criteria. Then it constructs two tuples file_types and file_exts containing the valid content-types and the valid file extensions. The data argument is check against the content-types, which are taken from the IANA MIME Media Types page (content-type information for files is sent along with any HTTP file upload).

Quite simple. To turn this into an image validator for PNG files, change the file_exts to ('image/png') and file_types to ('.png').

Just toss that code into your application file, create a custom form and insert the field and that’s it.

Click here for more information on the Django Forms API.

Interested In Other Django Topics? Check This Out

Categories: Software Development

TaskScheduler Domain Specific Language converted to Lisp

Oren Eini has written a DSL that uses the Boo language and does a bit of sub-classing. This was in response to a reply to one of his posts by a blogger named Tim Wilde. The purpose of a domain-specific language is to make it easier to talk about the domain. The DSL written is written for the domain of scheduling tasks. Instead of typing out the following:

myTask = new Task("warn if website not alive", (3 * 60), ... )

You would type out:

task "warn if website not alive" every 3 minutes starting now ...

It’s more readable for other users and it hides details that are unnecessary when talking about the domain.

Tim came up with a C# variant which had roughly 250 lines of code, 8 classes and 6 interfaces. Over-kill in my opinion. Oren came up with something that makes the DSL look cleaner and it uses the Boo language.

Oren says,

There are several interesting things that are going on in the DSL. For a start, we are using Boo’s ability to drop parenthesizes if needed, which gives us a more “keyword” feeling. Another interesting approach is that when the last parameter of a method is a delegate, we can use just create a block and use that as a way to create the delegate.

The keyword feeling is fantastic. But it can be taken much further. Much much further. Lisp comes with very powerful macros that can be used to write DSLs and DSLs have been written in Lisp since before I was born in 1987. Being able to create a DSL by extending a language is nothing new. This is why I’ve implemented my own version of the above DSL in Lisp

My Implementation

Warning: I’m using the Scheme dialect and the MzScheme implementation. I’m using the MzScheme thread library instead of the official multi-threading extension to Scheme.

My implementation uses Scheme and the syntax-rules pattern language. I didn’t much like it but now I am getting used it and may use it more often than the Common Lisp defmacro method. I have no idea exactly what the differences are since I am Lisp beginner, but I was able to use Scheme to write an implementation of this DSL in less than 30 minutes.

The code consists of 3 functions: 2 are placeholders, the other one converts whatever time is given into the equivalent amount in seconds. So, 1 minute turns into 60 seconds and 3 minutes turns into 180 seconds. This is used with the sleep function in each task’s thread which controls how long to wait until the task is executed again.

The 2 Patterns Detected

The code also includes 1 syntax definition that has 2 similar patterns that it can match. The 1st pattern is triggered when the task is not starting immediately. An example:

(task "warn if website is not alive"
      every 3 seconds
      starting in 5 seconds
      when (not (website-alive? ""))
      then (notify "" "server down!"))

The 2nd pattern is triggered when the task is starting immediately. This is triggered when the keyword “starting” is followed by the word “now”. The above example re-written to start immediately.

2 Interesting Things

Two interesting things that you must know about this code: literals and named let. Literals are using in the syntax-rules pattern language and are the 1st argument to the syntax-rules call. Literals allow us to include keywords in the pattern, such as now and when.

The other interesting thing is the used of the named let. This is when the 1st argument of a let call, a literal, is the name of the “function” created. The 2nd argument is the list of parameters which can include default values that the “function” will be called with. A named let is typically used to add a recursive loop in the middle of another function.


The download is available here. The code for this domain specific language is very short: 59 lines including comments. It uses no classes and no interfaces. Some ideas for improvements include hooking into a task/thread list so that tasks/threads can be killed or retrieved later on.

Lisp can be used as well and can be more concise than other languages. Domain specific languages are not a new idea and I am happy that software developers are finding great uses for them.