Javier Tordable

On Software, Mathematics and Technology

SOPA Protest in Google App Engine

January 19, 2012

Just for trivia, this is how I implemented the SOPA protest page yesterday.

class Sopa(webapp.RequestHandler):
  """Handler for 503 protest Sopa response."""
  def get(self):
    self.response.set_status(503, 'Service Unavailable')
    self.response.out.write(
      '<p><b>503: Service Unavailable</b></p>' +
      '<p>www.javiertordable.com is not available today in protest with ' +
      'the <a href=\"http://sopastrike.com/\>>Stop Online Piracy Act ' +
      '(SOPA)</a>.</p>')

This would work for any simple Python wsgi Google App Engine application

def main():
  application = webapp.WSGIApplication([('\.*', Sopa)], debug = False)
  util.run_wsgi_app(application)
Did you like this post? it on Google.

The Robots of Tomorrow

January 16, 2012

I've been reading a little bit lately about robots. It's amazing how fast robotics has advanced in the last ten years. On the one hand we have several million robots doing useful tasks in people's homes. I'm talking of course about the Roomba.

Roomba, cleaning

On the other hand we have projects that are pushing the boundaries of what is possible to automate. For example the Google driverless car, which has recorded thousands of miles of automatic driving in a variety of road environments.

Google driverless car

There is also an increasing trend of automation in factories. Of course robots have been used in manufacturing for quite a while, but in the near future it may be possible to replace complete categories of human workers (See this or this).

But from my point of view the most important advance is the creation of platforms that other engineers can build upon. On the hardware side, I specially like the Willow Garage PR2.

Willow Garage PR2 robot

The PR2 is a very complete hardware platform, with many features for movement, manipulation of objects, cameras and other sorts of sensors. Although the PR2 is still very expensive (400,000 $ for the complete version) I imagine having a solid and reliable hardware platform would allow robotics teams to concentrate on the automation of behavior, which is the really important part.

On the software side, I think ROS (Robot Operating System) is a good step in the creation of a platform. It already has a very large set of modules available for all sorts of robot behavior.

The same way that the IBM PC for example contributed to a new wave of computing applications that dramatically changed the world that we live in, we may find that in the next few years the PR2, ROS and their successors have similar effects. I'm really excited to see what robotics will bring us during this decade.

Did you like this post? it on Google.

Google Code Prettify

December 26, 2011

I just installed the Google code prettify library on Nounoublog. It's a very small and simple Javascript library to pretty print code. Pretty printing is of course formatting code to make it look good and easier to understand, identifying language keywords, constants, etc. The Google code prettify library supports a wide variety of languages, including C, Java, Python, Bash, SQL, HTML, Javascript, etc. Even with the default configuration it generates snippets that are very nice looking. For example:

# Computes the hailstone sequence of an input number
# and prints how many iterations it takes to reach 1.
# For more info see http://en.wikipedia.org/wiki/Collatz_conjecture

import sys

def iterate_hailstone(n):
  if n % 2 == 0:
    return n / 2
  else:
    return 3 * n + 1

if __name__ == '__main__':
  n = int(input('Introduce a natural number: '))
  if (n < 1):
    sys.exit('You need to learn what a natural number is.')

  num_iterations = 0
  while n > 1:
    print n
    n = iterate_hailstone(n)
    num_iterations = num_iterations + 1

  print 'Converged in %d iterations' % num_iterations

Or more succinctly:

while(n > 1): n = (n%2) * (3*n+1) + (1 - n%2) * (n/2); n;

Installing the library was painless. Also, it seems very quick to load. The complete instructions are here.

PS. Does the program finish for all natural numbers?

Did you like this post? it on Google.

Enigma, the Hidden Secret of the Third Reich

December 11, 2011

Cryptography studies how to process data to transmit it securely, even if someone access the information in transit. For thousands of years cryptography has been a key military technology. For example, Julius Caesar used a simple encryption technique to communicate with his generals. Starting from a message text, the method replaces a letter for another letter in the alphabet that comes after one or several positions. For example, if the secret message is:

HI THIS IS A SECRET MESSAGE
To encrypt, we can replace each letter with the next letter in the alphabet H->I, I->J and so on:
IJ UIJT JT B TFDSFU NFTTBHF
To decrypt, replace with the previous letter, I->H, J->I, etc.:
HI THIS IS A SECRET MESSAGE

The reason to use encryption is obvious. Imagine yourself two thousand years ago. There is no telephone, internet, radio or anything similar. You are trying to attack an enemy army and in order to do that, you have split your forces into two, trying to enclose the enemy and force them to surrender. Now, you need to synchronize with the other side of the army so that you attack at the same time. But, if you simply send a soldier across with a message like Attack at dawn you have the risk that the soldier will be caught by the enemy army while trying to reach across. If the enemy is able to read this message they could as well maneuver during the night to escape the attack.

Here is where cryptography comes into play. If instead of sending a message like Attack at dawn you send an encrypted message, for example: BUUBDL BU EBXO now it's not obvious what the message means. Using a code secure enough so that only you and the recipient of the message are able to understand it, means that you don't need to worry about the enemy reading the message. For example, you could send three soldiers across different paths, and even if the enemy captures one of them, the attack could proceed as planned.

