Rails ActionMailer and gmail

June 30th, 2009 View Comments

Ok… So this took me longer than it should have to work out. There was much advice about using some sort of tls configuration in the actionmailer config. Don’t listen!! :-P It didn’t seem to work for me.

This is what did work:

Step 1:
Run this from your app root.

curl -s http://s3.amazonaws.com/drawohara.com.ruby/tls_smtp.rb > ./lib/tls_smtp.rb

Step 2:
Add an initializer ie. config/initializers/smtp_config.rb with the following:

require 'tls_smtp'

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'mydomain',
:authentication => :plain,
:user_name => 'name@domain',
:password => 'uber-secure'
}

Do it!! I hope you find this before you get very annoyed at the not working and seeming 0 debugging output like I did!

The Economics of Upselling

June 18th, 2009 View Comments

This post follows directly fron an issue we have been having with SnackPanda lately. We are looking for a good domain registrar that we can resell for. This isn’t because we care at all about making money off of selling domain names. It’s because we want domain registration to be a seamless invisible process to our clients. What we found is that many domain registrars provide a high barrier to entry to reselling domain names through them. Many ask for a high up front “down payment” before they allow any domain resale for example.

At first this seemed curious to me. Why would a store provide a barrier to entry to people who are planning on driving more traffic in their direction? It doesn’t really make any sense. My first thought was the barrier was there so that when buying a domain someone couldn’t claim to be a resaler and buy a domain at 8.50$ instead of 9.50$. But the more I thought about it that just seemed stupid, if this were the case they would provide a service where I could resell domains at the price I would normally pay. Then finally the answer occurred to me. Domain registrars don’t actually want you to resell their domains.

?!?!? What?!?! Seems bizarre right? Why would a domain registrar not want you to give them more business? The answer is that they don’t actually make any money off of selling domains. Say a domain registrar makes 3$ per domain and registers a million in a year. That’s only 3 million dollars. Seems like a ton of money, but for a company like godaddy which cleared over half a billion last year it’s a mere drop in the bucket. If anyone has ever registered at godaddy they know that to buy a domain you have to navigate through a million pages of “Do you also want to add this useful thing?”. Godaddy makes money on the extras they sell! For every domain name registration someone else resells that does not force the user to go through their crazy options they don’t make money.

This in fact is just the common practice of variable pricing applied to the internet. When you buy a coffee at Starbucks and get Venti it costs them virtually no more than to give you a tall, and yet you pay significantly more. Stores want to price items so the consumer who is willing to pay more for the item does. The same practice happens in retail with sales. People willing to pay more buy the item at full price, people less willing buy it on sale at the end of the season. In domain registration some people may be willing to pay 80$ for a registration, some might be discouraged by anything more than 10$. The registrar wants both of these people’s business but needs some way to part the person willing to pay more from their 80$ so they offer upselling options.

The last example of this I’m going to give on this ramble is Intel. Intel for while (and still may) deliberately breaks some processors to make them go slower. Because of this some slower processors were in fact more expensive to produce than the expensive processors. It was necessary however because without having different processor speeds there is no way to part consumers from exactly the amount of money they were willing to pay.

Use this wisely in your businesses. Extra upselling features don’t need to be magnificent, they do however need to exist so that you give consumers willing to pay more for your product the opportunity to pay more. Don’t believe me? Start looking around, you’ll see variable pricing everywhere!
Thanks for listening to my rant. Joel out.

Perl Regex locations

June 16th, 2009 View Comments

Sometimes this is more like my personal notebook to look back on. Something that I have in the past had trouble googling for perl is how to find the location in a string of a regex match. It’s actually really easy. The variable @- and @+ contain the start and end of the match respectively.

ie.

my $string = 'abcdefgabcdefgabcdefgabcdefg';

while ($string =~ m/abc/g) {
print "Start: '@-', End: '@+'\n";
}

Social Evolution

June 13th, 2009 View Comments

While evolution is not a specific point that I do any sort of work on it is something that I am very interested in. From a genetic perspective the amount we understand with respect to evolution that we did not formerly understand is unbelievable. I find evolution particularly interesting interesting because it is so unfathomable timeframe wise as compared to our lives. It is a concept we imagine that we all understand, but it is so difficult to actually visualize the changes, particularly as someone who knows the involvement of mutation DNA repair and physiological changes.
That being the case there are evolutionary traits that are evolved in most species that seem very counter intuitive. The easiest example of this is the insane colorfulness of male ducks. As a less colourful duck a male duck could live longer, have sex with more hot woman ducks and have more little mini ducks on average. The situation would however not be sustainable as if all male ducks had the same behaviour there would no longer be any selectionary advantage. The issue is that evolutionary pressure is not just on an individual basis it is societal. Societies have not only a drive to continue to exist, but also heritable characteristics. For example behaviour is passed down both partially genetically and through instruction by parents.
One of the coolest examples of this is altruism in humans. Time and time again studies have shown that humans are intrinsically altruistic. The evolutionary problem with this is that throwing oneself in harms way to help another human is from an individual perspective a ridiculous decision. As a society however groups of people who do as such tend to survive better and so the societal evolutionary pressure overcomes the individual evolutionary pressure. Another cool example is wolves. A pack of wolves has only one set of cubs per year. If all the wolves just had sex all the time there would be way more cubs and each individual that was not the head of the pack would increase their chances of passing on their genetics to the next generation. The cubs however would not get the same attention, nor have as good of a chance to survive. Societal evolutionary pressure overcomes individual evolutionary pressure. Pretty cool.
I’m sure if I had not been drinking all day at barcampyeg I might have put this better, but I hope you all enjoyed.

