March 7th, 2010 by Tuomas Rasila

Photo courtesy of Mads Sabroe
We all love Unix shell. I can’t remember when was the last time I had my Mac running without an open Terminal window. Here are couple of tricks you can do with it.
1. “cd -”
After finding this in all of its simplicity I asked many of Linux & OS X hardcore users and none of them knew this existed. “cd -” sends you back to the last directory you where in:
macbookpro:/ tuomas$cd usr/bin/
macbookpro:bin tuomas$ cd -
/
macbookpro:/ tuomas$ cd -
/usr/bin
2. “mkdir -p”
With mkdir you can make a directory, but adding the “-p” argument can make multiple directories in case those do not exist before. For example:
mkdir -p /home/bill/documents/books/computer
3. Update Twitter from shell with cURL
curl -u username:password -d status="Your tweet" http://twitter.com/statuses/update.xml
4. Speak a text file to spoken .aiff file
cat foo.txt |say -o foo
Now try this with Apache log;)
5. “history”
History shows you list of commands you have ran before like this:
526 cat blog-google-api.txt |say -o foo.mp3
527 open .
528 ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
529 history
If you want to run something from your history you can just: !527 and it will run command #527 from the history. In this case: “open .”
Tags: mac
Posted in Uncategorized | No Comments »
June 13th, 2009 by Tuomas Rasila
Ok, this might sound like that we are in the spamming business now. Well, we are not. The case is that email address is typically the only per-person unique key in CRM data. These couple of lines of Python will extract email addresses from any text file, e.g a HTML-file. This script will also make list unique so if the same email address is listed many times in the original data, it will be only once in the output. Enjoy:
#!/usr/bin/env python
# coding: utf-8
import os
import re
import sys
def grab_email(file):
"""Try and grab all emails addresses found within a given file."""
email_pattern = re.compile(r'\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b',
re.IGNORECASE)
found = set()
if os.path.isfile(file):
for line in open(file, 'r'):
found.update(email_pattern.findall(line))
for email_address in found:
print email_address
if __name__ == '__main__':
grab_email(sys.argv[1])
Tags: email, python
Posted in Programming | 4 Comments »
February 15th, 2009 by Tuomas Rasila
SugarCRM is nowadays very widely used CRM system so I will cover it in my posts every now and then.

The API is not very well documented but you can browse its capabilities be opening http://URL-TO-SUGAR/soap.php in your browser
At work we use it by ourselves to handle some processes and have been working with customers using it. There are things I like and thing I don’t like in SugarCRM. It is bit bloated and the code is not the most beautiful I have seen. On the other hand it does its job quite well and it is easy to configure without touching a line of code.
If you use a CRM in your business for a while you will most likely to find that you would like to do some integration. At work we have been doing various kinds of integration tasks. We have integrated a phone system to automatically make entries to SugarCRM when inbound or outbound calls have been made, connected registration of a web application to create a new accounts to CRM, connected a LIMS in various ways to it and so on. The reason I found SOAP-API to be the best way in most these cases is the fact that if you use it you won’t break down anything and it is likely that your code will work with future releases too. Off course there is a performance penalty and using SOAP API is not a good option when performance is an issue. So lets get to the business.
Read the rest of this entry »
Tags: Open Source, python, sugarcrm
Posted in Open Source, Programming | 4 Comments »
February 5th, 2009 by Tuomas Rasila
Today I was thinking about integrating our company’s SugarCRM with our Laconi.ca installation. I thought it would be cool, if our CRM could automatically tweet to Laconi.ca if e.g. a new case have been filed or mail has arrived to some of the group inboxes. There are several quite easy ways to do this. I began by logging into Sugar and looking around what data I would actually want to get out.
So as I clicked the Admin button and went to admin area I realized that there is a new version of SugarCRM available. Ok, I’ll install the new version first I thought hmm.. lets see release notes hmm.. a new feature Sugar Feeds, sounds cool. Maybe I could finally get Trac like timeline RSS feed from SugarCRM. Here is what release notes said:
Sugar Feed enables users to be informed as soon as a user creates a new contact, lead, opportunity, or case. Users can add a My Sugar Feed dashlet on their Home page so that when a user performs any of these actions, a message displays in the dashlet on
their Home page. Userscan also be notified when a lead is converted, when a case is closed, and when an opportunity is closed.
Additionally, users can post status updates, external links, images, and YouTube videos for other users to view within the dashlet.
SugarCRM Community Edition5.2.2.3.h Release Notes
After reading that I still continued to believe that this would be like users life stream RSS-feed. Guess what, it was not. Sugar Feeds is SugarCRM’s internal message sending service. Sure it sounds kinda cute “aww, now I can send these nice little messages to my co-workers” but really. As long as there is no API and no RSS why would anyone log in to SugarCRM to read and write these messages.
As much as I do value the effort of the SugarCRM’s team and their bold moves on the open source field, I still cannot understand who would want to use Sugar Feeds.
Tags: sugarcrm
Posted in Open Source | 1 Comment »
January 26th, 2009 by Tuomas Rasila
“The average spam messages per day is 18.5 and the average time spent per day deleting them is 2.8 minutes. The loss in productivity is equivalent to $21.6 billion per year at average U.S. wages.”
- Jesdanun, A. (2005), “Deleting spam costs billions, study finds”, The Associated Press Newswires (online)

