Do you need to insert the current Date and Time in your documents?

This is an AppleScript that inserts the current Date and Time in any document you are working on.

Applescript

The script acts like Emacs with C-u M-! date or with vim‘s :r !date.

First of all I wanted the script to work across all my GUI apps in Leopard. So I resorted to AppleScript. After fiddling for a while with the grammar of the language I came up with a solution. The only problem was that I couldn’t launch the script from a keyboard shortcut.

Use Quicksilver to trigger Applescript

Luckily, quicksilver has triggers that you can configure to do almost anything. I mapped Shift+Command+- (hyphen) to run the AppleScript bellow. As a result, the script copies the current Date and Time to the clipboard and then asks the foremost application to paste it.

This works well and is cool to have the date on the clipboard for future pastes if I want. This is great keystroke saver for working with log files! Just use Script Editor and put it in your User Scripts Folder! A time saver!

-- Insert Date and Time into your documents
-- @2012 David Rodrigues
set date_ to ((current date) as string)
set the clipboard to the date_
tell application "System Events"
	set frontmostApplication to name of the first process whose frontmost is true
end tell
tell application frontmostApplication
	activate
	tell application "System Events"
		keystroke "v" using {command down}
	end tell
end tell

Playing with A* Updated

A* algorithm

Just updated the Playing with A* algorithm app so that now one can toggle on and off the use of the heuristic and the use of a cross product tiebreaker. This leads to new variants of the algorithm, mainly the well known Dijkstra algorithm.

This A * application was written in Java, so you’ll need to check your java permissions to run it. You can download the .jnlp file and run it from your computer.

The A* Algorithm (A star) is a pathfinding and graph traversal algorithm. It is widely used in computer science, games, robotics and network science. A thorough overview of the algorithm can be found in Introduction to A* which presents several comparisons and illustrations on the mechanics of the A star algorithm.

Google Reader: Hit “f”, Hit “j”,”j”,”j”, enjoy

I had complained before about the new Google Reader stylesheet  but now I’m starting to get the grips around it by just using the full screen mode.

Hit “f” and then scroll through the posts with “j” (down) and “k” up as in VIM.

In any case the solution isn’t elegant! In wide screens the lines tend to get “a bit” too long. There should be some kind of hack that would make each line around 11,15 words maximum or alternatively a 45-75 characters limit extending it possibly to 90, if the user chooses to. This would make reading on the google reader a more pleasant experience and follow some of the typographic recommendations on the size of each line.

Why is google so good at hacking things together and then not paying attention to the little details?

Playing with the A* Algorithm

A star algorithm

In computer science, A* (pronounced “A star”) is a computer algorithm that is widely used in pathfinding and graph traversal, the process of plotting an efficiently traversable path between points, called nodes. Noted for its performance and accuracy, it enjoys widespread use. [Wikipedia]

My implementation uses a tie-breaker based on the cross product of the vectors from the start to the target and the evaluated node and the target.

The A Star App was coded in java. If your browser doesn’t run java you can download the A Star Jnlp file and run it from your desktop.

Bye G+, Hello again Twitter

After some time using G+ I’m starting to find that the platform, although good, isn’t great! Why doesn’t google get social platforms? Can’t understand. I’m finding myself back more often to twitter, and I’ve even moved my name domain (www.davidmsrodrigues.com) from my G+ profile page to my Twitter profile! That’s life!