JJ

I’m 26!!

June 4th, 2009 View Comments

Damn it. FML. haha. Seriously though, I do feel like I should have done more by 26. Also I’m late 20s. No cool kids wanna hang out with a dude in his late 20s. Anyway, Happy Birthday to me. Time for bed.

Rails internals

June 3rd, 2009 View Comments

Preliminary note:  This one is devels only.  Otherwise I assume you will find it dry, boring and hate me for making you read it.

Ok, so all opinions on rails and ruby and the goodness and badness thereof aside there is one thing about rails that always bothered me.  That is that the documentation that is easily findable online is basically

Step 1: Install
Step 2: Run the following commands
Step 3: Magic, basic web app.

While that is very nice for a basic skinable web app, it doesn’t really cut it when the application is going to be more complicated and there is lots of internal logic that has to occur that is not associated with the display.  I often found myself frustrated trying to decide where extra functions would go that didn’t belong in the model, controller or views and that were not helpers. (Check elsewhere for what should *actually* be here.) Some people put this code in the libs folder. This is NOT where it belongs. libs is, always has, and will always be for external code. The code in libs should not be touched by you, it’s for bug free code

So where does this all belong? Put it in a new folder in the app directory! Yup, you heard me a “new” folder. The apps directory does not have to only have the controllers, views, models and helpers folders. Just make a new one and then edit your environments.rb adding the following:

Rails::Initializer.run do |config|
config.load_paths << "#{RAILS_ROOT}/app/newfolder"
end

and you're off. You can now divide up back end code logically to your content! Pretty sweet no?

Silent Mutations

June 2nd, 2009 View Comments

As someone involved in biological research I get the opportunity to read lots of research in the field of biology.  (obvious right?)  The sad truth however is that the presentation of most papers is such that they are really dry!  Because of this *many*, but not all, interesting things I read come from Scientific American.  Today I read an article that was fairly interesting, but really makes me realize that biology and genetics as a science is still in it’s very infancy.

First a little background info for the not biologically inclined who wish to read this.  Proteins in out cells make *everything* happen.  When you move it’s proteins in your muscle cells.  When you eat the sugar is digested using proteins in your cells. etc.  So naturally when these proteins change so that they don’t work that’s bad.  The proteins are composed of amino acids and the order of these amino acids is essentially what makes a protein what it is.  The order of the amino acids depends on the gene that codes for the protein.  The genes are composed of nucleic acids and every three nucleic acids codes for an amino acid.  is.  GGC is Glutamine.  Hope that wasn’t too dense!

The catch is that there are 61 different combos of nucleic acids that can be used but only 20 amino acids, so sometimes and amino acid comes from more than one combo.  ie. GGC and GGA actually both make glutamine.  It has long been assumed that mutations in your DNA (ie. GGC->GGA) that do not cause a protein to change do not cause harm.  These are called silent mutations.  (Quick note for the biologically inclined:  Ok, we have long known they cause problems in bacteria etc.  but for various reasons they were thought to be benign in humans.)

Lastly, when human proteins are made, chunks called introns are taken out.  So the entire gene doesn’t actually participate in the protein.

Where is this going?  Simple.  As it turns out, among other things, the introns are determined by sequences of nucleic acids.  How obvious is that that the nucleic acid sequence should determine intron location?  Nucleic acid sequence determines everything else, like where to start making the protein etc.  The answer is it should have been obvious.  Despite the obviousness it took us until just the last 5 years to figure out that silent mutations can effect other things like intron location.  This after knowing for over a decade that for some “mysterious” reason it looked statistically probably that some genetic diseases are caused by silent mutations.

What’s the point of this?  Basically if this stunningly obvious discovery is new then what more obfuscated and difficult to discover processes still await our prying minds to unveil?  This is the reason it’s so exciting to work in bioinformatics.  The world is waiting for us to uncover it.  For discoveries such as this all the clues are there, but the amount of data is so vast that machine inference techniques need to be used to put it all together.  With any luck, I’ll be there doing it.  Up up and away.  (Or something else slightly more inspirational…)

Where am I?

You are currently viewing the archives for June, 2009 at Where Is Joel?.