Ancelyn: Geek's text expansion/ generation toolkit

Visit http://www.harshadsharma.com/e/ancelyn for updates

Problem: I hate to repeat myself, which is also one of the the reasons why I have a blog ;-) Anyway, so I have to type in similar stuff all the time… name, address, email, signature, ssh/gpg public key, licenses for software/images, copyright notices, short snippets of html for posting on forums, canned email replies that are personalized… and the list goes on.

I searched for a solution, found many that came close enough, but not quite fit my needs (you know this drill) so I created my own ;)

I've named the software Ancelyn, that mean's 'Knight's spear attendant', a feminine form of 'Lancelot'… and Ancelyn, the software you are about to see does exactly that: Lets you choose your weapon from your collection of texts and scripts.

Here's how i did it and you can too…

First let me explain how this works, I have a folder that holds a bunch of txt and py files… these are plain text and python files, respectively.

Screen_shot_2011-05-31_at_3

Have a look at a txt file:

Screen_shot_2011-05-31_at_3

And a very simple python file:

0screen_shot_2011-05-31_at_3

So my script installs as a "Service" in MacOSX, and can be summoned with a keystroke from just about any native Mac program… and then it shows this:

Screen_shot_2011-05-31_at_3

Suppose you type in 'thanks' and hit enter, the text from the file 'thanks.txt' will be inserted at cursor. In case you type in 'hello World' … 'Hello World' will be inserted at cursor.

First preference is to text files, if not found, it tries to run a python file by the name of first word… here: 'hello' and passes the whole text as 'arguments' to the script.

Here is the automator service script:

Screen_shot_2011-05-31_at_3

In Snow Leopard: Start Automator, select 'Service' and then figure out rest of stuff… it is right in front of you (above)

Make sure you set the right directory in the script above.

Screen_shot_2011-05-31_at_3

Once you've saved it, the service will show up in System Preferences

Screen_shot_2011-05-31_at_3

Assign a keyboard shortcut by double clicking on right side of the name and you're done!

Now for something more complex… a script that generates basic html tags from information I supply…

1screen_shot_2011-05-31_at_3

So 'html img foo.com/bar.png' will be converted to '<img src="foo.com/bar.png" />'And 'html a example.com' will be converted to 'example.com'

Use your imagination :-)

Also, use the attached files if you like…

Click here to download:
Snippet.zip (79 KB)

Click here to download:
Examples.zip (2 KB)

 

Dedication: Hey Ankita, this one's for you!

 

License:

# Copyright (C) 2011 by Harshad Sharma
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

Software: Torrent Finder

(download)

Sometime in the near future, I want to queue torrents for downloading via email/chat/sms, which are picked up by my workstation for downloading. The whole setup will be fairly complex, so I'm working on smaller components - first being able to get a torrent file form given keywords.

First thing to do is search if someone else has solved your problem, I found this: http://danfolkes.com/2008/02/06/torrent-search/ . It gave me direction and ideas to begin writing code.

My current script looks nothing like it though, and can be used as a library to get list of torrents, their seeders, size and comment count. Do note that this will break when the site changes design.

If run as a standalone, tfind.py simply takes in command line arguments, performs a search, gets the torrent url, downloads the file in current directory and exits. No fuss, no questions.

You can grab app/source code here: https://bitbucket.org/hiway/torrentfinder/

I'll leave you with a quote: "You are what you don't automate."