Turning A List of Links Into One Link
I frequently find myself in need of sending a list of links to a friend. I’m very comfortable with keyboard shortcuts so sometimes, I just do CTRL+space – Te – enter – command+tab – command+l – command+c – command+w – command+tab – command+v – well, you get the idea. Sometimes that method doesn’t really cut it. Sometimes I don’t want to close the tabs as I work which makes the keyboard shortcuts almost complicated enough to resort to using the mouse.
So, I have a couple of other methods using Safari and Automator. Safari is usually my browser of choice anyway so this works for me.
- I created a small app using Automator that simply grabs the link from Safari and appends it to a text file. Then I use QuickSilver to call the script and then I close the tab and move on. Of course, if I want to keep the tabs open I modify this a bit but there are still less keystrokes than the method above (even when closing the windows in that method)
- I have a modified version of the app I just mentioned that creates clickable links so I can create an html page which I can then either email or post online for a friend. I use three items in Automator.
- Get Current Webpage from Safari
- Run Shell Script
I use a Python and pass in the URL as an argument.
The Python looks like this:import sys print '<a href="%s">%s</a>' % sys.argv[1]
- Run Shell Script
This one is bash
cat >> ~/Desktop/mylinks.html
-
Today I put together a third method. Last week, I learned about a service called 1link. It wasn’t quite what I wanted and in my search for better I found another service almost exactly like it – linkbun.ch. This still wasn’t quite what I wanted but both services provide an interesting benefit to the receiver of my shared link. You can read more about the services here.
I decided to throw together a method to give me almost what I wanted. Frankly, this method is not quite as useful to me as what I was already doing but it will come in handy when I want the “one link” benefit for my friends.
I start with a file with only one line
links=
Then I used Automator to build an app that does almost what my other one does, but the Python looks like this
import sys print sys.argv[1]+"%0A"
and the bash
cat >> ~/Desktop/links.txt
After I’ve posted all the links to it, I run these two lines
cd ~/Desktop; curl -d @links.txt http://1link.in/createlink > foo.html; echo “links=” > links.txt
Then I can open foo.html and click the link. This is better for me than trying to use the web-based form.
Environment Variables
Here is a quick little Python script I use to inspect environment variables.
Code Fragments and Tips
I plan to use this category to post tips and tricks – mostly as a reminder to myself. It would be nice if they are helpful to someone else too.
Data Extraction – Sports Scores
I extracted years of historical data – NBA box scores – for a private client. I also wrote a program that would extract current data as needed.
I found an unfinished version of this script over here.