One of the most famous cryptographic mechanisms in history is the system used by German troops during World War II, the Enigma. Enigma is a family of machines that encrypt and decrypt messages based on a complex set of electric and mechanical components.

The relevance of the Enigma comes from the fact that it provided encryption that was vastly superior to most previous systems. It allowed the U-Boat submarines from the Third Reich to attack allied ships without any kind of warning. The Enigma encryption was broken by allied cryptanalysts. It is often said that this achievement hastened the end of the European war by two years.

Enigma encryption machine

Recently I had the chance to see some of these Enigma machines in a visit to Germany. They have some in display in the Deutsches Museum in Munich. I enjoyed the museum very much, and I highly recommend it. If you are ever near Munich, the Deutsches Museum is an obligated visit.

Did you like this post? it on Google.

Memcache Optimizations in App Engine

September 01, 2011

Google just announced that App Engine is going to be out of preview soon. And there is a new pricing model as part of the changes. So I decided to take a look at the resource usage of this blog and found out that the RSS feed is the most expensive request. I decided to optimize it by caching it in the memcache and 5 minutes later it's working in production (talking about fast software development cycles...).

Implementing memcache diff
Did you like this post? it on Google.

The Modern Quest for Immortality

August 19, 2011

Human interest in the possibility of rejuvenation begins in ancient times. Around 200BC the Chinese emperor Qin Shi Huang became obsessed with his own mortality and sent the famous alchemist Xu Fu to find the Peng Lai islands (where immortal beings were believed to live) and return with the elixir of life. Starting in the Middle Ages, European alchemists began a quest for a substance that was not only able to transform metal into gold, but also rejuvenate whoever held it: the philosopher's stone. These myths have reached the present day, and feature in works such as J. K. Rowling's (hugely successful) first Harry Potter novel.

Such contemporary references indicate we are still as fascinated by the myth as our ancestors, but we might be evolving to a scenario where what was once transcendental and restricted to the realm of the imagination is likely to become very much real and palpable. In part thanks to the work of Dr. Aubre de Grey and SENS.

Aubrey de Grey

Aubre de Grey is one of the most prominent faces of the longevity movement, and somewhat of a celebrity within scientific circles. Although he came from a computer science background, Dr. de Grey's interest in aging research was already well developed as early as 1999, when he published a book analyzing the role of mitochondria in aging, a book which granted him his Cambridge PhD, even though he had not enrolled for doctoral studies. This interest in aging research quickly became focused on regenerative medicine (or biogerontology) and in the early years of the new millennium several conferences of like-minded individuals paved the way to a plan to cure aging, which they called SENS.

SENS Foundation

SENS

SENS is an acronym for Strategies for Engineered Negligible Senescence. Despite the daunting name, the ultimate goal of this approach is simply to reach a level of technological advancement where we have such knowledge and control over the human body's biological machinery that we are able to diagnose and repair whatever goes wrong. Although, admittedly, this kind of development is bound to be decades or even centuries away, that does not mean people alive today might not see their life extended. As Dr. de Grey elegantly explains in this TED talk (included below), we don't need to solve the entire aging problem within a small time frame, but we will extend our lifespan in successive increments as research progresses and we uncover new ways to rejuvenate our bodies. Of course, in the time between discoveries we will continue to age, but as long as the speed at which new developments reach the market is greater than the rate at which biological damage takes place, we will have attained actuarial escape velocity and, consequently, the possibility to live for a very long time, and eventually immortality.

How SENS will help us live longer

In Ending Aging (a very engaging and surprisingly easy to read book), Dr. de Grey explains what he considers to be the seven factors behind aging and the SENS approaches designed to tackle them. Very briefly, these are:

Even if the problems have been identified, we are still not at a point where we can make great strides in all areas. What SENS has been doing, however, is a number of strategic advances in areas which have great relevance now and whose potential benefits are enormous, for example:

RepleniSENS is one of those areas. The program seeks to solve the problem created by cells which divide slower than they die. This cellular behavior is behind many of the age-related pathologies, including loss of muscle strength (due simply to the decrease of the number of muscle cells) or Parkinson's disease. However, a group of German researchers working under the SENS umbrella discovered a way to administer stem cells to rats' brains in a non-invasive fashion through the nose. The rats, which exhibited symptoms of Parkinson's, showed great improvement in mobility after receiving the treatment.

Another very exciting field is the one under AmyloSENS. This approach intends to (literally) clean up the junk that accumulates outside the cells either by stimulating the immune system to find and eat it or by introducing enzymes (the agents that do the eating) directly into the body. Dr. Houk and his research team have been undertaking the Herculean task of using computer simulation to design enzymes from scratch, so they can be very effective at removing each different type of accumulated junk.

Controversy

