Twitter Archive Alfred 2 Workflow by David Ferguson

 

I half-jokingly asked David on Twitter to make an Alfred 2 (Beta) workflow that could quickly search Twitter’s new downloadble tweet archive, but knowing he is a busy guy I didn’t really expect him to make it. However David came through and really delievered on another excellent add-on to Alfred.

 

This Twitter Archive workflow is easy to configure and simple to use. Just install the workflow and run the import command including the folder path to the csv data like in the example below.

 

 

The workflow will generate its own SQLite database of your tweets, making search lightning fast. Selecting a tweet from the search results will open it in Twitter.com or you can hit CMD+C to copy the URL to your clipboard. It works flawlessly.

 

 

Download the Twitter Archive workflow

Also, be sure to check out his blog http://dferg.us which is updated regularly with tons of Alfred goodies and follow him on Twitter @jdfwarrior.

Gitfred: An Alfred v2 (beta) Workflow for GitHub

Alfred Mega Supporters are currently rejoicing the first beta release of Alfred v2. One of the long awaited features, teased by the developer, are the new workflows that enable users to develop comprehensive actions using many of Alfred’s powerful features wrapped up inside of neat little packages. David Ferguson has already whipped up some great examples like his Rdio and Mail search workflows. I thought I would share my first workflow I created for the beta Alfred v2 called Gitfred. It is a workflow for interacting with your GitHub account, specifically for quickly launching repos, issues, and gists.

To use Gitfred, type one of these commands:

  • repos – list available repositories
  • issues – list open issues
  • gists – list view gists

*To use Gitfred, you must enter in your GitHub credentials. To do this, download and install the workflow, open the workflow folder and edit the gitfred.py file. Change the USERNAME and PASSWORD variables, then save the file and close it.

 

Download: Gitfred Alfred Workflow

Gitfred is powered by the PyGithub project

Regex Groups in Python

Federico Viticci has me hooked on Pythonista. I am not sure what took me so long to buy it because the very premise of scripting on my phone sounds like the best idea ever. I bought it and can confirm it is (in my opinion) the best app ever. At the very least, it is my favorite app right now.

This is not an app review, that may come later. No, this is more of a reminder for myself the next time I go to use regex groups in a Python script. I am extremely new to Python so when I learn how to do something I generally write my self a little text note or store the code snippet for future use, this time I am just going to share it in a blog post.

Groups are incredibly useful. You can use regular expressions to identify a portion of a string and assign it a group name that can be easily referenced when replacing values.

The syntax in Python for defining a regex group is:

(?P<foo>some-regex)

The syntax to reference that group later is:

\g<foo>

This is often better described with a real world example. So here is a link to a tweet on Twitter.com that I am going to break up in to multiple useful groups:

https://twitter.com/binaryghost/statuses/261213781294718976

Using regex to identify the may portions of the URL (domain, user, status, and id) I can assign each chunk of the URL an identifiable name:

Now that I have my groups identified, I can call them in the substitution pattern to do something like convert the format of the link to one that is compatible with Tweetbot’s URI scheme:

tweetbot://\g<user>/status/\g<id>

So when you put all this together in Python you basically get this little code snippet:

So disregarding the import statement, it is possible to identify only specific sub-strings and reuse or replace them at will with only 1 line of code. As you can see, I did not end up using <domain> or <status> and I could have probably left them out but I wanted them to be apart of the example. Every language has its own flavor of regex groups, this syntax however is specific to Python which I why I felt it best to document it with a useful example.

In addition here is a gist with the above code in a working example specifically written for Pythonista:

*Also check out Viticci’s version over at MacStories

Perl Regex Removed From Grep in Mountain Lion

I realized today that many of my shell scripts were no longer working since I upgraded to OS X 10.8. After digging in to it I found out that they were all bombing out on a common grep command I use for finding specific bits of text with Perl regular expressions.

grep -Po '(?<= ).*?(?= )'

I pulled up the grep man page and couldn’t find the -P switch I had always used for Perl regex. It was definitely removed.

To be completely certain, I jumped on a machine running OS X 10.7.4 to see if it was in the last OS, and sure enough there it was.

I am not sure why it was removed, but it was a great way to use powerful Perl regular expressions in a quick and convenient shell script. I really loved being able to whip up a quick shell script for something and use Patterns for the Perl regex. I know egrep has ‘extended’ regex but I like the Perl syntax. I guess it is time to leave my shell scripts behind and start writing in some more sophisticated scripting languages.

Maybe it wasn’t Apple and it was just apart of its open-source development, I don’t know, but it will be missed by me.

Verizon vs. Sprint – iPhone 5 vs. iPhone 4S

This is why I bought an iPhone 5 and switched to Verizon.

Archives