NuncaMind

Hashtag Generator

Let me preface this by saying that this is a pointless and ridiculous tool, but I did learn a few things while creating it.

Lately my friends and I have been including #RidiculouslyLongHashtagsForNoParticularReason in our text messages as well as our tweets. Many of my friends do not use camel case, which pains me as a developer. Camel case leads to much greater legibility: #thishashtagismuchhardertoread, whereas #ThisHashtagIsActuallyPrettyLegible. But typing out the hashtags can be a pain, especially on the iPhone. So, using Will Bontrager’s code as a jumping off point, I wrote my own Hashtag Generator. It’s very simple, and can only make one hashtag at a time, but it gets the job done. Also as an iPhone user I added a special exception to capitalize iPhone properly (I don’t mention iPads or any other iProducts enough to justify adding exceptions for them as well, but the code is available and adding those exceptions is pretty simple).

Type in a sentence with spaces and click submit.



This tool works quite well, but after listening to the Mac Power Users episode about Automator, I decided to try and make a service to use on my computer that would have the same functionality but be a little quicker to access. The service itself is quite simple, and as it is probably easier to recreate than download here’s an image of it:


The hashtag.py code is here:

1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/python
import sys
string = raw_input('')
array = string.split(' ')
sys.stdout.write("#")
for word in array:
  if word.lower() == "iphone":
    sys.stdout.write("iPhone")
  else:
    sys.stdout.write(word.capitalize())
print

This service will now convert any selected text into the hashtag camel case format, and then place that on your clipboard. You can then paste it anywhere. This also integrates well with Launchbar, which will prompt you for the text if you want to write your own phrase:


#Enjoy