You can filter spam and viruses before they hit your mailserver
Let’s say there are ten people working in your office and monthly cost per person is 4500€ (25,50€ per hour). By eliminating spam you could save 9:48 hours or 249,90€ per month totaling 2998,80€ per year the study says. Ok, I know I’m quantifying the unquantifiable, but the amount is anyway far greater than zero.
In my opinion the problem that is not solved yet is the deployment. I think every tech savvy person filters their spam already. But how about the rest of the people. Sure, you can use time and install a spam filter to each client, you can also install a spam filter to mail server and get more results.
If you wish to install spam filter to every client computer it will take lot of time and possibly people can mess up their installations. Updating lots of PCs does not sound like a good idea either.
Installing spam filter to a mail server sounds like a better idea but it might be that you cannot go to the mail server. Another problem would be that having a universal spam filter that works with any mail server is not reality.
But what about I you could just use hardware based solution that works out-of-the-box with any kind of setup. Wouldn’t that be cool? Perhaps the easiest way to eliminate spam in any POP3, IMAP & SMTP scenario would be to set up a network attached spam filter. This way would be 100% transparent to clients and completely platform independent. In SMTP scenario (You are not using mail server of your service provider, instead you have your own mail server) you can directly block spam before it goes to your mail server. You can also set up a simple shell script to automatically log in to your mail accounts and sweep the spam with Spamassassin. This would also be useful if you use a mobile device e.g. an iPhone to read your mail.
Read the rest of this entry »
Tags: linux, Open Source, spam
Posted in Business, Open Source | 3 Comments »
January 25th, 2009 by Tuomas Rasila

Full disk is a lousy reason to wake up in a middle of the night
In my last post I wrote about Laconi.ca and mentioned that we have many bots updating Laconi.ca too. The bots are made active when some condition has met.
Example: Make server running out of disk space to post an update to Laconi.ca
This is actually quite useful. Sure, you can tell every service to send an email when something not wanted is happening but then you will have to read that mailbox too. Sending email to someone else doesn’t solve the problem. Hmm, updating to Laconi.ca doesn’t solve the problem either but it makes servers easier follow and to subscribe.
So here is a simple shell script:
Read the rest of this entry »
Tags: bash, laconi.ca, unix
Posted in Business, Open Source, Programming | 2 Comments »
January 20th, 2009 by Tuomas Rasila

You can get Ubuntu Cola from Sweden
One of my colleagues gave this drink to me on the other day so I had to post an image here.
Tags: ubuntu
Posted in Photos | No Comments »
January 15th, 2009 by Tuomas Rasila
Yesterday I had a simple problem. I had one big PDF-file with 6000 pages in it and I wanted to prepare it for mail house. What they needed to get the job done was two PDF-files, one with single-paged documents and one with multi-paged ones.
Luckily all the single-paged documents had string “Page: 1/1″ (or same in Finnish) on the top of the page. So writing a small Python-script to do the job was easy. What I needed in addition to Python was pdftotext binary (here is a dmg for OS X) and pyPdf. So here is the code:
Read the rest of this entry »
Tags: python, scripting
Posted in Programming | 1 Comment »