Tag Archives: automation

Justin Kan’s first programming experience

May 22nd, 2012

Justin Kan about his first experience using programming on the job:

A couple more hours of applied effort and I had a macro that looped through all the images in a directory tree and laid them out in Excel. I spent the next four days surfing the web and handing out files.

The first time I did any programming it was more than likely a “Hello World” script in ASP. However, I do remember doing something very similar to what Kan did to automate a process which a fellow employee spent hours a day doing.

I worked for a brokerage and each and every day a fellow employee had to take about 100 stock ticker symbols and run reports on them and input that data into an Excel spreadsheet. This was circa 2000. This went on for nearly a year before I caught wind of what they were doing. On a break or at lunch I was talking to this person and they explained to me what they did nearly every morning for two hours. I was astounded.

When I got back to my desk I fired up my code editor (EditPlus I believe) and in about an hour I had built a very simple PHP script to pull the relevant information for all 100 stock tickers using Yahoo! Finance’s CSV creator. Then a simple Excel macro formatted the data the way that this person had been doing. In all it took the script and macro about 45 seconds to run and create an email with the new data as an attachment.

It wasn’t long after I shared this workflow with my boss that the person that had been doing that job needed to figure out something else to do or they’d probably be of little use to the company. Whoops. Not my intention.

Another co-worker and friend at the time bought me a sticker from Thinkgeek and stuck it to the side of my computer. It read “Go away or I’ll replace you with a very small Shell script.” (Now available in T-shirt form.)

There has been a lot of hoopla lately about the fact that people believe that everyone should learn to code. Some are taking that quite literally to mean that everyone should learn how to build applications or websites. I don’t take it that way. I think everyone should learn the “languages” that their applications speak so that they too can take advantage of working smarter rather than harder. If you are tasked with using Excel all day become the very best at it you can be. And that means being able to program macros. If you are asked to use multiple applications on a Mac learn how to use Services or Automator to do some of your reoccurring tasks for you.

This type of programming won’t put you out of the job. It will free you up to get more work done. To use your time to do other things rather than the same thing every single day. If you do the same task more than once a week you should seriously consider learning how to automate it.

Open a file from Terminal with Coda

December 6th, 2009

If you’re like me, you love Coda. Well, you may find the need to open a file, or set of files, from Terminal in Coda. Gregory Tomlinson has created a bash script to let you do just that.

Update May 20, 2011: It turns out that Tomlinson’s website is down. So, here is a brief synopsis of what you can do to add this functionality to your Mac.

  • Open Terminal
  • In terminal, enter: open .profile
  • Add the following lines of code
    # TextMate
    # set path and simple shell function
    export TEXTMATE_PATH=/Applications/TextMate.app/Contents/Resources/mate
    mate () {
    $TEXTMATE_PATH $1 $2 $3 $4 $5 $6
    }
    # svn for TextMate (default editor, end-of-line types)
    export EDITOR="$TEXTMATE_PATH -w"
    export LC_CTYPE=en_US.UTF-8

    # Coda
    # set path
    export CODA_PATH=/Applications/Coda.app
    # function roughly like 'mate .' by expanding '.' to '*.htm*'
    coda () {
    if [[ "." == $1 ]]
    then
    open -a $CODA_PATH *.htm*
    else
    open -a $CODA_PATH $1 $2 $3
    fi
    }

  • Save .profile
  • Quit Terminal
  • Restart Terminal

There is also a slightly more robust script written for Coda by Aditya Bhargava that handles a few more tidbits and it is available on GitHub.

Baker Tweet

September 16th, 2009

Own a bakery? Want to notify your customers when fresh baked goodies are ready via Twitter? Look no further than Baker Tweet. A simple device that sends canned Twitter updates with the push of a button. Love it.

This has me wanting to work on my own device that will update Twitter for no other reason than to do it.

Clean up your data with Magic/Replace

December 1st, 2008

Although I do not do a lot of this sort of thing much any more, I remember spending many an hour in Excel fighting with various bits of data that I exported to make subtle edits to thousands of rows. After a little bit of experience I began to build Visual Basic scripts, or Macros, that would allow me to do these tasks in an automated fashion.

Boy do I with I had Dabble DB‘s Magic/Replace tool back then.

Magic/Replace allows you to paste a huge block of data, make as many changes as you’d like to a single or set of rows, and it will “remember” the changes you make to the data and apply those changes to the entire set of data. I know that doesn’t sound interesting but it is quite awesome.

Having “Magic” in the name of a product is rarely warranted. But I believe in this case it is.  Be sure to check out the video demonstration to get the full effect of how good Magic/Replace really is.

