Login

Ruby

Send email with attachment using Rb-Appscript & Apple Mail

Here is a simple way to send a mail attachment through Apple's Mail application using rb-appscript!

I use this as a command line utility and put it in my /usr/local/bin folder. Now I can access it from anywhere.

If you do not have an attachment to send put an empty string for that parameter.

 

Setting Up a Ruby Library

After you have programmed awhile you will see this pattern of copying and pasting the same code over and over again. The thing to do at this point is create some libraries of your trusted and tested code.

I place all my ruby libraries in this folder:
/Library/Ruby/Site/1.8/_mylibs/
   

Command Line Utility to Make Files Executable

If you are like me and you make a lot of command line utilities then this script is for you. There are only a few steps to making an executable but this is exactly what makes it a good candidate for automation.

I make this script an executable naming it 'make_exe' and it goes in a folder called 'my_bin' in my home directory. Then when I want to make another file executable I just type 'make_exe' in a Terminal (I mainly use iTerm) it pops up a dialog asking me to pick the file, give it a name and it does the rest.

It makes a copy of the file that was chosen giving it the new name specified. It then chmods the new file to 755 (change to your liking). After that it is moved to '/users/user_name/my_bin/' (again, change to your liking).

   

Installing Rb-Appscript

Why do we need rb-appscript? Well, because I prefer not to write a bunch of '/usr/bin/osascript/ -e "tell application \"MyApp\" to blah bla bla"' from Ruby to talk to other applications. Rb-appscript enables us to communicate with scriptable applications through Ruby instead of using AppleScript. It is very, very cool and if you are needing to script applications then I suggest you try it. My many thanks to Hamish Sanderson for creating it! Click here for more information.

   

Rails to iTerm

I have been meaning to learn Rails for quite some time now so this past weekend I took the plunge and started running through a tutorial. I noticed very quickly that each time I created a new project I performed the same set of tasks in iTerm ( an alternative to Terminal ).

Since I love automation I wrote a little script to do this for me. There is more you can do with this like open your browser to this project, resize the windows in the applications you use for development, etc. I use separate scripts for these tasks so I will not be adding them here.

   

Page 1 of 2

 

Product Categories