Even today, the outlook for the SENS project is not clear. In November, a group of 28 biogerontologists released a response to a paper by de Grey accusing him of being overly optimistic by claiming that each one of the specific proposals that comprise the SENS agenda is exceptionally optimistic, and went as far as stating that a program as speculative as SENS did not deserve the respect of the scientific community. Previously, de Grey sparked the controversy with a paper that he wrote in the MIT Technology review MIT Technology review offering a reward to whoever could prove that the idea of SENS was so preposterous that it was not even worthy of scholarly debate. Although 5 submissions were received, independent juries analyzed them and concluded they did not provide compelling evidence to warrant the dismissal of the SENS approach, although they recognized the speculative nature of the programme.

Other research projects

It could be said that other scientists are taking the research step-by-step, whereas SENS is looking at what lies ahead, but the immediate research concerns are not conceptually different. In fact, much exciting research in biogerontology is being done around the world. For instance, Harvard researchers took mice whose telomerase enzyme was shut down and consequently developed symptoms of aging very soon (having a very short life-span) and reactivated the enzyme. Almost instantly, the mice became healthy, with recovery being almost total. These are encouraging results not only because they indicate rehabilitation is likely to be possible even if treatment starts in adulthood, but also because it offers great promise in treating accelerated aging diseases like progeria. Similarly, a collaboration between 3 American universities uncovered that rapamycin, a drug that has been used to prevent organ rejection and to treat tumors, was able to extend the life-span of mice between 5 and 16%. What was most surprising about this result, however, is that the effect was achieved with middle-aged mice. They started administering the drug to mice at an age equivalent to 60 human years which leads credence to Dr. de Grey's belief we might yet live to see significant life-extension possibilities available.

The ethical debate on immortality

Part of the reason why SENS became so controversial recently was the whole new ethical debate it brought about immortality (or at least a much longer life) was no longer a theoretical concept, but it was possible to envision how it might become real. From one side of the barricade, individuals against this type of life-extension claimed death was natural and it would be a corruption of the natural order of things (including evolution) to thwart death. Moreover, they were concerned that social inequalities might become more pronounced as these technologies would be used by rich people in detriment of the poorer classes. On the other hand, transhumanists see nothing of natural in dying (in fact, they go as far as considering death an abomination) and find it unethical not to do anything in our power to fight it. They also argue social inequalities would not be an issue as society would adjust to the new paradigm as we have adjusted in the past.

Regardless of where you stand in this debate, one thing appears clear research on the matter, either cautiously or overtly optimistic, is happening and we are finally starting to get a glimpse of how the extremely complex machinery within our bodies works. Whether that research will be applied only time will tell but, who knows, some of us might live to celebrate the year 3000 :)

Aubre de Grey
Did you like this post? it on Google.

Adding Authorship Data to Your Site

July 31, 2011

I figured out how to add authorship markup in the blog! There is a nice tutorial here, and complete documentation in the official Webmaster Tools authorship help page. But it basically comes down to this: There are two options, with 2 or 3 links.

In the 2 link option, you simply add a rel=author link from the content page to your Google+ profile, and then in the profile a link back to the root site.

2-way Google Authorship link

In the 3 way option, which you can use if you have an author page, you add a rel=author link from the content page to the author page, which has to be on the same domain. Then you add two links back and forth between the Google+ profile and the author page. Those two links have to be marked rel=me.

3-way Google Authorship link

In Google+ you can mark a link as rel=me if you indicate that the page is about you.

Indicate in Google+ that the page is about you

After that, you can check that the markup is correct in the Rich Snippets Testing Tool. Rich Snippets Testing tool for authorship

Easy enough, right? If you liked this post, or you have any question that I can answer just leave me a note on Google+.

Did you like this post? it on Google.

Two Cool Gadgets

July 30, 2011

Just wanted to leave a note on two new cool gadgets that I found online.

Homemade electron microscope

The first one is a homemade electron microscope. An electron microscope is a type of microscope that uses electrons instead of regular light to illuminate and create images with better resolution. Kudos to Ben Krasnow for it.

3D printer capable of printing biological organs

The second one is a 3D printer that can be used to print biological organs. Organovo has figured out how to use 3D rapid prototyping to print blood vessels. But who knows if in the future they will be able to print full organs?

Did you like this post? it on Google.

Programmer fonts

July 14, 2011

I read a few days ago an interesting post about what are the best fonts for programmers (monospaced fonts) at Hivelogic. And I decided to try out one of the fonts, Inconsolata. Here you have a screenshot of emacs with it.

Screenshot of emacs with Inconsolata font

I think it looks very similar to my previous favorite, Lucida Console. If you want to set it up in emacs (why would you use any other editor?), just edit your .emacs file and add

(set-default-font "Inconsolata-12")

Or something along those lines, depending on your preferred font size.

Did you like this post? it on Google.

Google+

July 01, 2011

Google+ is finally here! Google+ is the new social network from Google. It has a lot of cool features that make it better than anything else out there, like for example, the hangouts, which are like Skype, but with many friends at the same time.

Google Plus Features

The look & feel of Google+ is very clean and it's easy to use after you spend a few minutes getting familiar with the UI. And differently from other social networks out there, you can download all your data whenever you want.

Google Plus Screenshot

If you are already on Google+, you can find me here, if not, send me a message and I will forward an invitation as soon as I have some available!

Did you like this post? it on Google.