Source: Magic/Replace.
Via: Simon Willison.

Poll: Should my site send Twitter notifications?

March 27th, 2008

Ironically you may be reading this note because you clicked on a link from my Twitter account.

My site is setup to post links to Twitter, every 15 minutes, if there was a new post here on my site. I try to add a little context by adding the category before the Twitter status (e.g. “Link:”) and I also include the title of the note so that people can choose whether or not to click the link from Twitter back to my site.

But I could see this getting pretty annoying for some.

Someone whose opinion I value, Justin Blanton, had said in October 2007, on Twitter no less, that he didn’t like the whole “use Twitter to link to your blog” method of letting people know when you update your site. In some ways I agree with him but in others I find it fairly useful when I am not near Twitter to automate the process. I’m torn.

This process all started when I started to post mobile photos with my iPhone. At first they were going to Flickr and so I once Flickr updated the RSS feed for my photos, I had a script that would notify Twitter of the new photo. Once I began to post my mobile photos here on my site, I figured I would do the same thing.

This slowly expanded into, what is now, a script that will post to Twitter every single time I publish something to my site.

So, I ask – should I continue this? Is it annoying? It is useful? Should I only do it for mobile photos and nothing else? Please let me know in the comments.

Mobile photos now here, more to come later

March 19th, 2008

When I launched the photos section last September, I knew I’d be making incremental updates to how the site handled, displayed, and aggregated them compared to normal posts. I’ll be doing the same thing with mobile photos.

Starting today, mobile photos that used to show up on my Flickr account, will now be on my site. You can see the first one which is a photo of the TVs in the lobby at ViddlerHQ. I plan on adding a new section, to the main navigation, to handle mobile photos and notes that I post while on the go – but I’ll worry about that later. I am going to wait until I get a few mobile notes and photos up before worrying about how the site handles them.

Thanks to Owen Winkler, via Twitter, for hooking me up with this plugin that enhances WordPress’ built-in email-to-post functionality. Now, from my iPhone, all I need to do is select a photo and email it to a special email account I’ve created, and it will be posted here on my site within 5 minutes of me emailing it. Works like a charm.

As with the Photo section, all will be available through the feed – so there is no need to change subscriptions up at all.

I’ve also modified the way that my automated processes for notifying Twitter and Pownce of new mobile photos works. Now, both of these processes are pointed at this sites feed, rather than at Flickr. So all links will be pointing back to here instead of there, and will be for any new post not just mobile photos.

Another big step forward in bringing it all together. For those taken notes, I’ll be digesting the entire strategy to bringing all of my content onto my site sometime in the future when I’m nearly done. For now, subscribe to my feed, if you’d like the play-by-play of how I’m experimenting with this.

Next up? Links. (But probably not for a few days.)

Powncing your Flickr photos automagically

March 5th, 2008

The moment I saw how Pownce handled links to Flickr photos (here is my first Flickr photo that I Pownced) I knew I had to modify a script that I found and had modified for Twitter. The script would automatically “tweet” when I posted a photo to Flickr using my iPhone.

The script isn’t anything special mind you, all it does it “watch” any Flickr feed for new entries. To be more precise, my server runs this script every 15 minutes and checks for new photos, when there is one, it creates a TinyURL and posts it to Twitter (like this).

But I wanted this to work for Pownce.

I immediately dove head first into Pownce’s API only to find out that the API didn’t allow posting anything. I thought my Powncing days were over until, out of some crazy stroke of coincidence, I read an article on TechCrunch that said Pownce was due to release a new version of their API the very next day. Turns out, I didn’t even have to wait that long and the Pownce wiki was updated to include documentation for version 2 of their API.

Without blinking an eye I finished my script, grabbed myself an app_key, and Pownced the script (you’ll need to be logged in, and be my Pownce friend to see this Pownce message). Once I figured out that I couldn’t Pownce a file to the general public, I knew I had to find some time to write this post.

Since then I read that Dave Winer also enjoys the way Pownce shows links to Flickr photos and that he is running a similar script. So I thought I’d put this out for everyone to use.

Powncer!

Enough beating around the bush, you can download the script here which includes an XML parser for ripping through Flickr’s RSS feed. You’ll need to edit the first few lines of powncer.php for it to work, so this isn’t your run-of-the-mill plug-and-play type script, unfortunately, but for the PHP savvy of you, you should be able to get it up and running pretty easily. If you need help getting it setup, just ask in the comments.

I run this script here on cdevroe.com every 15 minutes using cron. You may run it however you’d like.