Javier Tordable http://www.javiertordable.com Javier Tordable on Software, Mathematics and Technology Nounoublog https://code.google.com/p/nounoublog/ Excel Reports http://www.javiertordable.com/excel-reports Sat, 12 Jul 2014 03:42:51 GMT http://www.javiertordable.com/excel-reports <p> Everybody who has spent some time working in a business of any size knows that Excel is ubiquitous. It's surprising that there are so few companies out there working in the spreadsheet world. <p> <p> Recently I had to create a bunch of Excel reports, and I took some time to explore ideas on how to structure a library for easy report creation. I took the excellent <a href="https://xlsxwriter.readthedocs.org/">XlsxWriter</a> library and built a few conveniences on top of it. Check out the first iteration of <a href="https://github.com/tordable/XlsxReports">XlsxReports</a> in my Github page. </p> <p> The code to create a report looks like this: </p> <pre class="prettyprint"> #!/usr/bin/python2 """Example XLS report.""" __author__ = 'jt@javiertordable.com' from XlsxReports.layout import ( HideOutsideLayout, PaddingLayout, TableLayout) from XlsxReports.style import ( EmptyStyle, FixedStyle, TableStyle) from XlsxReports.table import Table from XlsxReports.xls import new_workbook LIGHT_GREY = '#BBBBBB' def main(): workbook = new_workbook('my_file.xlsx') sheet = workbook.add_worksheet('TableData') table = Table('Data', ['Name', 'Id', 'Data']) table.add_row(['John', '1', 'First']) table.add_row(['Jane', '2', 'Second']) table_style = TableStyle(workbook, table) table_layout = TableLayout(table_style, table) padding_style = FixedStyle(workbook, '', LIGHT_GREY) padding_layout = PaddingLayout(padding_style, table_layout, 1, 1, 1, 1) overall_style = EmptyStyle(workbook) overall_layout = HideOutsideLayout(overall_style, padding_layout) start_position = (0, 0) overall_layout.draw(sheet, start_position) workbook.close() if __name__ == '__main__': main() </pre> <p> and generates an Excel spreadsheet like the following: </p> <a href="https://github.com/tordable/XlsxReports"> <img src="http://www.javiertordable.com/img/spreadsheet.png" alt="A spreadsheet generated with Python"/> </a> <p> Please, let me know if you find it useful! </p> A Simulation of the Universe http://www.javiertordable.com/universe-simulation Sat, 10 May 2014 21:45:04 GMT http://www.javiertordable.com/universe-simulation <p> A new detailed <a href="http://www.illustris-project.org/">simulation of the universe</a>: </p> <a href="http://www.illustris-project.org/"> <img class="big" src="http://www.javiertordable.com/img/universe-simulation.jpg" alt="Simulation of the universe" /> </a> <p class="special-text"> The Illustris project is a large cosmological simulation of galaxy formation, completed in late 2013, using a state of the art numerical code and a comprehensive physical model. Building on several years of effort by members of the collaboration, the Illustris simulation represents an unprecedented combination of high resolution, total volume, and physical fidelity. </p> A Raytracer in a Business Card http://www.javiertordable.com/raytracer-business-card Mon, 10 Mar 2014 00:13:47 GMT http://www.javiertordable.com/raytracer-business-card <p> A raytracer in the back of a business card! Here is the code: </p> <img src="http://www.javiertordable.com/img/raytracer-1.png" alt="Raytracer code"/> <p> And the output: </p> <img src="http://www.javiertordable.com/img/raytracer-2.png" alt="Raytracer output"/> <p> Kudos to <a href="http://www.cs.utah.edu/~aek/">Andrew Kensler</a>, and thanks to <a href="http://fabiensanglard.net/rayTracing_back_of_business_card/index.php"> Fabien Sanglard</a> for the detailed explanation. </p> A github-like Activity Chart http://www.javiertordable.com/github-activity-chart Fri, 28 Feb 2014 07:46:33 GMT http://www.javiertordable.com/github-activity-chart <p> One of my favorite features from github is the activity chart that appears in the user profile. For example, this one from user <a href="https://github.com/jmcnamara">jmcnamara</a>: </p> <a href="https://github.com/tordable/activity-chart"> <img class="big" src="http://www.javiertordable.com/img/github-activity-chart.png" alt="Github activity chart"/> </a> <p> However, I don't really use github except for <a href="https://github.com/tordable/FinanceAI"> one of my older projects</a>. In part because I prefer Mercurial over git. So I decided to write a small tool to generate these charts for my own local repositories. </p> <p> There are two interesting parts. First, reading the change list data from Mercurial: </p> <pre class="prettyprint" style="font-size: 12px"> def extract_cl_counts(repository_path, cl_counts): """Reads the repository changelog and extracts CL counts per day.""" repository = hg.repository(ui.ui(), repository_path) changelog = repository.changelog for cl_index in changelog: cl_id = changelog.lookup(cl_index) cl = changelog.read(cl_id) # The timestamp seems to be the 3rd field in the CL. # It's given in a tuple. The UNIX timestap is the first field. timestamp = cl[2][0] cl_date = date.fromtimestamp(timestamp) if cl_date in cl_counts: cl_counts[cl_date] = cl_counts[cl_date] + 1 else: cl_counts[cl_date] = 1 </pre> <p> And then building the chart itself, which seems surprisingly easy using SVG: </p> <pre class="prettyprint" style="font-size: 12px"> for day_index in range(first_day_to_show, last_day_to_show): # Boxes are stacked first by column and then by row. x = MARGIN + (day_index // 7) * DISTANCE_BETWEEN_BOXES y = MARGIN + (day_index % 7) * DISTANCE_BETWEEN_BOXES # Compute the real date from the day index. day = start_date + timedelta(days=(day_index - first_day_to_show)) if day in cl_counts: color = get_box_color(cl_counts[day]) else: color = get_box_color(0) chart.add(chart.rect(insert=(x,y), size=(DAY_BOX_SIZE, DAY_BOX_SIZE), fill=color)) </pre> <p> And here is how it looks like: </p> <a href="https://github.com/tordable/activity-chart"> <img class="big" src="http://www.javiertordable.com/img/github-like-activity-chart.png" alt="Github-like activity chart"/> </a> <p> You can find the entire code of the <a href="https://github.com/tordable/activity-chart"> chart script</a> in Github (of course!) </p> Blog Redesign and Social Buttons http://www.javiertordable.com/blog-redesign-social-buttons Sun, 16 Feb 2014 03:43:16 GMT http://www.javiertordable.com/blog-redesign-social-buttons <p> Hello, internets! I just redesigned the look & feel of the blog. The new design has bigger font sizes and less distractions. It's optimized for mobile so it should look much better than before on Android and iOS phones, and especially on iPad. </p> <img src="http://www.javiertordable.com/img/social-buttons.png" alt="Buttons for sharing content."/> <p> Apart from the new sleek design now each post has multiple social buttons, to +1 on Google Plus, Like on Facebook, tweet on Twitter and share on LinkedIn to your heart's content. Check them out below. </p> Masters of Doom http://www.javiertordable.com/masters-of-doom Thu, 13 Feb 2014 05:29:10 GMT http://www.javiertordable.com/masters-of-doom <p> A few weeks ago I had the chance to read <a href=""> Masters of Doom</a> by David Kushner and found it very interesting. It tells the story of John Carmack and John Romero, the founders of id Software and authors of some the most revolutionary videogames ever. </p> <a href=""> <img src="http://www.javiertordable.com/img/masters-of-doom.jpg" alt="Masters of Doom book cover"/> </a> <p> The book includes the biographies of Carmack and Romero, as well as plenty of anectodes of their wild ride in the world of videogames. But the part that I found most interesting was the story of how Carmack became such a talented (and widely acclaimed) software engineer. Highly recommended. </p> Mathigon http://www.javiertordable.com/mathigon Mon, 23 Dec 2013 22:22:03 GMT http://www.javiertordable.com/mathigon <p> A while back I found a beautiful website on Mathematics and I wanted to share the link: <a href="http://world.mathigon.org/">Mathigon</a> has a series of introductory articles and many images, figures and interactive visualizations on a variety of mathematical topics. </p> <a href="http://world.mathigon.org/"> <img class="big" src="http://www.javiertordable.com/img/mathigon-1.jpg" alt="Mathigon screenshot"/> </a> <p> The content is quite basic, but it's presented in a great way, the website is well built, and the pictures are fantastic. </p> <a href="http://world.mathigon.org/"> <img class="big" src="http://www.javiertordable.com/img/mathigon-2.jpg" alt="Mathigon screenshot"/> </a> A Cube That Can Walk http://www.javiertordable.com/cube-that-can-walk Mon, 23 Dec 2013 06:13:55 GMT http://www.javiertordable.com/cube-that-can-walk <p> I guess this is the advanced version of the <a href="https://www.google.com/search?q=companion+cube">companion cube</a>: </p> <iframe class="big" width="600" height="338" src="//www.youtube.com/embed/n_6p-1J551Y" frameborder="0"> </iframe> Blender http://www.javiertordable.com/blender Sun, 01 Dec 2013 03:51:09 GMT http://www.javiertordable.com/blender <p> I haven't done any kind of 3D design in many years, but I was thinking last week that it would be fun to get back to it. And while I was looking at software available for Linux, I found <a href="http://www.blender.org/">Blender</a>. </p> <img src="http://www.javiertordable.com/img/blender-logo.png" alt="Blender logo" /> <p> Blender has been around for <a href="http://www.blender.org/foundation/history/">quite some time</a> but it seems that now it's <a href="http://www.blender.org/features/"> features</a> are up to par with some of the most popular 3D packages like 3DS Max or Alias. </p> <img src="http://www.javiertordable.com/img/blender-screenshot.png" class="big" alt="Blender screenshot" /> <p> Apart from the 3D design tools Blender has one very cool feature, a <a href="http://www.blender.org/documentation/blender_python_api_2_64_release/info_quickstart.html">Python API!</a> I will post another note after I have the chance to try it out. </p> A One-line primality test http://www.javiertordable.com/one-line-primality-test Sat, 09 Nov 2013 22:11:54 GMT http://www.javiertordable.com/one-line-primality-test <p> A primality test in one line of Perl: </p> <pre class="prettyprint"> perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/' [number] </pre> <p> Originally written by <a href="http://abigail.be/">Abigail</a>. Explained in detail by <a href="http://neilk.net/blog/2000/06/01/abigails-regex-to-test-for-prime-numbers/"> Neil Kandalgaonkar</a>. Kudos to <a href="http://petewarden.com/2013/11/09/five-short-links-56/"> Pete Warden</a> for the link. </p> Git Branching http://www.javiertordable.com/git-branching Sun, 22 Sep 2013 19:52:11 GMT http://www.javiertordable.com/git-branching <p> I haven't had much time to write lately, work is keeping me busy. But today I wanted to share a site I found recently and I think is really interesting. It's essentially a git tutorial, but with a twist. </p> <a href="http://pcottle.github.io/learnGitBranching/"> <img src="http://www.javiertordable.com/img/learn-git1.png" alt="Learn Git branching screenshot"/> </a> <p> As most of you know <a href="http://git-scm.com/">git</a> is a version control system. Essentially, a program to track and coordinate updates to a set of files, which is one of the most basic tasks in software engineering. <a href="http://pcottle.github.io/learnGitBranching/">Learn Git Branching</a> helps beginners learn how to use git. But instead of simply explaining the git commands it's structured as a puzle game. The levels are git tree structures, and in order to solve the puzzles it's necessary to input the proper git commands. </p> <img src="http://www.javiertordable.com/img/learn-git2.png" alt="Learn Git branching simple example"/> <p> The puzzles go from the very simple, to the fairly complex. So even if you already know git, it may be fun to play the most advanced levels. </p> <img src="http://www.javiertordable.com/img/learn-git3.png" alt="Learn Git branching complex exercise"/> <p> Kudos to <a href="http://petermcottle.com/">Petter Cottle</a> for the tutorial. You can check out his Github profile <a href="https://github.com/pcottle">here</a>. </p> How Memories Look Like http://www.javiertordable.com/how-memories-look-like Sat, 22 Jun 2013 22:05:42 GMT http://www.javiertordable.com/how-memories-look-like <p> <a href="http://news.usc.edu/#!/article/52496/what-do-memories-look-like/"> A team from USC</a> engineered microscopic markers that light up synapses in a living neuron in real time. </p> <img src="http://www.javiertordable.com/img/neuron.jpg" class="big" alt="How memories look like - Living neuron" /> <p class="special-text"> The fluorescent markers allow scientists to see live excitatory and inhibitory synapses for the first time and, importantly, how they change as new memories are formed. </p> Balloon Powered Internet http://www.javiertordable.com/balloon-powered-internet Sat, 22 Jun 2013 02:57:54 GMT http://www.javiertordable.com/balloon-powered-internet <p class="special-text"> <a href="http://www.google.com/loon/">Project Loon</a> is a network of balloons traveling on the edge of space, designed to connect people in rural and remote areas, help fill coverage gaps, and bring people back online after disasters. </p> <iframe class="big" width="600" height="338" src="http://www.youtube.com/embed/mcw6j-QWGMo" frameborder="0" allowfullscreen> </iframe> Code Search with Regular Expressions http://www.javiertordable.com/code-search-with-regular-expressions Mon, 03 Jun 2013 02:50:26 GMT http://www.javiertordable.com/code-search-with-regular-expressions <p> A few days ago I found out about <a href="https://code.google.com/p/codesearch/">codesearch</a>. It's a group of command-line tools to index and search code using regular expressions. It was originally developed by fellow googler <a href="http://swtch.com/~rsc/">Russ Cox</a>. It uses the same algorithms that were behind Google Code Search. </p> <img src="http://www.javiertordable.com/img/google-codesearch.png" alt="Google Code search" /> <p> I played with it a little bit and I'm impressed by how fast it is. Also, it can be <a href="https://github.com/abingham/codesearch.el"> integrated easily with emacs</a>. However, I think it would be even better with a simple web interface. For example, to show the content of the files and highlight matching expressions. Actually that would be a nice weekend project... </p> MIT Talk: Mathematics at Google http://www.javiertordable.com/mit-talk-mathematics-at-google Sun, 05 May 2013 22:14:11 GMT http://www.javiertordable.com/mit-talk-mathematics-at-google <p> A few weeks ago I gave a small webinar for a group of students from <a href="http://www.mit.edu/">MIT</a>. </p> <img src="http://www.javiertordable.com/img/mit-1.jpg" alt="MIT Talk, Mathematics at Google" class="big" /> <p> They told me it went quite well. About 40 people attended. </p> <img src="http://www.javiertordable.com/img/mit-2.jpg" alt="MIT Talk, Mathematics at Google" class="big" /> <p> I basically covered the material in this presentation about <a href="http://www.javiertordable.com/blog/2012/08/24/mathematics-at-google"> Mathematics at Google</a> which I published last year. </p> <a href="http://www.javiertordable.com/blog/2012/08/24/mathematics-at-google"> <img src="http://www.javiertordable.com/img/mathematics-at-google.png" alt="Mathematics at Google" class="big" /> </a> <p> So I'll make use of the opportunity to put the link out there again, for any of you who didn't have the chance to take a look before. Comments and suggestions will be appreciated. </p> Atom movie http://www.javiertordable.com/atom-movie Thu, 02 May 2013 04:23:01 GMT http://www.javiertordable.com/atom-movie <p> A stop-motion movie made with two-atom molecules. </p> <img src="http://www.javiertordable.com/img/atom-movie.jpg" alt="A movie made of two atom molecules" class="big" /> <p class="special-text"> <a href="http://www-03.ibm.com/press/us/en/pressrelease/40970.wss"> IBM researchers</a> used the scanning tunneling microscope to control a super-sharp needle along a copper surface to “feel” atoms. Only 1 nanometer away from the surface, which is a billionth of a meter in distance, the needle can physically attract atoms and molecules on the surface and thus pull them to a precisely specified location on the surface. </p> <iframe class="big" width="600" height="338" src="http://www.youtube.com/embed/xA4QWwaweWA" frameborder="0" allowfullscreen> </iframe> Tech Meetups http://www.javiertordable.com/tech-meetups Sat, 27 Apr 2013 19:36:51 GMT http://www.javiertordable.com/tech-meetups <p> Over the last few months I have been going to a few technology meetups here in Seattle, and I enjoyed it very much. It's great to see all the cool technology that local companies are creating. Here are three of the most popular tech meetups in Seattle: </p> <p> <strong>Seattle Tech Meetup</strong> </p> <a href="http://www.meetup.com/SeattleTechMeetup/"> <img src="http://www.javiertordable.com/img/meetup-tech.png" alt="Seattle Tech Meetup" /> </a> <p> <strong>Hacker News Seattle Meetup</strong> </p> <a href="http://www.meetup.com/HackerNewsSeattleMeetup/"> <img src="http://www.javiertordable.com/img/meetup-hacker.png" alt="Hacker News Seattle Meetup" /> </a> <p> <strong>Seattle Scalability Meetup</strong> </p> <a href="http://www.meetup.com/Seattle-Hadoop-HBase-NoSQL-Meetup/"> <img src="http://www.javiertordable.com/img/meetup-scalability.png" alt="Seattle Scalability Meetup" /> </a> <p> Feel free to drop me a note if you are planning to go to any of these. And say hi if you see me there! </p> Card Games, Complete Subgraphs, Constant Weight Error Correcting Codes and Finite Projective Geometries http://www.javiertordable.com/card-games-complete-subgraphs-constant-weight-error-correcting-codes-finite-projective-geometries Mon, 08 Apr 2013 02:01:51 GMT http://www.javiertordable.com/card-games-complete-subgraphs-constant-weight-error-correcting-codes-finite-projective-geometries <p> I was recently in a store buying a gift for a friend and found a card game that seemed interesting. The cards have small symbols which are arranged in a way such that between two cards there is always one symbol in common. </p> <img src="http://www.javiertordable.com/img/spot-it-card-game.png" alt="Spot it game" /> <p> These are the rules, from the <a href="http://www.marblesthebrainstore.com/spot-it-card-game"> store page</a>: </p> <p style="margin-left: 2em;"> <em> Some people can spot a 90% off designer dress in a pile of discounted rubbish. They make out street signs from superhero distances. And they can identify the rarest of rare birds without even trying. You can be one of those people after a few quick rounds of Spot It! This smart game contains 55 illustrated cards with eight symbols each. There is always one, and only one, matching symbol between any two cards. All you need is a sharp eye and quick hands to take home the title of “Spot It! Master of the Visual Universe.” Win or lose, every player gets killer visual perception skills as a parting gift. </em> </p> <p> You can see an example of the relationship between cards here: </p> <img src="http://www.javiertordable.com/img/spot-it-card-game-2.png" alt="Spot it game" /> <p> As I was leaving the store I though maybe there is something more to this game than meets the eye. </p> <h2>Card Games</h2> <p> First of all, <em>how many symbols are there? And are they repeated or not?</em> Let's start with the most simple approach. We have 55 cards, and we know that there is always a symbol in common between two cards. Given 55 cards we have a maximum of $$ \left(\begin{array}{c} 55\\ 2\end{array}\right)=\frac{55\cdot54}{2}=1485 $$ pairs of cards. Now, that seems a large number of symbols, more than one would imagine by looking at the card images. But the real problem with this approach is that each card would need 54 symbols, instead of just 8. </p> <p> Let's think about it the other way around. We have 55 cards, with 8 symbols each, and each symbol is repeated at least twice. That makes $$ \frac{55\cdot8}{2}=220 $$ symbols. Obviously the problem here is that we can't guarantee that between any two cards there is always a symbol in common. </p> <p> Now, if we think for a moment about the second question, what if the symbols were not repeated across more than 2 cards? Let \(C_{1}\) be one card from the deck, it has 8 symbols, \(C_{1}=\left\{ s_{1},\ldots,s_{8}\right\}\) which are shared by at most eight other cards $$ C_{2},\ldots,C_{9}\,|\, C_{1}\cap C_{2}=\left\{ s_{1}\right\} \ldots C_{1}\cap C_{9}=\left\{ s_{8}\right\} $$ what happens when we consider yet another one, \(C_{10}\). Then it has to be $$ C_{1}\cap C_{10}\in\left\{ s_{1},\ldots,s_{8}\right\} \Rightarrow\exists i\in\left\{ 1,\ldots,8\right\} \,|\, C_{1}\cap C_{10}\cap C_{i}\neq\emptyset $$ Or in another words. With 8 symbols the card 1 could only be connected to 8 other cards, but not the remaining 46, arriving to a contradiction. As a matter of fact, if one looks carefully at the images of the deck and the video, it's possible to spot 4 cards that share the same symbol. </p> <h2>Complete Subgraphs</h2> <p> The combinatorial approach didn't get me very far. Let's go back to the original problem and try to model it as a graph. We have 55 nodes, for each of the 55 cards. And each pair of nodes is connected through a symbol. So we have the complete graph of 55 nodes \(K_{55}\), which has 1485 edges. Now we could think that each edge has a color, and that would reduce our problem, to the problem of finding a coloring of the dual graph of \(K_{55}\). However that doesn't seem to work. In a coloring problem we are interested in assigning colors to nodes such that two asjacent nodes have different colors. In our case we can perfectly have two adjacent edges with the same color, corresponding to one card sharing a symbol with two other cards. In any case, the theory of <a href="http://en.wikipedia.org/wiki/Graph_coloring">graph coloring</a> is <a href="http://en.wikipedia.org/wiki/Chromatic_polynomial">very rich</a> so there may be another less obvious approach that works. </p> <p> Going back to our original graph \(K_{55}\), realize that we can have edges coming from the same node that have the same color, for instance $$ n_{1},n_{2},n_{3}\in V\left(K_{55}\right),\left(n_{1},n_{2}\right),\left(n_{1},n_{3}\right)\in E\left(K_{55}\right) $$ such that \(\left(n_{1},n_{2}\right),\left(n_{1},n_{3}\right)\) have the same color. But this imposes the additional condition that \(\left(n_{2},n_{3}\right)\) has the same color as the other two. Or in other words, taking all the edges that have the same color and the corresponding nodes should give us a complete subgraph. Going back to cards and symbols, this makes obvious sense. If we have 8 cards that share a particular symbol, then any two pairs of cards out of those 8 are connected through that same symbol. We know from the problem definition that there is no other symbol that can be shared among any pair of those 8 cards. </p> <p> This seems closely related, but not quite the same as the problem of finding <a href="http://en.wikipedia.org/wiki/Clique_(graph_theory)">cliques</a> in the graph. In our subgraphs each of the nodes is also connected to nodes outside of the subgraph. All other nodes, as a matter of fact. Nevertheless, considering that the <a href="http://en.wikipedia.org/wiki/Clique_cover">clique cover problem</a> is NP-complete, that doesn't augur an easily computable solution to our deck problem. </p> <p> For the sake of example, let's try to find a solution in case we had 6 cards. We can start taking the complete subgraph with the first 5 nodes. All with the same color, or symbol a. And then the remaining node, with 5 edges to the previous 5. Each one with a different color b,c,d,e,f. We can't take the same color for all because the destination nodes are not connected within the subgraph. The 6 cards would be: $$ \begin{eqnarray*} C_{1} & = & \left\{ a,b\right\} \\ C_{2} & = & \left\{ a,c\right\} \\ C_{3} & = & \left\{ a,d\right\} \\ C_{4} & = & \left\{ a,e\right\} \\ C_{5} & = & \left\{ a,f\right\} \\ C_{6} & = & \left\{ b,c,d,e,f\right\} \end{eqnarray*} $$ These verify that between each pair of cards there is only one symbol in common. However they don't satisfy the condition that each card have the same number of symbols. In order to satisfy that condition as well, we would need to make sure that each node is contained in the same number of subgraphs. With a little bit more work we can find a solution for \( K_{6}\), which is as follows </p> <img src="http://www.javiertordable.com/img/complete-graph-six-nodes.png" alt="Complete Subgraph with six nodes" class="big" /> <p> Giving the cards: $$ \begin{eqnarray*} C_{1} & = & \left\{ a,b,e\right\} \\ C_{2} & = & \left\{ a,d,f\right\} \\ C_{3} & = & \left\{ b,d,g\right\} \\ C_{4} & = & \left\{ c,d,e\right\} \\ C_{5} & = & \left\{ b,c,f\right\} \\ C_{6} & = & \left\{ a,c,g\right\} \end{eqnarray*} $$ Again, it's easy to verify that between each pair of cards there is only one symbol in common. But now each card has only 3 symbols. In any case, following this approach it doesn't seem obvious how to manually scale the process to 55 cards. </p> <h2>Constant Weight Error Correcting Codes</h2> <p> Here is another insight: we can write a matrix that has one row for each card, and one column for each symbol. This reminds to the <a href="http://en.wikipedia.org/wiki/Incidence_matrix"> incidence matrix for the graph</a>, but is clearly different. The matrix is: $$ \begin{array}{c} \begin{array}{ccccccc} a & b & c & d & e & f & g\end{array}\\ \left(\begin{array}{ccccccc} 1 & 1 & 0 & 0 & 1 & 0 & 0\\ 1 & 0 & 0 & 1 & 0 & 1 & 0\\ 0 & 1 & 0 & 1 & 0 & 0 & 1\\ 0 & 0 & 1 & 1 & 1 & 0 & 0\\ 0 & 1 & 1 & 0 & 0 & 1 & 0\\ 1 & 0 & 1 & 0 & 0 & 0 & 1\end{array}\right)\end{array} $$ And what we have here is a set of binary words, such that the <a href="http://en.wikipedia.org/wiki/Hamming_distance">Hamming distance</a> between each pair of words is 4. Between each of the words there is one symbol in common, there are two symbols which appear only in the first word, two more that appear only in the second word, and the remaining symbols don't appear in any of them. This is precisely what makes an <a href="http://en.wikipedia.org/wiki/Error-correcting_code"> error correcting code</a> valuable. In our particular case we are interested in codes with <a href="http://en.wikipedia.org/wiki/Constant-weight_code"> constant weight</a>, because each of the words should have the same number of symbols. </p> <p> With this, the problem is reduced to finding an error correcting code. We have 55 words, corresponding to the 55 cards in the game. The weight of each word is 8, because each card has 8 symbols, and the distance between words is 14, because for each pair of cards there is one symbol in common, 7 appear only in the first card, 7 in the second one, and the rest don't appear in any of them. </p> <p> Three questions arise, first, <em>is it possible to build a code like this?</em> second, <em>how many symbols do we need?</em> and third, <em>how do we actually go about building this code?</em> </p> <p> Fortunately, there are complete tables that indicate the <a href="http://www.win.tue.nl/~aeb/codes/Andw.html"> bounds for binary constant weight codes</a>. Formally, \(A\left(n,d,w\right)\) is the maximum number of words in a binary code with word length n, distance d and constant weight w. In our case d=14, w=8 and we are looking for the minimum n such that \( A\left(n,d,w\right)\geq55\). By looking at the tables we can see that \(A\left(n,14,8\right)<55\) for all \(n<55\), and \(A\left(56,14,8\right)=49\) and \(A\left(57,14,8\right)=57\). And this answers the first two questions. If we take 57 symbols then we can build a code with 57 words which verifies our constraints. If you look back at the tables you will see a <a href="http://www.win.tue.nl/~aeb/codes/Andw.html#d14">note</a> which indicates that the maximum is reached by taking \(PG\left(2,7\right)\). </p> <h2>Finite Projective Geometries</h2> <p> \(PG\left(2,7\right)\) is a <a href="http://en.wikipedia.org/wiki/Projective_geometry"> finite projective geometry</a> of dimension 2 and order 7. The order is one less than the number of points in a line. In particular, this is the <a href="http://en.wikipedia.org/wiki/Projective_plane">projective plane</a> built on top of the <a href="http://en.wikipedia.org/wiki/Finite_field">finite field</a> \(\mathbb{F}_{7}\). </p> <p> In \(PG\left(2,7\right)\) we have \(7^{2}+7+1=57\) points, 57 lines, 7+1=8 points on each line, and 8 lines through each point. As such, if we model the cards in our deck as lines, and the symbols as points, we can build explicitly our deck: </p> <p> Points: $$ \begin{array}{c} \left(\underline{0},\underline{0},\underline{1}\right),\\ \left(\underline{0},\underline{1},\underline{0}\right),\left(\underline{0},\underline{1},\underline{1}\right),\left(\underline{0},\underline{1},\underline{2}\right),\left(\underline{0},\underline{1},\underline{3}\right),\left(\underline{0},\underline{1},\underline{4}\right),\left(\underline{0},\underline{1},\underline{5}\right),\left(\underline{0},\underline{1},\underline{6}\right),\\ \left(\underline{1},\underline{0},\underline{0}\right),\left(\underline{1},\underline{0},\underline{1}\right),\left(\underline{1},\underline{0},\underline{2}\right),\left(\underline{1},\underline{0},\underline{3}\right),\left(\underline{1},\underline{0},\underline{4}\right),\left(\underline{1},\underline{0},\underline{5}\right),\left(\underline{1},\underline{0},\underline{6}\right),\\ \left(\underline{1},\underline{1},\underline{0}\right),\left(\underline{1},\underline{1},\underline{1}\right),\left(\underline{1},\underline{1},\underline{2}\right),\left(\underline{1},\underline{1},\underline{3}\right),\left(\underline{1},\underline{1},\underline{4}\right),\left(\underline{1},\underline{1},\underline{5}\right),\left(\underline{1},\underline{1},\underline{6}\right),\\ \left(\underline{1},\underline{2},\underline{0}\right),\left(\underline{1},\underline{2},\underline{1}\right),\left(\underline{1},\underline{2},\underline{2}\right),\left(\underline{1},\underline{2},\underline{3}\right),\left(\underline{1},\underline{2},\underline{4}\right),\left(\underline{1},\underline{2},\underline{5}\right),\left(\underline{1},\underline{2},\underline{6}\right),\\ \left(\underline{1},\underline{3},\underline{0}\right),\left(\underline{1},\underline{3},\underline{1}\right),\left(\underline{1},\underline{3},\underline{2}\right),\left(\underline{1},\underline{3},\underline{3}\right),\left(\underline{1},\underline{3},\underline{4}\right),\left(\underline{1},\underline{3},\underline{5}\right),\left(\underline{1},\underline{3},\underline{6}\right),\\ \left(\underline{1},\underline{4},\underline{0}\right),\left(\underline{1},\underline{4},\underline{1}\right),\left(\underline{1},\underline{4},\underline{2}\right),\left(\underline{1},\underline{4},\underline{3}\right),\left(\underline{1},\underline{4},\underline{4}\right),\left(\underline{1},\underline{4},\underline{5}\right),\left(\underline{1},\underline{4},\underline{6}\right),\\ \left(\underline{1},\underline{5},\underline{0}\right),\left(\underline{1},\underline{5},\underline{1}\right),\left(\underline{1},\underline{5},\underline{2}\right),\left(\underline{1},\underline{5},\underline{3}\right),\left(\underline{1},\underline{5},\underline{4}\right),\left(\underline{1},\underline{5},\underline{5}\right),\left(\underline{1},\underline{5},\underline{6}\right),\\ \left(\underline{1},\underline{6},\underline{0}\right),\left(\underline{1},\underline{6},\underline{1}\right),\left(\underline{1},\underline{6},\underline{2}\right),\left(\underline{1},\underline{6},\underline{3}\right),\left(\underline{1},\underline{6},\underline{4}\right),\left(\underline{1},\underline{6},\underline{5}\right),\left(\underline{1},\underline{6},\underline{6}\right)\end{array} $$ </p> <p> Lines: </p> <img src="http://www.javiertordable.com/img/projective-geometry-2-7.png" alt="Projective geometry PG(2,7)" class="big" /> <p> Feel free to check my computations. I wrote the table above manually. I included it as an image to make the formula rendering easier on the browser, but I can share the orginal \(\LaTeX\) code on request. I don't have the game with me, so I can't check if this is exactly how it's made, remember that the game has 55 cards instead of the 57 available. This leaves another question open, what other ways are there to build a deck like this, possibly with more symbols and less words? </p> Bye Google Reader, welcome Feedly http://www.javiertordable.com/bye-google-reader-welcome-feedly Sun, 07 Apr 2013 02:31:53 GMT http://www.javiertordable.com/bye-google-reader-welcome-feedly <p> Probably everyone that is reading this post knows that Google has decided to <a href="http://googlereader.blogspot.com/2013/03/powering-down-google-reader.html"> discontinue Google Reader</a>. This comes as a surprise to many because of the large and very passionate user base, including myself. </p> <img src="http://www.javiertordable.com/img/google-reader-logo.png" alt="Google Reader logo" /> <p> Fortunately, it seems there are quite a few companies offering alternatives and willing to pick up all the disheartened readers. I have been personally using <a href="http://feedly.com/">Feedly</a> for a few weeks now. </p> <img src="http://www.javiertordable.com/img/feedly.jpg" alt="Feedly logo" /> <p> While many of the other feed readers are merely frontends on top of the Google Reader backend, which is what keeps track of posts read and not read, <a href="http://blog.feedly.com/2013/03/14/google-reader/">Feedly promises to migrate all user data</a> to their backends when Google Reader closes. Apart from that, Feedly has a nice modern user interface, and works quite well on phones (iPhone and Android), tablets and Chrome. And it has very handy options to share pages on Twitter and Google+. </p> <img src="http://www.javiertordable.com/img/feedly-mobile.png" alt="Screenshot of Feedly on a phone" /> <p> It's been working quite well for me so far, so if you are looking for an alternative to Google Reader, I recommend that you give it a try. </p> A Desktop Computer in a 2 Inch Cube http://www.javiertordable.com/desktop-computer-in-2-inch-cube Sun, 06 Jan 2013 23:39:00 GMT http://www.javiertordable.com/desktop-computer-in-2-inch-cube <p> The <a href="http://www.solid-run.com/cubox">CuBox</a>: </p> <img src="http://www.javiertordable.com/img/cubox.jpg" alt="The CuBox, a desktop computer in a 2 inch cube" class="big" /> <p> It would be very cool for example to make a Linux-based media player hooked to the TV. Or maybe something more original like a cloud based toaster... </p> DNA http://www.javiertordable.com/dna Sun, 02 Dec 2012 21:08:25 GMT http://www.javiertordable.com/dna <img src="http://www.javiertordable.com/img/dna.jpg" alt="DNA strand, as seen from an electron microscope" class="big" /> <p> An electron microscope has imaged threads of DNA directly for the first time: </p> <p class="special-text"> "<a href="http://pubs.acs.org/doi/abs/10.1021/nl3039162"> Here</a> we report on the direct imaging of double stranded (ds) λ-DNA in the A conformation, obtained by combining a novel sample preparation method based on super hydrophobic DNA molecules self-aggregation process with transmission electron microscopy (TEM). The experimental breakthrough is the production of robust and highly ordered paired DNA nanofibers that allowed its direct TEM imaging and the double helix structure revealing." </p> A Free and Open Internet http://www.javiertordable.com/free-and-open-internet Mon, 26 Nov 2012 00:54:42 GMT http://www.javiertordable.com/free-and-open-internet <p> On December 3rd, the world’s governments will meet to update a key treaty of a UN agency called the <a href="http://www.protectinternetfreedom.org/"> International Telecommunication Union (ITU)</a>. Some governments are proposing to extend ITU authority to Internet governance in ways that could threaten Internet openness and innovation, increase access costs, and erode human rights online. </p> <p> A free and open world depends on a <a href="http://www.google.com/intl/en/takeaction/whats-at-stake/"> free and open Internet.</a> Governments alone, working behind closed doors, should not direct its future. The billions of people around the globe who use the Internet should have a voice. </p> <iframe width="600" height="338" src="http://www.youtube.com/embed/z-lwA9GJ1e0" frameborder="0" class="big" allowfullscreen></iframe> <p> Please take action <a href="http://www.google.com/intl/en/takeaction/what-you-can-do/"> to support a free and open internet</a>. </p> How to make icons using only CSS http://www.javiertordable.com/icons-using-only-css Sat, 24 Nov 2012 19:24:29 GMT http://www.javiertordable.com/icons-using-only-css <p> A few days ago I had the chance to watch a talk by <a href="http://stevesouders.com/">Steve Souders</a>, who is one of the world's top experts on website performance. I started thinking about how to apply some of the techniques that he mentions to my site, and I decided to replace the icons that appear at the top. These are links to subscribe to blog updates, the RSS feed, the feedburner email subscription, and links to twitter and Google+, which I update when there are new blog posts. I decided to replace these image icons with icons made using only CSS. </p> <p> This has several advantages: </p> <ul> <li>4 HTTP calls less. And as the number of TCP connections from the browser is limited, this would allow other content to be downloaded faster <li>Potentially one DNS call less, because the g+ icon is in a different domain than most of the blog <li>A few less KB of data that need to be transmitted over the wire <li>3 less requests to the AppEngine web server, for the images <li>Nicer, more sleek look, which is resolution independent. Try zooming into the icons! </ul> <p> So here is how I did it. First, the general style for all the buttons. Using the same color schema as the rest of the blog: </p> <pre class="prettyprint"> /* Subscribe icons */ .subscribe-icon { /* Little boxes on the right side. */ display: inline; float: right; /* Same colors as the title. */ color: #eee; background-color: #34343e; /* Buttons with rounded corners, 2 px between them. */ margin: 1px; border-radius: 4px; } </pre> <p> The twitter icon is probably the easiest one, I simply took a <em>t</em> in an appropriate font, and gave it a reasonable size and position. I added a little bit of shadow to give it depth: </p> <pre class="prettyprint"> /* Lowercase t in a box. Similar to the twitter logo. */ .twitter-icon { font-family: monospace; font-weight: bold; font-size: 24px; text-shadow: 1px 1px #aaa; width: 20px; height: 22px; padding: 1px 0px 0px 4px; } </pre> <p> The Google+ icon is very similar, but with <a href="http://www.w3schools.com/cssref/pr_pos_overflow.asp"> overflow: hidden</a> to make the text out of the box dissappear: </p> <pre class="prettyprint"> /* g+ text overflowing from a box. Similar to the Google+ icon. */ .gplus-icon { font-family: times, serif; font-size: 27px; text-shadow: 1px 1px #aaa; /* Cut the text outside of the box. */ overflow: hidden; width: 24px; height: 23px; } </pre> <p> The email icon has another twist, it uses a special Unicode character that represents an envelope. This trick is commonly used in many sites, for example for zippys: </p> <pre class="prettyprint"> &lt;span class="subscribe-icon email-icon"&gt;&amp;#009993;&lt;/span&gt; </pre> <p> The CSS of the button is basically the same: </p> <pre class="prettyprint"> /* Unicode envelope character inside of a box. */ .email-icon { font-weight: 600; font-size: 23px; width: 20px; height: 18px; padding: 3px 2px 2px 2px; } </pre> <p> Finally, the RSS button, which is the most complex one. The <em>waves</em> are made as circles, in which the left and bottom parts are hidden. It has 5 parts: </p> <ul> <li>The outside button, which similar to the other 3 buttons <li>The dot at the bottom left <li>A top right quadrant of a circle, in small size <li>Another quadrant, but a little bit bigger <li>Most importantly, a container box for the circles, which hides the rest of the objects and allows to see only one quadrant </ul> <p> This is the HTML: </p> <pre class="prettyprint"> &lt;a href="/blog/rss.xml"&gt; &lt;span class="subscribe-icon rss-icon"&gt; &lt;span class="rss-icon-dot"&gt;.&lt;/span&gt; &lt;span class="rss-icon-container"&gt; &lt;span class="rss-icon-small-wave"&gt;&amp;nbsp;&lt;/span&gt; &lt;span class="rss-icon-big-wave"&gt;&amp;nbsp;&lt;/span&gt; &lt;/span&gt; &lt;/span&gt; &lt;/a&gt; </pre> <p> And the CSS: </p> <pre class="prettyprint"> /* Outer box for the RSS icon. */ .rss-icon { width: 22px; height: 23px; padding-left: 2px; } /* The dot at the bottom left of the RSS icon. */ .rss-icon-dot { font-family: times, serif; font-size: 36px; position: relative; left: -1px; top: -3px; } /* Container that marks the borders of the RSS icon waves. */ .rss-icon-container { display: block; width: 20px; height: 20px; /* Show only one quadrant. Hide the rest of the circle. */ overflow: hidden; position: relative; left: 1px; top: -29px; } /* The small wave at the right of the icon. Only one quadrant. */ .rss-icon-small-wave { display: block; width: 16px; height: 16px; border-style: solid; border-width: 3px 3px 0px 0px; border-radius: 50%; border-color: #eee; position: relative; left: -8px; top: 9px; } /* The big wave at the right of the icon. Only one quadrant. */ .rss-icon-big-wave { display: block; width: 28px; height: 28px; border-style: solid; border-width: 3px 3px 0px 0px; border-radius: 50%; border-color: #eee; position: relative; left: -14px; top: -15px; } </pre> <p> As the end result, this is how the icons look like, made with just a few bytes of CSS: </p> <img src="http://www.javiertordable.com/img/css-icons.png" alt="Icons made using only CSS"> <p> I hope that was useful. If you have a website check out what icons you can convert to CSS. And if you liked the post, don't forget to share using the Google+ button. </p> Two emacs tips http://www.javiertordable.com/two-emacs-tips Sun, 04 Nov 2012 17:54:26 GMT http://www.javiertordable.com/two-emacs-tips <p> I've been using emacs for a few years now. And even though I am not an expert I appreciate how powerful it is. It never ceases to amaze me how many configuration options are available. </p> <p> The first tip I want to share is about formatting rules. For example, I write my code in lines of at most 80 characters (and you all should do too, see the <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Line_Length#Line_Length"> style guide</a>). It's nice to have an indication from the editor if the line is longer. So I set up emacs to turn the font weight to bold when the line is too long. I also have a special configuration to indicate tabs (which are <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Spaces_vs._Tabs#Spaces_vs._Tabs"> forbidden</a>) and trailing whitespaces at the end of the line (which are <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Horizontal_Whitespace#Horizontal_Whitespace"> forbidden as well</a>). </p> <!-- Include prettify for lisp. --> <script src="/js/prettify/prettify.js"> </script> <p> <pre class="prettyprint lang-lisp"> <span class="nocode">;; Special fonts for > 80 chars, tabs and trailing whitespace.</span> (custom-set-faces <span class="nocode">&#39;</span>(my-long-line-face ((((class color)) (:weight bold))) t) <span class="nocode">&#39;</span>(my-trailing-space-face ((((class color)) (:background "PeachPuff"))) t)) <span class="nocode">;; Mark lines longer than 80 characters, and indicate trailing whitespace.</span> (add-hook <span class="nocode">&#39;</span>font-lock-mode-hook (function (lambda () (setq font-lock-keywords (append font-lock-keywords <span class="nocode">&#39;</span>(("^.\\{81,\\}$" (0 <span class="nocode">&#39;</span>my-long-line-face t)) ("[ \t]+$" (0 <span class="nocode">&#39;</span>my-trailing-space-face t)))))))) </pre> </p> <p> The second tip is to enable emacs to highligt links, to be able to click on them from within emacs and open the link in <a href="https://www.google.com/intl/en/chrome/browser/">Chrome</a>. Or if you want to use the keyoard only, move to the link and press C-c &lt;RET&gt;. </p> <p> <pre class="prettyprint lang-lisp"> <span class="nocode">;; Add Chrome to the $PATH.</span> (add-to-list <span class="nocode">&#39;</span>exec-path "/opt/google/chrome") <span class="nocode">;; Set it as default.</span> (setq browse-url-browser-function <span class="nocode">&#39;</span>browse-url-generic browse-url-generic-program "chrome") <span class="nocode">;; After loading the file, follow links.</span> (add-hook <span class="nocode">&#39;</span>find-file-hook <span class="nocode">&#39;</span>goto-address-mode) </pre> </p> <p> And with these changes emacs looks like this: </p> <img src="http://www.javiertordable.com/img/emacs-configuration-options.png" alt="emacs configuration options" /> The Chromebook http://www.javiertordable.com/chromebook Sun, 21 Oct 2012 23:17:56 GMT http://www.javiertordable.com/chromebook <p> Today, I'm just going to do a little bit of self-promotion. A few days ago Google announced the launch of the new <a href="http://www.google.com/intl/en/chrome/devices/"> Chromebook</a>. The Chromebook is a very low cost laptop (249$ as I write this) which works a little bit different than many other computers. All the data is basically stored in the cloud, and the laptop has apps for <a href="http://www.google.com/intl/en/chrome/devices/features-learnmore.html"> the most common uses</a>, navigating the internet, checking mail, playing games, etc. One does not need to worry for example about "files" or configuration, which is the case when using other operating systems. </p> <img src="http://www.javiertordable.com/img/chromebook-1.jpg" alt="The Google Chromebook" class="big" /> <p> In this sense, the Chromebook is closer to a phone than a deskptop computer. Obviously the form factor is that of a laptop, which enables using it for productivity applications, writing long emails, and watching video comfortably. But the simplicity of usage, permanent conectivity, and sandboxed Chrome environment resemble more closely the functionality of a smartphone. </p> <img src="http://www.javiertordable.com/img/chromebook-2.jpg" alt="The Google Chromebook" class="big" /> <p> Nevertheless, it has limitations. And it's not for everybody. For example I don't think I could install <a href="http://www.gnu.org/software/emacs/">emacs</a>, <a href="http://git-scm.com/">git</a> and <a href="http://gcc.gnu.org/">gcc</a> in this machine and do software engineering. And the same concerns would apply to anyone who requires specialized applications like photo editing, scientific software, games outside the browser, etc. Also, not everybody will be comfortable keeping most of their data in the cloud. But I think that for the vast majority of people, the Chromebook is a perfectly reasonable computer. Capable to do 99% of what most people do with computers, and at an amazing price. </p> The History of Mathematics http://www.javiertordable.com/history-of-mathematics Sun, 14 Oct 2012 21:40:40 GMT http://www.javiertordable.com/history-of-mathematics <p> Today I would like to share a <a href="https://www.youtube.com/course?list=EC55C7C83781CF4316&feature=plcp"> Youtube video course on the History of Mathematics</a>. I haven't watched all of it, but I liked the part that I saw. Here is one of the videos, on projective geometry: </p> <iframe class="big" width="600" height="338" src="http://www.youtube.com/embed/NYK0GBQVngs?list=EC55C7C83781CF4316&amp;hl=en_US" frameborder="0" allowfullscreen></iframe> <p> This reminded me of a book that I read on my last summer after high school. It was probably the reason that I decided to study Mathematics in university (in addition to Computer Science). It's called <a href="http://www.amazon.com/gp/product/0486409163/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0486409163&linkCode=as2&tag=javitordblogo-20"> Mathematics: Its Content, Methods and Meaning </a> in it's English translation. It was written by some of the best Russian Mathematicians of the last century. It covers most major branches of Mathematics and it's written in a very accessible style. When I read it I became fascinated by the sheer beauty and incredible variety of Mathematics. I'm very happy to see that Dover published a new edition recently. If you have any interest in Mathematics, I would highly recommend that you take a look at it. </p> <a href="http://www.amazon.com/gp/product/0486409163/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0486409163&linkCode=as2&tag=javitordblogo-20"> <img src="http://www.javiertordable.com/img/mathematics-contents-methods-meaning.jpg" alt="Mathematics: Its Content, Methods and Meaning" /> </a> How to create a mind http://www.javiertordable.com/how-to-create-a-mind Sun, 30 Sep 2012 23:33:43 GMT http://www.javiertordable.com/how-to-create-a-mind <p> Like many Software Engineers and Computer Scientists, I've always been interested in Artificial Intelligence (AI). When people outside of the field think about AI, they normally think about computers that can behave like humans in the real world. This branch of AI is called Artificial General Intelligence. And despite how popular it is in science fiction, in the real world there has been little progress towards the goal of creating an intelligent machine. </p> <p> However, that hasn't stopped people from trying. In particular, to propose new comprehensive theories of how a synthetic brain would work. For example, by simulation of a real brain like the <a href="http://bluebrain.epfl.ch/">Blue Brain Project</a>. Or arguing that it's an emergent property of highly interconnected networks, similar to what <a href="http://www.alleninstitute.org/about_us/staff/christof_koch.html"> Christof Koch</a> explains in this talk: </p> <iframe class="big" width="600" height="450" src="http://www.youtube.com/embed/6i9kE3Ne7as" frameborder="0" allowfullscreen></iframe> <p> Ray Kurzweil has decided to contribute another theory in his new book, <a href="http://www.amazon.com/gp/product/0670025291/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0670025291&linkCode=as2&tag=javitordblogo-20"> <em>How to Create a Mind</em></a>: </p> <a href="http://www.amazon.com/gp/product/0670025291/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0670025291&linkCode=as2&tag=javitordblogo-20"> <img src="http://www.javiertordable.com/img/how-to-create-a-mind.png" alt="Ray Kurzweil book: How to Create a Mind"> </a> <p> The book is coming out in November, so I haven't had the chance to read it yet. But a priori the model that he proposes seems reasonable: <em>a self-organizing hierarchical system of pattern recognizers</em>. I will post an update once I have the book in my hands. </p> Data backup in Google AppEngine http://www.javiertordable.com/data-backup-google-appengine Sun, 16 Sep 2012 23:28:05 GMT http://www.javiertordable.com/data-backup-google-appengine <p> Today I'm just going to share a little bit of code to download content from the DataStore in Google AppEngine. A few days ago I was worried about not having a recent backup of my blog. So I decided to write some code to download all the blog content in a convenient <a href="http://docs.python.org/library/zipfile.html"> ZIP file</a>. Here it is: </p> <pre class="prettyprint"> class Backup(webapp.RequestHandler): """Handler to download a file with a backup of the site. Beware of the maximum response size in AppEngine, which could cause failures with big files. """ def get(self): # Set up headers for the browser to correctly recognize the ZIP file. self.response.headers['Content-Type'] ='application/zip' self.response.headers['Content-Disposition'] = \ 'attachment; filename=' + BACKUP_FILE_NAME # Write ZIP file directly to output stream. output = ZipFile(self.response.out, "w", ZIP_DEFLATED) # Compress posts and emit them directly to HTTP response stream. # Encode file_name as ASCII, which is what the zipfile library uses. for post in app.get_all_posts_and_drafts(): file_name = BACKUP_POSTS_DIRECTORY + post.title + '.txt' file_info = ZipInfo() file_info.filename = file_name.encode('ascii', 'ignore') file_info.date_time = (post.date.year, post.date.month, post.date.day, post.date.hour, post.date.minute, post.date.second) file_info.external_attr = 0644 << 16L # R/W permissions. post_content = 'Title: ' + post.title + '\nDate: ' + str(post.date) \ + '\nUrl: ' + post.desired_url + '\n\n' + post.content output.writestr(file_info, post_content.encode('ascii', 'ignore')) # Now add the images. Same as before, encode the file_name as ASCII. for image in app.get_all_images(): file_name = BACKUP_IMAGES_DIRECTORY + image.name file_info = ZipInfo() file_info.filename = file_name.encode('ascii', 'ignore') file_info.external_attr = 0644 << 16L # R/W permissions. output.writestr(file_info, image.get_data()) output.close() </pre><p> Black Mesa, Nuclear Energy and Thorium http://www.javiertordable.com/black-mesa-nuclear-energy-thorium Thu, 13 Sep 2012 03:28:48 GMT http://www.javiertordable.com/black-mesa-nuclear-energy-thorium <p> I was recently in the Denver area, and while driving around I saw directions to a place called Mesa. This reminded me of Black Mesa, which is the <a href="http://en.wikipedia.org/wiki/Black_Mesa_Research_Facility#Black_Mesa_Research_Facility"> location of the original Half Life game</a>. The game actually starts after some kind of nuclear accident, which opens an inter-dimensional portal. </p> <img src="http://www.javiertordable.com/img/black-mesa-research-facility.jpg" alt="Black Mesa research facility" class="big"/> <p> Now in real life, Black Mesa holds simply a rocket testing center. And nuclear accidents don't open inter-dimensional portals, but have other kinds of <a href="http://www.greenpeace.org/international/en/campaigns/nuclear/safety/accidents/Fukushima-nuclear-disaster/"> consequences</a>. </p> <p> To bring the discussion back on topic, I wanted to mention a great video about an alternative form of nuclear power generation which has many advantages over conventional methods. The alternative is <a href="http://en.wikipedia.org/wiki/Thorium-based_nuclear_power"> Thorium-based nuclear power</a>. </p> <iframe width="600" height="338" class="big" src="http://www.youtube.com/embed/N2vzotsvvkw" frameborder="0" allowfullscreen></iframe> Mathematics at Google http://www.javiertordable.com/mathematics-at-google Fri, 24 Aug 2012 19:32:38 GMT http://www.javiertordable.com/mathematics-at-google <p> There is a wide variety of Mathematics used at Google. For example Linear Algebra in the PageRank algorithm, used to rank web pages in search results. Or Game Theory, used in ad auctions, or Graph Theory in Google Maps. At Google there are literally dozens of products which use interesting Mathematics. These are not just research prototypes, but real Google products; in which Mathematics play a crucial role. </p> <p> In this presentation, I introduce several applications of Mathematics at Google. I begin with a detailed explanation of search on the web and PageRank. Then I show a dozen examples of Google products and the corresponding Mathematics that are used. The presentation has an extensive list of links and references. And it's available in English and Spanish. To access the PDF file, simply click on the links or the images below. </p> <p> <div class="special-text"> English version: <a href="http://www.javiertordable.com/files/MathematicsAtGoogle.pdf">Mathematics at Google</a> </div> </p> <a href="http://www.javiertordable.com/files/MathematicsAtGoogle.pdf"> <img src="http://www.javiertordable.com/img/mathematics-at-google.png" alt="First slide of a presentation about Mathematics at Google." class="big"> </a> <p> <div class="special-text"> Presentación en Español: <a href="http://www.javiertordable.com/files/MatematicasEnGoogle.pdf">Las Matemáticas en Google</a> </div> </p> <a href="http://www.javiertordable.com/files/MatematicasEnGoogle.pdf"> <img src="http://www.javiertordable.com/img/matematicas-en-google.png" alt="Presentación sobre las Matemáticas en Google." class="big"> </a> <p> If you have any comments or if you liked the presentation or found a mistake, please <a href="http://plus.google.com/115448600022457507975/"> send me a message</a> and let me know. </p> Guice and Dependency Injection http://www.javiertordable.com/guice-dependency-injection Wed, 15 Aug 2012 05:43:14 GMT http://www.javiertordable.com/guice-dependency-injection <p> Recently I've been learning a little bit about Google Guice (pronounced like juice) and dependency injection. In case you are not familiar with dependency injection, a good introduction is this article by <a href="http://martinfowler.com/articles/injection.html"> Martin Fowler</a>. Guice is a framework for dependency injection in Java made by Google. It's well explained in the talk below, which Jesse Wilson and Dhanji Prasanna gave at Google IO a few years back. </p> <iframe class="big" width="600" height="450" frameborder="0" allowfullscreen src="http://www.youtube.com/embed/hBVJbzAagfs"> </iframe> <p> Guice provides <em>@</em> annotations for constructs that would take longer to build using plain Java. For example <em>@Singleton</em> seems very useful, as well as <em>@RequestScoped</em> and <em>@SessionScoped</em> in App Engine applications. I can see how these can make the code simpler for experts in Guice. But they can also make the learning curve steeper for programmers that are not so well versed in dependency injection. </p> <p> Guice has advantages and disadvantages with respect to other techniques. For example, it encourages use of interfaces and well defined APIs which results in stronger compartmentalization. However, it requires the creation of Module classes to register injection bindings. These classes must have knowledge of whole systems, and are closely tied to many other classes, somehow weakening the compartmentalization. Another example, one would need to look at least in two places to understand how a request in one class is executed in another class. This is because the dependency is not listed in the class itself. If every dependency is handled though injection this may be cumbersome. </p> <p> If all that was confusing, here is a code sample: </p> <p> <strong>Demo.java</strong> </p> <pre class="prettyprint" style="line-height: 1.2em;"> import com.google.inject.Guice; import com.google.inject.Injector; /** * Guice demo. Get an instance of the billing service through injection * and use it. The {@link DemoModule} sets up the {@link BillingService} * with the correct bindings. */ public class Demo { /** * Launch the Guice demo. Create a billing service and use it. * * @param args ignored. */ public static void main(String args[]) { Injector injector = Guice.createInjector(new DemoModule()); BillingService billingService = injector.getInstance(BillingService.class); billingService.chargeOrder(1234); } } </pre> <p> <strong>DemoModule.java</strong> </p> <pre class="prettyprint" style="line-height: 1.2em;"> import com.google.inject.AbstractModule; /** * The {@code DemoModule} will set up the Guice bindings for the Demo * application. */ public class DemoModule extends AbstractModule { @Override protected void configure() { // Whenever a Transaction Processor is needed, return a // real transaction processor. bind(TransactionProcessor.class).to(RealTransactionProcessor.class); } } </pre> <p> <strong>BillingService.java</strong> </p> <pre class="prettyprint" style="line-height: 1.2em;"> import com.google.inject.Inject; import java.util.logging.Logger; /** * The {@code BillingService} allows charging a given amount. In order to * do that it relies on a {@link TransactionProcessor} to actually process * the transaction. */ public class BillingService { private final Logger logger = Logger.getLogger(BillingService.class.getName()); // The actual processor that will execute the transaction. private final TransactionProcessor processor; @Inject public BillingService(TransactionProcessor processor) { this.processor = processor; } /** * Charge the given amount. * * @param amount is the currency amount to charge. * @returns {@code true} if successful, {@code false} if not. */ public boolean chargeOrder(int amount) { logger.info("Billing service charging amount."); return processor.charge(amount); } } </pre> <p> <strong>BillingServiceTest.java</strong> </p> <pre class="prettyprint" style="line-height: 1.2em;"> import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertThat; import static org.hamcrest.core.Is.is; import java.util.logging.Logger; /** * Tests for {@link BillingService}. */ public class BillingServiceTest { private BillingService billingService; @Before public void setUp() { // Set up the BillingService injecting a mock transaction processor. Injector injector = Guice.createInjector(new TestModule()); billingService = injector.getInstance(BillingService.class); } /** * Binding overrides with mock test classes. */ private class TestModule extends AbstractModule { @Override protected void configure() { bind(TransactionProcessor.class).to(MockTransactionProcessor.class); } } @Test public void testChargeBillingService() { assertThat(billingService.chargeOrder(1234), is(true)); } } </pre> <p> You can learn more about Guice <a href="http://code.google.com/p/google-guice/">here</a>. </p> Writing Tools http://www.javiertordable.com/writing-tools Sun, 12 Aug 2012 02:46:29 GMT http://www.javiertordable.com/writing-tools <p> I would like to share a quick note about some writing tools that I've been using lately. </p> <p> The first one is <a href="http://www.iawriter.com/"> iaWriter</a>. It's an iPad app with a focus on simplicity, which enables concentrating in the text itself. It has support for saving files in Dropbox, but considering the <a href="http://www.google.com/webhp?#hl=en&q=dropbox+insecure"> security problems that Dropbox has</a> I'd rather not use it. I end up sending files to myself over email. The files are just plain text files, with <a href="http://support.iawriter.com/help/kb/general-questions/markdown-syntax-reference-guide"> Markdown syntax</a>. </p> <a href="http://www.iawriter.com/"> <img alt="iaWriter, an editor for iPad" class="big" src="http://www.javiertordable.com/img/iawriter.png"> </a> <p> And there is where the second tool comes in. <a href="http://johnmacfarlane.net/pandoc/index.html"> pandoc</a> allows converting the plain text Markdown files into a wide variety of output formats. For example: HTML (which I can then paste into the blog), LaTeX (if I want to write a paper) or EPUB (so that I can publish it later as an eBook). The chart below should give you an idea of the many formats supported by pandoc. </p> <a href="http://johnmacfarlane.net/pandoc/index.html"> <img alt="pandoc, a document editor" class="big" src="http://www.javiertordable.com/img/pandoc.jpg"> </a> <p> Also, as a curiosity, pandoc is written in <a href="http://www.haskell.org/haskellwiki/Haskell"> Haskell</a>!. For those of you not familiar with Haskell I recommend this <a href="http://steve-yegge.blogspot.com/2010/12/haskell-researchers-announce-discovery.html"> post by Steve Yegge</a>. </p> <p> Of course, there are many more editors that support Markdown, as well as more powerful editing. However, I find that I only need to do simple tasks on the iPad. For anything that is more complicated, I prefer to use the computer. And in that case the best editor that I know is, by far, <a href="http://www.lyx.org/Home">Lyx</a>. </p> <a href="http://www.lyx.org/"> <img alt="Lyx, the best editor ever" class="big" src="http://www.javiertordable.com/img/lyx.png"> </a> <p> I hope some of these tools will be useful for you. Or, if you have better recommendations, drop me a line on <a href="http://plus.google.com/115448600022457507975/"> Google+</a>. </p> Beautiful Mathematics in All Browsers http://www.javiertordable.com/beautiful-mathematics-all-browsers Fri, 03 Aug 2012 03:20:45 GMT http://www.javiertordable.com/beautiful-mathematics-all-browsers <p> I recently discovered the wonderful <a href="http://www.mathjax.org/">MathJax</a>. MathJax is a JavaScript library that displays mathematical formulas in web pages. It's very easy to set up and it renders beautiful mathematics. </p> <a href="http://www.mathjax.org/"> <img src="http://www.javiertordable.com/img/mathjax.gif" alt="MathJax logo" /> </a> <p> For example: </p> <p style="margin-left: 2em;"> <em> Suppose \( U \) is an open subset of the complex plane \( \mathbb{C} \), \( f : U → \mathbb{C} \) a holomorphic function, and the closed disk \( D = \{z : |z − z_0| ≤ r\} \) is completely contained in \( U \). Let \( \gamma \) be the circle forming the boundary of \( D \). Then for every a in the interior of \( D \): </em> $$ f(a) = \frac{1}{2 \pi i} \oint_{\gamma}{ \frac{f(z)}{z-a} dz} $$ <em> where the contour integral is taken counter-clockwise. </em> </p> <p> That is, of course, <a href="http://en.wikipedia.org/wiki/Cauchy%27s_integral_formula"> Cauchy's integral formula</a>. </p> An Atom http://www.javiertordable.com/atom-picture Sun, 15 Jul 2012 22:33:32 GMT http://www.javiertordable.com/atom-picture <img src="http://www.javiertordable.com/img/single-atom-picture.jpg" alt="Picture of an atom" class="big" /> <p class="special-text"> "In an international scientific breakthrough, a <a href="http://www3.griffith.edu.au/03/ertiki/tiki-read_article.php?articleId=37742">Griffith University</a> research team has been able to photograph the shadow of a single atom for the first time." </p> How to Resize All Images in a Directory http://www.javiertordable.com/how-to-resize-all-images-in-a-directory Sun, 08 Jul 2012 18:54:33 GMT http://www.javiertordable.com/how-to-resize-all-images-in-a-directory <p> At some point or another, pretty much everybody has had to bulk process all the images in a directory. Either to resize them to a smaller size to share them, or do some other simple transformation. Well, here is a very easy way to do it with a dozen lines of Python. </p><p></p><pre class="prettyprint"># Resize all images in a directory to half the size. # # Save on a new file with the same name but with "small_" prefix # on high quality jpeg format. # # If the script is in /images/ and the files are in /images/2012-1-1-pics # call with: python resize.py 2012-1-1-pics import Image import os import sys directory = sys.argv[1] for file_name in os.listdir(directory): print("Processing %s" % file_name) image = Image.open(os.path.join(directory, file_name)) x,y = image.size new_dimensions = (x/2, y/2) output = image.resize(new_dimensions, Image.ANTIALIAS) output_file_name = os.path.join(directory, "small_" + file_name) output.save(output_file_name, "JPEG", quality = 95) print("All done")</pre><p></p> No more handmade HTML http://www.javiertordable.com/handmade-html Sun, 17 Jun 2012 06:31:00 GMT http://www.javiertordable.com/handmade-html Normally I write all the posts in this&nbsp;blog manually, including all the HTML, paragraphs, links, images, etc. But a few days ago I found a great in-browser HTML5 editor,&nbsp;<a href="http://xing.github.com/wysihtml5/">http://xing.github.com/wysihtml5/</a>. It's&nbsp;made in JavaScrip and it's very easy to integrate into a web app. So now to add a new post, instead of this:<br><img style="border:1px solid;" alt="Nounoublog HTML editor" src="http://www.javiertordable.com/img/nounoublog-editor-before.jpg">I can just write the text right away:<br><img style="border:1px solid;" alt="Nounoublog HTML editor" src="http://www.javiertordable.com/img/nounoublog-editor-after.jpg"><br>Isn't that nice? Introducing Synthetic Biology http://www.javiertordable.com/introducing-synthetic-biology Fri, 15 Jun 2012 01:50:30 GMT http://www.javiertordable.com/introducing-synthetic-biology <p> If you are not familiar with Synthetic Biology, you should watch the following video. It's a very well made introduction to one of the most promising fields in technology. </p> <iframe width="600" height="338" style="margin-left: -30px;" src="http://www.youtube.com/embed/rD5uNAMbDaQ?rel=0" frameborder="0" allowfullscreen> </iframe> New Blog Design http://www.javiertordable.com/new-blog-design Wed, 06 Jun 2012 06:51:55 GMT http://www.javiertordable.com/new-blog-design <p> Welcome to the new sleek and minimalistic design of the blog! Take a look at the page source for the beautifully handcrafted HTML and CSS. Now with the option to include big images. For example, this completely unrelated picture of <a href="https://plus.google.com/111626127367496192147/posts"> Project Glass</a>. </p> <img src="http://www.javiertordable.com/img/glass-photo.jpg" class="big" alt="Google project glass" /> More Cool Technology http://www.javiertordable.com/more-cool-technology Fri, 27 Apr 2012 22:54:52 GMT http://www.javiertordable.com/more-cool-technology <p> Two very cool pieces of technology that I saw in the news recently: </p> <p> A nano-engineered glass that is anti-fogging, self-cleaning and without glare </p> <iframe width="540" height="300" src="http://www.youtube.com/embed/8he2oKAR8IE" frameborder="0" allowfullscreen></iframe> <p> More info <a href="http://www.kurzweilai.net/through-a-glass-clearly">here</a> </p> <p> And an original application of existing technology, a maglev based <em>vacuum tube for people</em> </p> <iframe width="540" height="300" src="http://www.youtube.com/embed/McpWcn-1RZU" frameborder="0" allowfullscreen></iframe> <p> Taken from <a href="http://singularityhub.com/2012/04/26/from-d-c-to-beijing-in-2-hours-evacuated-tube-transport-could-revolutionize-how-we-travel/"> here</a> </p> Calorie Restriction and Living Longer http://www.javiertordable.com/calorie-restriction-and-living-longer Sun, 26 Feb 2012 21:38:32 GMT http://www.javiertordable.com/calorie-restriction-and-living-longer <p> During the twentieth century the life expectancy grew from an average of 47 years to about 70-80 years, in part because of improved healthcare and hygiene as well as the development of antibiotics and vaccines. In some places even greater incidence of extraordinary life spans has even been observed, like the Okinawan Japanese, who have the <a href="http://edition.cnn.com/2008/HEALTH/12/02/okinawa.aging/index.html"> highest number of centenaries in the world</a>. This cannot be explained by the same improvements that led to the extension of life expectancy elsewhere in the world. The quest to unveil the reasons behind their increased longevity has captured the mind of biogerontologists, who have spent decades investigating the causes, mechanisms and consequences of aging. <a href="http://www.javiertordable.com/blog/2011/08/19/modern-quest-for-immortality"> Dr. Aubrey de Grey</a>, the leader of the strategies for engineered negligible senescence (SENS) foundation, suggests that </p> <div id="special-text"> <p> Aging exists in nature for just the same reason that aging exists in man-made structures and machines: it is the default, and genes are required to combat it, just as mechanics and their ilk are required to combat the aging of man-made objects. </p> </div> <p> Today, with the help of modern medicine and science, researchers have been making great progress in understanding how the aging process works and how we can control or even reverse it to some extent. The SENS foundation (and its affiliated researchers) has been pivotal to this effort, being involved in bringing innovation such as <a href="http://sens.org/sens-research/extra-mural/projects/immunorejuvenation-at-arizona">rejuvenating the immune system to better fight disease</a> in later years or <a href="http://www.parkinsons.org.uk/about_us/news/news_items/all_news/stem_cells_through_the_nose.aspx">using stem cells to treat Parkinson's disease</a>. Other unaffiliated biogerontologists have also made remarkable advancements like the development of a <a href="http://www.sciencedaily.com/releases/2011/12/111207113552.htm">drug that might reverse aging-related decline of the brain.</a> </p> <p> While these new techniques and breakthroughs are very exciting, we are still at least a few decades away from seeing practical applications. However, there are two lifestyle factors which can have a remarkable effect on how we age, and are well within our control: exercise and diet. Exercise is a good strategy to stave off <em>secondary</em> aging (aging that comes as a consequence of disease), as it can be seen by its effect on the <a href="http://www.sciencedaily.com/releases/2011/10/111004221112.htm"> health of people suffering from kidney disease</a> or in the <a href="http://www.sciencedaily.com/releases/2011/08/110815095727.htm"> prevention of damage linked to Alzheimer's disease</a>. A good diet can not only have benefits when it comes to <em>secondary</em> aging, but it can even extend the maximum life span slowing down <em>primary</em> (disease independent) aging. </p> <h3>Diet and life extension</h3> <p> When it comes to diet, attention tends to be immediately drawn to healthy eating (something that nutritionists have been advocating for decades) as the ultimate goal, but even more can be potentially accomplished with dietary change. A very successful strategy for increasing life span is, in fact, <a href="http://www.fightaging.org/archives/2001/11/calorie-restriction-explained.php">calorie restriction</a>. Something as simple as reducing the amount of energy we obtain from food beyond the recommended daily intake levels, while ensuring that the diet still includes enough nutrients. </p> <img src="http://www.javiertordable.com/img/calorie-restriction.jpg" alt="Calorie restriction diet." /> <p> Although this idea might seem counter-intuitive, eating less may make it possible to live longer. Several <a href="http://news.sciencemag.org/sciencenow/2009/07/09-01.html"> studies conducted on animals</a> prove that. In particular, studies on mice reveal a very interesting trend. Individuals which had a diet with the full recommended daily dosage of nutrients but with calorie restriction lived longer if they started on a calorie restricted diet early, just after their growing period. In fact, such a strategy extended life up to an incredible 80% in young animals and still provided a 20-30% increase in lifespan of animals which were already middle-aged by the time their diet was changed. Still, the benefits did not stop there, not only did the animals live longer, but they were healthy throughout the course of their lives. In Rhesus monkeys (who share more in common with humans than rats), long-term studies are now being carried out and preliminary reports (at a stage where monkeys have reached their average life expectancy) point to a three-fold difference in deaths due to age-related illness between a calorie restricted group and monkeys fed a regular diet. </p> <h3>How calorie restriction works</h3> <p> Our bodies accumulate energy in the form of a reusable molecule, <a href="http://en.wikipedia.org/wiki/Adenosine_triphosphate">ATP</a>. Every time we breathe, move or even think we use ATP, which then needs to be recharged. That happens in specific sites in our cells, the <a href="http://en.wikipedia.org/wiki/Mitochondria">mitochondria</a>, which are structures akin to power stations, where a number of complex reactions (which depend on the presence of oxygen) spring life back into the ATP molecule in a never ending cycle. However, sometimes that operation malfunctions and the oxygen we breathe (which is essential for the whole process) is affected in an undesirable fashion, creating damaging molecules which would cause havoc if left to roam free. To stop these molecules our cells have mechanisms designed to neutralize them, a task at which they are fairly effective during youth (although damage often starts decades before any symptoms are evident). But they become less and less so as the years go by, when damage progressively becomes rampant. </p> <a href="http://www.amazon.com/gp/product/B000XPRRTY/ref=as_li_tf_tl?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B000XPRRTY"> <img src="http://www.javiertordable.com/img/the-cr-way.jpg" alt="The CR Way book." /> </a> <p> This accumulated damage is likely to be behind the cellular "garbage" which causes Parkinson's or Alzheimer's disease; chronic inflammation responsible for rheumatoid arthritis or atherosclerosis; changes in lipid metabolism, which lead to type 2 diabetes and muscle loss; and many other diseases which tend to lead to premature death. Calorie restriction has been shown to reduce the rate at which all these different types of damage occur and, while the exact molecular mechanisms are not yet clear, is likely to do so on two fronts. First, by increasing the efficiency of the mechanisms that prevent damaging oxygen molecules from having detrimental effects. Second, by reducing the amount of damaging oxygen molecules from the start. In addition, it is hypothesized calorie restriction might reduce the metabolic rate itself. This would be in line with the observation that calorie restricted animals tend to have lower body temperature, but further research on the subject is still needed. </p> <h3>You can live longer too</h3> <p> Human trials conducted so far support the hypothesis that calorie restriction is a valid and useful method in <a href="http://www.javiertordable.com/blog/2010/01/15/trascend-book-kurzweil-grossman"> extending life span</a>. Despite the relatively short duration of the experiments, several studies show calorie restriction has the ability to reduce the effects of secondary aging (for example by <a href="http://www.sciencedaily.com/releases/2010/07/100723112715.htm">starving cancer</a> or <a href="http://www.ecardiologynews.com/specialty-focus/hypertension/single-article-page/diabetes-calorie-restriction-yields-lasting-cardiac-benefit.html"> reducing the severity of diabetes and cardiovascular disease</a>) and even to <a href="http://www.sciencedaily.com/releases/2006/05/060531164818.htm">slow down primary aging</a>, thus extending the maximum lifespan an individual could hope for. In addition, populations which endured food shortages are known to have lived longer and healthier lives. The Okinawan example is, once again, of great relevance. This population had an impoverished diet during world war II which, combined with a <a href="http://en.wikipedia.org/wiki/Okinawa_diet">naturally calorie restricted diet</a>, has made it possible for individuals who were adult when the war broke to be alive today. Although genetic factors may also be in play, the fact younger Okinawans who opted for an approximation to a Western diet are facing much lower life expectancy is a strong indicator calorie restriction was at least partly responsible for the beneficial effects observed. </p> <a href="http://www.amazon.com/gp/product/B003P9XC6W/ref=as_li_tf_tl?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B003P9XC6W"> <img src="http://www.javiertordable.com/img/the-longevity-diet.jpg" alt="The longevity diet book." /> </a> <p> Nevertheless, there are some hazards to this approach. Calorie restriction is <a href="http://en.wikipedia.org/wiki/Calorie_restriction#Not_for_the_young.2C_or_those_with_low_body_fat"> not suitable for children and teenagers</a>, who are in a particular phase of development which requires large energy intake. There is risk of stunted growth and cognitive dysfunction. On the other end of the spectrum, the fact that calorie restriction is correlated with <a href="http://en.wikipedia.org/wiki/Calorie_restriction#Musculoskeletal_losses"> moderate loss of bone and muscle mass</a> exposes the elderly to a potentially larger danger of bone fractures and loss of mobility. Moreover, even on healthy adults this is a strategy which requires significant attention, as particular care is needed to ensure the nutritional needs are consistently met and the energy intake is not too low, since such behaviour effectively consists of starvation. This is very undesirable because it is the percursor of a <a href="http://en.wikipedia.org/wiki/Starvation_response">plethora of metabolic changes</a> leading up to further muscle mass loss as well as hormonal imbalance and increased cellular stress levels, therefore cancelling out all the positive effects of calorie restriction. </p> SOPA Protest in Google App Engine http://www.javiertordable.com/sopa-protest-app-engine Thu, 19 Jan 2012 01:52:46 GMT http://www.javiertordable.com/sopa-protest-app-engine <p> Just for trivia, this is how I implemented the SOPA protest page yesterday. </p> <pre class="prettyprint"> class Sopa(webapp.RequestHandler): """Handler for 503 protest Sopa response.""" def get(self): self.response.set_status(503, 'Service Unavailable') self.response.out.write( '&lt;p&gt;&lt;b&gt;503: Service Unavailable&lt;/b&gt;&lt;/p&gt;' + '&lt;p&gt;www.javiertordable.com is not available today in protest with ' + 'the &lt;a href=\"http://sopastrike.com/\&gt;>Stop Online Piracy Act ' + '(SOPA)&lt;/a&gt;.&lt;/p&gt;') </pre> <p> This would work for any simple Python wsgi Google App Engine application </p> <pre class="prettyprint"> def main(): application = webapp.WSGIApplication([('\.*', Sopa)], debug = False) util.run_wsgi_app(application) </pre> The Robots of Tomorrow http://www.javiertordable.com/the-robots-of-tomorrow Mon, 16 Jan 2012 19:08:54 GMT http://www.javiertordable.com/the-robots-of-tomorrow <p> 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 <a href="http://www.irobot.com/">Roomba</a>. </p> <img src="http://www.javiertordable.com/img/roomba.jpg" alt="Roomba, cleaning" /> <p> On the other hand we have projects that are pushing the boundaries of what is possible to automate. For example the <a href="http://en.wikipedia.org/wiki/Google_car"> Google driverless car</a>, which has recorded thousands of miles of automatic driving in a variety of road environments. </p> <img src="http://www.javiertordable.com/img/google-car.jpg" alt="Google driverless car" /> <p> 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 <a href="http://news.xinhuanet.com/english2010/china/2011-07/30/c_131018764.htm">this</a> or <a href="http://singularityhub.com/2011/12/09/a-drop-in-solution-for-replacing-human-labor-kawadas-nextage-robot/">this</a>). </p> <p> 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 <a href="http://www.willowgarage.com/pages/pr2/overview"> Willow Garage PR2</a>. </p> <img src="http://www.javiertordable.com/img/robot-pr2.jpg" alt="Willow Garage PR2 robot" /> <p> 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. </p> <p> On the software side, I think <a href="http://www.ros.org/wiki/">ROS</a> (Robot Operating System) is a good step in the creation of a platform. It already has a very large set of <a href="http://www.ros.org/wiki/StackList">modules available</a> for all sorts of robot behavior. </p> <p> 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. </p> Google Code Prettify http://www.javiertordable.com/google-code-prettify Mon, 26 Dec 2011 19:43:49 GMT http://www.javiertordable.com/google-code-prettify <p> I just installed the <a href="http://code.google.com/p/google-code-prettify/">Google code prettify library</a> on <a href="http://nounoublog.org">Nounoublog</a>. It's a very small and simple Javascript library to <em>pretty print</em> 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: </p> <pre class="prettyprint"> # Computes the hailstone sequence of an input number # and prints how many iterations it takes to reach 1. # For more info see <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">http://en.wikipedia.org/wiki/Collatz_conjecture</a> 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 </pre> <p> Or more succinctly: </p> <pre class="prettyprint"> while(n > 1): n = (n%2) * (3*n+1) + (1 - n%2) * (n/2); n; </pre> <p> Installing the library was painless. Also, it seems very quick to load. The complete instructions are <a href="http://google-code-prettify.googlecode.com/svn/trunk/README.html">here</a>. </p> <p> PS. Does the program finish for all natural numbers? </p> Enigma, the Hidden Secret of the Third Reich http://www.javiertordable.com/enigma-hidden-secret-third-reich Sun, 11 Dec 2011 23:21:42 GMT http://www.javiertordable.com/enigma-hidden-secret-third-reich <p> 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, <a href="http://en.wikipedia.org/wiki/Caesar_cipher">Julius Caesar</a> 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: </p> <pre> HI THIS IS A SECRET MESSAGE </pre> To encrypt, we can replace each letter with the next letter in the alphabet H->I, I->J and so on: <pre> IJ UIJT JT B TFDSFU NFTTBHF </pre> To decrypt, replace with the previous letter, I->H, J->I, etc.: <pre> HI THIS IS A SECRET MESSAGE </pre> <p> 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 <em>Attack at dawn</em> 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. </p> <p> Here is where cryptography comes into play. If instead of sending a message like <em>Attack at dawn</em> you send an encrypted message, for example: <em>BUUBDL BU EBXO</em> 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. </p> <p> One of the most famous cryptographic mechanisms in history is the system used by German troops during World War II, the <em>Enigma</em>. <a href="http://en.wikipedia.org/wiki/Enigma_(machine)">Enigma</a> is a family of machines that encrypt and decrypt messages based on a complex set of electric and mechanical components. </p> <p> The relevance of the Enigma comes from the fact that it provided encryption that was vastly superior to most previous systems. It allowed the <a href="http://en.wikipedia.org/wiki/U-boat">U-Boat</a> submarines from the <a href="http://en.wikipedia.org/wiki/Third_Reich">Third Reich</a> to attack allied ships without any kind of warning. The Enigma encryption was broken by allied cryptanalysts. It is often said that this achievement <em>hastened the end of the European war by two years</em>. </p> <img src="http://www.javiertordable.com/img/enigma.jpg" alt="Enigma encryption machine" /> <p> Recently I had the chance to see some of these Enigma machines in a visit to Germany. They have some in display in the <a href="http://en.wikipedia.org/wiki/Deutsches_Museum">Deutsches Museum</a> 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. </p> Memcache Optimizations in App Engine http://www.javiertordable.com/memcache-optimizations-app-engine Thu, 01 Sep 2011 06:00:39 GMT http://www.javiertordable.com/memcache-optimizations-app-engine <p> Google just announced that <a href="http://googleappengine.blogspot.com/2011/08/50-credit-for-new-billing-signups-and.html"> App Engine is going to be out of preview soon</a>. 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 <a href="http://www.javiertordable.com/blog/rss.xml">RSS feed</a> 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...). </p> <a href="http://www.javiertordable.com/img/implement-memcache.png"> <img src="http://www.javiertordable.com/img/implement-memcache.png" alt="Implementing memcache diff" width=500 /> </a> The Modern Quest for Immortality http://www.javiertordable.com/modern-quest-for-immortality Fri, 19 Aug 2011 22:12:43 GMT http://www.javiertordable.com/modern-quest-for-immortality <p> 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) <a href="http://en.wikipedia.org/wiki/Harry_Potter_and_the_Philosopher's_Stone"> first Harry Potter novel</a>. </p> <p> 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 <a href="http://sens.org/">SENS</a>. </p> <h3>Aubrey de Grey</h3> <p> 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 <a href="http://en.wikipedia.org/wiki/Mitochondrion">mitochondria</a> 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. </p> <img src="http://www.javiertordable.com/img/sens-foundation.png" alt="SENS Foundation" /> <h3>SENS</h3> <p> 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 <a href="http://en.wikipedia.org/wiki/Actuarial_escape_velocity"> actuarial escape velocity</a> and, consequently, the possibility to live for a very long time, and eventually immortality. </p> <h3>How SENS will help us live longer</h3> <p> In <em><a href="http://www.amazon.com/gp/product/0312367074/ref=as_li_qf_sp_asin_tl?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=217145&creative=399377&creativeASIN=0312367074"> Ending Aging</a> </em>(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 <a href="http://www.sens.org/sens-research/research-themes">SENS approaches designed to tackle </a>them. Very briefly, these are: </p> <ul> <li>RepleniSENS - Cellular loss or atrophy</li> <li>OncoSENS - Mutations that lead to cancer and changes in the proteins that are around DNA</li> <li>ApoptoSENS - Cells which can no longer divide but refuse to die</li> <li>MitoSENS - Mutations in mitochondria</li> <li>LysoSENS - Junk that gets accumulated inside the cells</li> <li>AmyloSENS - Junk that gets accumulated outside the cells</li> <li>GlycoSENS - Random links that cells make and cause tissue to lose its elasticity</li> </ul> <p> 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: </p> <p> <strong>RepleniSENS</strong> 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 href="http://www.parkinsons.org.uk/about_us/news/news_items/all_news/stem_cells_through_the_nose.aspx"> a group of German researchers</a> working under the SENS umbrella discovered a way to administer <a href="http://en.wikipedia.org/wiki/Stem_cell">stem cells</a> 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. </p> <p> Another very exciting field is the one under <strong>AmyloSENS</strong>. 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 <a href="http://newsroom.ucla.edu/portal/ucla/designer-enzymes-created-by-ucla-46985.aspx"> using computer simulation to design enzymes from scratch</a>, so they can be very effective at removing each different type of accumulated junk. </p> <iframe class="video" width="420" height="345" src="http://www.youtube.com/embed/4cRN1Y09-eI" frameborder="0" > </iframe> <h3>Controversy</h3> <p> Even today, the outlook for the SENS project is not clear. In November, <a href="http://www.nature.com/embor/journal/v6/n11/full/7400555.html"> a group of 28 biogerontologists released a response</a> 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 <a href="http://www.technologyreview.com/blog/pontin/14968/"> MIT Technology review</a> 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, <a href="http://www.technologyreview.com/sens/">independent juries analyzed them</a> 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. </p> <h3>Other research projects</h3> <p> 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, <a href="http://news.sciencemag.org/sciencenow/2010/11/the-curious-case-of-the-backward.html?ref=hp"> Harvard researchers</a> took mice whose <a href="http://en.wikipedia.org/wiki/Telomerase">telomerase enzyme</a> 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 <a href="http://en.wikipedia.org/wiki/Progeria">progeria</a>. Similarly, a <a href="http://news.sciencemag.org/sciencenow/2009/07/08-01.html?ref=hp"> collaboration between 3 American universities</a> 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. </p> <h3>The ethical debate on immortality</h3> <p> Part of the reason why SENS became so controversial recently was <a href="http://www.nature.com/embor/journal/v6/n1s/full/7400435.html">the whole new ethical debate it brought about</a> 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. </p> <p> 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 :) </p> <img src="http://www.javiertordable.com/img/aubre-de-grey-immortality.jpg" alt="Aubre de Grey" /> Adding Authorship Data to Your Site http://www.javiertordable.com/adding-authorship-data-to-your-site Sun, 31 Jul 2011 23:11:34 GMT http://www.javiertordable.com/adding-authorship-data-to-your-site <p> I figured out how to add authorship markup in the blog! There is a nice tutorial <a href="http://www.blindfiveyearold.com/how-to-implement-rel-author"> here</a>, and complete documentation in the official <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=1229920">Webmaster Tools authorship help page</a>. But it basically comes down to this: There are two options, with 2 or 3 links. </p> <p> 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. </p> <img src="http://www.javiertordable.com/img/2-way-authorship-link.png" alt="2-way Google Authorship link" /> <p> 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. </p> <img src="http://www.javiertordable.com/img/3-way-authorship-link.png" alt="3-way Google Authorship link" /> <p> In Google+ you can mark a link as rel=me if you indicate that the page is about you. </p> <img src="http://www.javiertordable.com/img/about-me-google-plus.png" alt="Indicate in Google+ that the page is about you" /> <p> After that, you can check that the markup is correct in the <a href="http://www.google.com/webmasters/tools/richsnippets"> Rich Snippets Testing Tool</a>. <img src="http://www.javiertordable.com/img/rich-snippets-testing-tool.png" alt="Rich Snippets Testing tool for authorship" /> <p> Easy enough, right? If you liked this post, or you have any question that I can answer just leave me a note on Google+. </p> <a rel="author" href="http://plus.google.com/115448600022457507975/"> <img src="http://www.google.com/images/icons/ui/gprofile_button-64.png" width="64" height="64"> </a> Two Cool Gadgets http://www.javiertordable.com/two-cool-gadgets Sat, 30 Jul 2011 23:13:09 GMT http://www.javiertordable.com/two-cool-gadgets <p> Just wanted to leave a note on two new cool gadgets that I found online. </p> <img src="http://www.javiertordable.com/img/electron-microscope.jpg" alt="Homemade electron microscope" /> <p> The first one is a homemade <a href="http://en.wikipedia.org/wiki/Electron_microscope"> electron microscope</a>. 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 <a href="http://benkrasnow.blogspot.com/2011/03/diy-scanning-electron-microscope.html"> Ben Krasnow</a> for it. </p> <img src="http://www.javiertordable.com/img/3d-bioprinter.jpg" alt="3D printer capable of printing biological organs" /> <p> The second one is a <a href="http://en.wikipedia.org/wiki/3D_printing"> 3D printer</a> that can be used to print biological organs. <a href="http://www.organovo.com/">Organovo</a> 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? </p> Programmer fonts http://www.javiertordable.com/programmer-fonts Thu, 14 Jul 2011 03:50:44 GMT http://www.javiertordable.com/programmer-fonts <p> I read a few days ago an interesting post about what are the best fonts for programmers (monospaced fonts) at <a href="http://hivelogic.com/articles/top-10-programming-fonts/"> Hivelogic</a>. And I decided to try out one of the fonts, <a href="http://www.levien.com/type/myfonts/inconsolata.html"> Inconsolata</a>. Here you have a screenshot of emacs with it. </p> <img src="http://www.javiertordable.com/img/emacs-inconsolata.png" alt="Screenshot of emacs with Inconsolata font" /> <p> I think it looks very similar to my previous favorite, <a href="http://en.wikipedia.org/wiki/Lucida">Lucida Console</a>. If you want to set it up in emacs (why would you use any other editor?), just edit your .emacs file and add </p> <pre> (set-default-font "Inconsolata-12") </pre> <p> Or something along those lines, depending on your preferred font size. </p> Google+ http://www.javiertordable.com/google-plus Fri, 01 Jul 2011 03:02:54 GMT http://www.javiertordable.com/google-plus <p> <a href="http://plus.google.com/">Google+</a> 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. </p> <img src="http://www.javiertordable.com/img/google-plus-features.jpg" alt="Google Plus Features" /> <p> 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. </p> <img src="http://www.javiertordable.com/img/google-plus-screenshot.jpg" alt="Google Plus Screenshot" /> <p> If you are already on Google+, you can find me <a href="https://plus.google.com/115448600022457507975/">here</a>, if not, send me a message and I will forward an invitation as soon as I have some available! </p> The Google +1 button http://www.javiertordable.com/google-plus-one-button Thu, 02 Jun 2011 03:19:48 GMT http://www.javiertordable.com/google-plus-one-button <p> Google just made the +1 button available for websites. The <a href="http://www.google.com/+1/button/">+1 button</a> is a gadget that allows people to recommend content on the web. It's useful for you because your friends will see your recommendations when they do a related Google search. And it's great for sites because it gives them the chance to see what items people like most. Now any site can <a href="http://www.google.com/webmasters/+1/button/"> add the +1 button following these instructions</a>. And you should also check out the video to see all the cool features of the +1 button. </p> <object width="500" height="314"> <param name="movie" value="http://www.youtube.com/v/OAyUNI3_V2c?version=3&amp;hl=en_US"> </param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/OAyUNI3_V2c?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="480" height="300" allowscriptaccess="always" allowfullscreen="true"> </embed> </object> RSS Readers http://www.javiertordable.com/rss-readers Sun, 29 May 2011 03:10:00 GMT http://www.javiertordable.com/rss-readers <p> I’ve been a long time user of <a href="http://www.google.com/reader">Google Reader</a>. It worked great for me until a few weeks ago, when I started noticing it becoming slower. Also, I realized that many of the feeds that I frequently read were updated less frequently that I wanted. And it will only keep unread posts for up to 30 days. Anyway, my biggest issue with Reader is that it’s a web based RSS aggregator. Which means that it can be accessed from anywhere. Which really means that I may spend precious time reading feeds while I should be doing more useful stuff (like working...). </p> <img src="http://www.javiertordable.com/img/google-reader-logo.png" alt="Google Reader logo" /> <p> So I decided to find a good client-based RSS reader. After a little bit of research I started using <a href="http://www.mozillamessaging.com/thunderbird/">Thunderbird</a>, which is the aggregator from the Mozilla Foundation (the same guys that created <a href="http://www.mozilla.com/">Firefox</a>). And I have to say that I didn’t like it at all. Not only it’s full of counter intuitive options (why do I have to create a new folder for each feed if I want to see them separately? and why when I add a new feed the default option is to place posts in the same folder as the currently selected feed?), but it’s really slow. To a point that it was painful to read more than a few dozen posts straight. </p> <img src="http://www.javiertordable.com/img/thunderbird-logo.png" alt="Mozilla Thunderbird logo" /> <p> After a little bit more research I ended up finding <a href="http://userbase.kde.org/Akregator">Akregator</a>, which is made by the same team that built the <a href="http://www.kde.org/">KDE Desktop Environment</a> for Linux. And so far I really like it! It’s very fast, it allows to open the actual website in a separate tab (as opposed to only the post) and it has great keyboard shortcuts (Alt+, Alt- to switch between unread feeds, + and - to move between posts. No more tab back and forth to switch feeds like in Thunderbird). My only complaint is that it doesn’t have an Undo Delete option. </p> <img src="http://www.javiertordable.com/img/akregator-logo.png" alt="Akregator logo" /> <p> So I settled with Akregator and I installed it on my home computer. Since then, I am getting 30 minutes to an hour extra of work done every day! The only thing that I’m going to miss are the Google Reader stats... </p> <img src="http://www.javiertordable.com/img/google-reader-stats.png" alt="Google Reader stats" /> A short introduction to the Riemann Zeta Function http://www.javiertordable.com/short-introduction-riemann-zeta-function Fri, 04 Mar 2011 06:30:01 GMT http://www.javiertordable.com/short-introduction-riemann-zeta-function <p> <strong>The Riemann Zeta Function</strong> </p> <p> In the late 17th century it was known that the harmonic series </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\sum_{n%3D1}^{\infty}\frac{1}{n}%3D1%2B\frac{1}{2}%2B\frac{1}{3}%2B\frac{1}{4}%2B\ldots" /> </p> <p> is divergent, as it was proved by Pietro Mengoli, Johann Bernoulli and Jakob Bernoulli. Euler considered the series of the form: </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\sum_{n%3D1}^{\infty}\frac{1}{n^{k}}" /> </p> <p> for integer values of <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=k%3E1" />, which can be easily shown to converge </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=n\left(n%2B1\right)%3Dn^{2}%2Bn%3C2n^{2}\Rightarrow\frac{2}{n\left(n%2B1\right)}%3E\frac{1}{n^{2}}" /> </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\sum_{n%3D1}^{\infty}\frac{1}{n^{2}}%3C\sum_{n%3D1}^{\infty}\frac{2}{n\left(n%2B1\right)}%3D2\sum_{n%3D1}^{\infty}\left(\frac{1}{n}-\frac{1}{n%2B1}\right)%3D" /> </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=2\left[1%2B\left(\frac{1}{2}-\frac{1}{2}\right)%2B\left(\frac{1}{3}-\frac{1}{3}\right)%2B\sum_{n%3D4}^{\infty}\left(\frac{1}{n}-\frac{1}{n}\right)\right]%3D2" /> </p> <p> and obviously </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\forall%20n\geq1,\forall%20k\geq2,n^{k}\geq%20n^{2}\Rightarrow\frac{1}{n^{k}}\leq\frac{1}{n^{2}}" /> </p> <p> Posteriorly Dirichlet and Chebyshev would consider real valued exponents. It is also easy to prove that <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\forall%20s\in\mathbb{R},s%3E1\,\sum_{n%3D1}^{\infty}\frac{1}{n^{s}}" /> is a convergent series. Riemann went one step further and considered a complex variable <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=s" /> and proved that <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\sum_{n%3D1}^{\infty}\frac{1}{n^{s}}" /> converges for <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=Re\left(s\right)%3E1" /> and it can be continued analitically to all complex values <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=s\neq1" />. This extension of </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\sum_{n%3D1}^{\infty}\frac{1}{n^{s}}" /> </p> <p> is well defined and holomorphic in <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\mathbb{C}\setminus\left\{%201\right\}" />, it is denoted <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\zeta" /> and is called the Riemann Zeta Function. </p> <p> <strong>Some properties of <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\zeta" /> </strong> </p> <p> The zeta function can be written for <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=Re\left(s\right)%3E1" /> as the sum of a series and the Euler product formula allows us to write it as an infinite product: </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\sum_{n%3D1}^{\infty}\frac{1}{n^{s}}%3D\prod_{p\,%20prime}\frac{1}{1-p^{-s}}" /> </p> <p> One of the steps in proving that <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\zeta" /> is holomorphic in <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\mathbb{C}\setminus\left\{%201\right\}" /> consists in verifiying the following functional equation </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\zeta\left(s\right)%3D2\left(s\pi\right)^{s-1}sin\left(\frac{\pi%20s}{2}\right)\Gamma\left(1-s\right)\zeta\left(1-s\right)\" /> </p> <p> where <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\Gamma" /> is the gamma function <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\Gamma\left(z\right)%3D\int_{0}^{\infty}t^{z-1}e^{-t}dt" />. The fact that it verifies this functional equation allows to prove many other interesting properties. </p> <p> In his original paper, Riemann suggested that all zeroes of <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\zeta" /> which are not trivial ( <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=-2,-4,\ldots" /> ) are in the line </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\left\{%20z\in\mathbb{C}:Re\left(z\right)%3D\frac{1}{2}\right\}" /> </p> <p> This came to be known as the Riemann Hypothesis and it's been an open problem for over 150 years. </p> <p> Proving the Riemann Hypothesis would have many significant consequences. One of the most important ones is the precise caracterization of the distribution of prime numbers. Let's take the prime counting function <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=\pi\left(x\right)" />, which gives for each <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=x" /> the number of prime numbers less than or equal to <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=x" />. The Prime Number Theorem states that </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\pi\left(x\right)\sim\frac{x}{ln\,%20x}" /> </p> <p> This theorem was originally proved independently by Hadamard and de la Vallée Poussin. If we consider </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=Li\left(x\right)%3D\int_{2}^{x}\frac{1}{ln\,%20t}dt%3Dli\left(x\right)-li\left(2\right)" /> </p> <p> then the Prime Number Theorem can be written as </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\pi\left(x\right)\sim%20li\left(x\right)\sim%20Li\left(x\right)" /> </p> <p> Von Koch proved that if and only if the Riemann hypothesis is true then </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\pi\left(x\right)%3DLi\left(x\right)%2BO\left(\sqrt{x}ln\,%20x\right)" /> </p> <p> and Schoenfeld stated more precisely that the Riemann hypothesis is equivalent to </p> <p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=\left|\pi\left(x\right)-li\left(x\right)\right|%3C\frac{\sqrt{x}ln\,%20x}{8\pi}" /> </p> <p> for all <img class="inline" src="https://chart.googleapis.com/chart?cht=tx&chl=x>2657" /> and this is indeed the tightest limit possible. </p> Python Becoming More Popular http://www.javiertordable.com/python-becoming-more-popular Mon, 21 Feb 2011 22:38:14 GMT http://www.javiertordable.com/python-becoming-more-popular <p> The <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/tpci_definition.htm"> TIOBE Programming Community index</a> is an indicator of the popularity of programming languages. In their <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html"> data for February</a> we can see that Python is steadily rising in popularity. I believe there are two main reasons for this. First, the increasing availability of powerful libraries and frameworks like <a href="http://www.djangoproject.com/">Django</a>. And second, it's faster to program in Python because it's less verbose than other languages. </p> <a href="http://python.org/"> <img src="http://www.javiertordable.com/img/python-logo.png" alt="Python logo" /> </a> <p> For example, here is a simple program in Java, to read a CSV file, add the numbers in the last column and output the result. It's not optimized for performance or length. But it should resemble production code out there. </p> <pre> /** * This small program reads a CSV file and attempts to sum all the terms * in the last column. * * It assumes that the format of the file is: * one line,234 * another line,125 * ... etc. * consisting of several lines. Each line contains values separated * by ',', and the last value is an integer. */ public class JavaReader { private static final Logger LOGGER = Logger.getLogger( JavaReader.class.getName()); private static final char SEPARATOR = ','; public static void main(String args[]) { // Check the input arguments. if (args.length < 1) { LOGGER.severe("Please indicate the file to read"); return; } // Open the file. FileInputStream stream; try { stream = new FileInputStream(args[0]); } catch (FileNotFoundException e) { LOGGER.severe("Please indicate a valid file"); return; } // Read line by line. BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); int accumulatedValue = 0; try { String line = reader.readLine(); while (line != null) { // Find the last ',' and extract the integer. int lastSeparatorIndex = line.lastIndexOf(SEPARATOR); int value = 0; try { // Skip the separator, the rest should be the value. String valueInput = line.substring(lastSeparatorIndex + 1); value = Integer.valueOf(valueInput).intValue(); } catch (NumberFormatException f) { LOGGER.warning("Unable to parse the number"); } accumulatedValue += value; line = reader.readLine(); } } catch (IOException e) { LOGGER.warning("Unable to read line"); } System.out.println("Accumulated: " + String.valueOf(accumulatedValue)); } } </pre> <p> It consists of 61 lines and 1795 characters. By comparison this more or less equivalent Python program consists of 40 lines and 1051 characters. Again, it wasn't optimized for performance or length, and it should be similar to real production code. </p> <pre> class PythonReader(object): """This class reads a CSV file and attempts to sum all the terms in the last column. It assumes that the format of the file is: one line,234 another line,125 ... etc. consisting of several lines. Each line contains values separated by ',', and the last value is an integer. """ SEPARATOR = ',' def process_file(self, file_name): try: input_file = open(file_name) except IOError: logging.error('Unable to open the input file') sys.exit() accumulated_value = 0 for line in input_file.readlines(): last_token = line.split(PythonReader.SEPARATOR)[-1] value = 0 try: value = int(last_token) except ValueError: logging.error('Unable to parse the number') accumulated_value += value print 'Accumulated: ' + str(accumulated_value) if __name__ == '__main__': if len(sys.argv) < 2: logging.error('Please indicate the file to read') sys.exit(); reader = PythonReader() reader.process_file(sys.argv[1]) </pre> <p> The Java program is significantly longer, even though both do more or less the same. I believe the difference is because Python natively lends itself to writing shorter programs. And of course less time spent coding means more time thinking about how to solve problems and satisfying customers. <a href="http://www.javiertordable.com/contact">Thoughts?</a> </p> Tips for Better Health and Longevity http://www.javiertordable.com/tips-better-health-longevity Wed, 16 Feb 2011 07:23:44 GMT http://www.javiertordable.com/tips-better-health-longevity <p> I decided to read again <a href="http://www.javiertordable.com/blog/2010/01/15/trascend-book-kurzweil-grossman">Transcend</a>, and this time I took notes. Here are a few tips, in very synthesized form, to have better health and ensure greater longevity. Also, I have added a few other suggestions that I took from other places, marked with an asterisk *. </p> <ul> <li><strong>Nutrition</strong></li> <ul> <li>Don't eat sugar</li> <li>Don't eat fast food</li> <li>Eat 10 to 20 % less than normal</li> <li>Eat less sweets, bread, rice, pasta, potatoes and juice</li> <li>Eat more vegetables, legumes and fruits</li> <li>Eat at least 1 ounce of nuts a day</li> <li>Eat organic products when possible</li> <li>Cut on red meats, cheese and eggs</li> <li>Switch to fish, white meats and tofu</li> <li>Don't drink milk *</li> <li>Eat dark chocolate, red wine, blueberries, olive oil</li> <li>Stop drinking coffee. Drink green tea (2 to 3 cups a day)</li> <li>Use turmeric (curcumin) as a spice in food</li> </ul> <li><strong>Exercise</strong></li> <ul> <li>Frequent exercise, at least 3 times a week. Cardio and weights</li> <li>Stretch after exercise to maintain flexibility</li> <li>Intellectual activity *</li> </ul> <li><strong>Sex</strong></li> <ul> <li>2 or 3 times a week</li> </ul> <li><strong>Rest</strong></li> <ul> <li>6 to 7 hours a day</li> <li>Take a short nap in the middle of the day *</li> </ul> <li><strong>Tests</strong></li> <ul> <li>Annual physical (Bi-annual dental, annual vision *)</li> <li>LDL < 100</li> <li>HDL > 60</li> <li>CRP < 1</li> <li>Homocysteine < 7.5</li> <li>Cholesterol 160 to 180</li> <li>DHEA-S 200 to 250</li> <li>Insulin < 3</li> <li>Testosterone 500 to 800 (Men)</li> <li>Hemoglobin A1c < 5.8</li> <li>Vitamin D > 50</li> <li>Heart rate < 55</li> <li>Blood pressure < 120/80</li> <li>Regular self-testing for skin stains or lumps</li> </ul> <li><strong>Supplements</strong></li> <ul> <li>Multi-vitamin (Multigenics intensive care without iron *)</li> <li>Vitamin D - 5000 daily</li> <li>Fish oil (Carlson Elite Omega-3 gems *)</li> <li>EPA - 1000 to 3000 daily</li> <li>DHA - 700 to 2000 daily</li> </ul> <li><strong>Brain Supplements</strong></li> <ul> <li>PC (Phosphatidylcholine) >50% pure - 900 mg twice a day</li> <li>Vinpocetine - 10 mg twice a day</li> <li>Phosphatidylserine - 100 mg a day</li> <li>Acetyl-L-carnitine - 1000 mg a day</li> <li>Gingko biloba - 100 mg twice a day</li> </ul> <li><strong>Additional Supplements</strong></li> <ul> <li>Coenzime Q10 / Ubiquinol - 50 mg daily</li> <li>Grape seed extract - 50 mg twice a day</li> <li>Resveratrol - 50 mg twice a day</li> <li>Acetyl-L-Carnitine - 1000 mg daily</li> </ul> <li><strong>Advanced Tests</strong></li> <ul> <li>Genetic testing, 23 and me, Navigenics, Decode Me</li> <li>Sleep tracking (Zeo) *</li> </ul> <li><strong>Other</strong></li> <ul> <li>Relax</li> <li>Use a water filter</li> <li>Participate in blood drive</li> </ul> </ul> The Beauty of Complex Analysis http://www.javiertordable.com/beauty-complex-analysis Tue, 11 Jan 2011 01:51:01 GMT http://www.javiertordable.com/beauty-complex-analysis <p> <a href="http://en.wikipedia.org/wiki/Complex_analysis">Complex Analysis</a> is the branch of mathematics that studies functions of complex numbers. These numbers are those given by a + bi, where i is the imaginary unit, the square root of -1. We can think of complex numbers as points in a plane, where the x coordinate indicates the real component and the y coordinate indicates the imaginary component. </p> <img src="http://www.javiertordable.com/img/complex-number.png" alt="Complex number" /> <p> From that, we can consider functions of complex variable as maps that take each point in the plane to another point in the plane. </p> <p> There is one characteristic of Complex Analysis that makes it especially beautiful. Inside of it we can find objects that appear to be very complicated but happen to be relatively simple. Reciprocally, there are objects that appear to be very simple but are indeed extremely complex. </p> <p> For example, in Complex Analysis we study <a href="http://en.wikipedia.org/wiki/Holomorphic_function">holomorphic functions</a>. These are essentially functions that are differentiable in the complex sense. Which means that the function is continuous and both it’s real and imaginary parts have partial derivatives that satisfy the (apparently simple) Cauchy-Riemann equations. At first sense this is a very general definition. Considering the huge variety of differentiable functions in the real line we would imagine that there is also an extreme variety of holomorphic functions in the plane. However in complex analysis we have for example the following theorems, which impose very strong conditions on holomorphic functions: </p> <ul> <li> If a function is holomorphic in the entire plane and it’s bounded in module, then it’s constant. This is <a href="http://en.wikipedia.org/wiki/Liouville's_theorem_(complex_analysis)"> Liouville's_theorem</a> and it actually proves the <a href="http://en.wikipedia.org/wiki/Fundamental_theorem_of_algebra"> Fundamental Theorem of Algebra</a> </li> <li> If we know the value of a holomorphic function in a circle, then we can know the value in every single point inside of the disk, by the <a href="http://en.wikipedia.org/wiki/Cauchy's_integral_formula"> Cauchy Integral Formula</a> </li> <li> If two holomorphic functions are equal in an infinite number of points (with one accumulation point) then they are equal in a complete disk, this is because they are <a href="http://en.wikipedia.org/wiki/Holomorphic_functions_are_analytic">analytic</a> </li> </ul> <p> The last point is particularly shocking when one compares it with real functions. For example, the function {0 if x < 0 and exp(-1/x) if x >= 0} is identically equal to the constant 0 on the left side of the graph, and both are infinitely differentiable. However, they are obviously different functions. As a matter of fact, this function is a counterexample to show that the 3 properties above don't apply to real functions. </p> <a href="http://en.wikipedia.org/wiki/File:Non-analytic_smooth_function.png"> <img src="http://www.javiertordable.com/img/non-analytic-smooth-function.png" alt="Graph of a non-analytic smooth function" /> </a> <p> Holomorphic functions are very structured when compared with real differentiable functions. In that sense they are more <em>simple</em> than what intuition would suggest. </p> <p> On the other hand, we have objects like the <a href="http://en.wikipedia.org/wiki/Mandelbrot_set">Mandelbrot set</a>, which can be expressed in a very simple and concise way, but which is indeed very complex. From Wikipedia: A complex number c is in the Mandelbrot set if, when starting with z0 = 0 and applying the iteration: z_n+1 = (z_n)^2 + c the absolute value of z_n never exceeds a certain boundary, however large n gets. In spite of this simplicity, the graphical representation of a part of this set looks like this: </p> <a href="http://en.wikipedia.org/wiki/File:Mandel_zoom_11_satellite_double_spiral.jpg"> <img src="http://www.javiertordable.com/img/mandelbrot-set-small.jpg" alt="Mandelbrot set detail" /> </a> <p> Another example, even more interesting: Consider the <a href="http://en.wikipedia.org/wiki/Riemann_zeta_function">Riemann Zeta Function</a>: </p> <img src="http://www.javiertordable.com/img/riemann-zeta-function.png" alt="The Riemann Zeta Function" /> <p> where s is a complex parameter. This function can be defined in a seemingly very simple way. However it satisfies many remarkable properties. For instance, if we restrict ourselves to the stripe of the complex plane where the real component x is ½ < x < 1 and take a section of the stripe and any holomorphic function which doesn’t take the the value 0 we have that, informally, this function can be approximated by the zeta function as precisely as we want in another section of the strip right above or below. This property is called the <a href="http://en.wikipedia.org/wiki/Zeta_function_universality"> Universality of the Riemann Zeta Function</a> </p> <a href="http://en.wikipedia.org/wiki/File:Voronin_universality_theorem.png"> <img src="http://www.javiertordable.com/img/voronin-universality-theorem.png" alt="Voronin's Universality Theorem" /> </a> <p> Think about that, it doesn’t matter how complex an holomorphic function is inside of that area. As long as it doesn’t become 0, there is another area in which the zeta function approximates it as precisely as we want. In that sense the structure of the zeta function is so rich that it <em>contains</em> within itself the shape of every other non-vanishing holomorphic function. </p> N+2 Replication http://www.javiertordable.com/n-plus-2-replication Thu, 30 Dec 2010 23:02:17 GMT http://www.javiertordable.com/n-plus-2-replication <p> There are several ways to create fault tolerant systems. One of the most common is simply to duplicate the system. For example in a web application stack, we could have a master database and a slave database, which contain the same duplicated data. Also two web servers and a load balancing system that splits the load among the servers. In case of a hardware failure in a web server or a database the remaining server may be able to handle all the load while the broken one is being repaired. Replication of data and redundancy of servers is one of the reasons that some sites are highly available. </p> <img src="http://www.javiertordable.com/img/datacenter-replication.png" alt="Datacenter replication" /> <p> However, duplicating all infrastructure is expensive and inefficient. At the very least it duplicates the costs. If we needed one datacenter with 10 databases and 10 web servers to handle peak load, simply duplicating all the servers would leave us with two identical datacenters, for a total of 20 databases and 20 web servers. One of the datacenters, with 20 machines, would be idle most of the time. </p> <p> A good compromise between efficiency and cost is N+2 replication. N+2 means that if we need N instances of the system to handle peak load, we should have N+2 instances to ensure availability. Of course, assuming that these instances are independent of each other. Indeed, if the probability that one of the copies fails is p, the probability of having a complete system failure is: </p> <img src="https://chart.googleapis.com/chart?cht=tx&chl=$\left(1-p\right)^{n%2B2}%2B{n%2B2%20\choose%201}p\left(1-p\right)^{n%2B1}%2B{n%2B2%20\choose%202}p^{2}\left(1-p\right)^{n}$" alt="Probability of failure in N plus 2 replication" /> <p> A realistic value for p could be 0.01, which is around 3 days a year. If we take for example N=5, then the availability of the N+2 replicated system is 0.99997%. Which by the same rule of thumb means that it may be unavailable around 15 minutes a year. </p> <p> The same N+2 reasoning could be applied to other problems outside of computer science and web applications. One trend that is recently becoming popular is that of a <a href="http://en.wikipedia.org/wiki/Perpetual_traveler"> perpetual traveler</a>. It is also known as three flag theory. It basically advocates for hedging financial, legal and sovereign risk by splitting personal assets and legal status among different countries or flags. </p> <p> For example, if Alice is American, lives in the USA and has all her assets in the USA, that renders her vulnerable to a series of risks. Imagine in case of a lawsuit, a US judge can block her bank accounts and seize her assets with the click of a button. Possibly depriving her from the means to defend herself in court. It definitely wouldn’t be so easy if she did her banking in Singapore or Hong Kong. </p> Visualizations to Show Causality http://www.javiertordable.com/visualizations-causality Fri, 17 Dec 2010 21:32:55 GMT http://www.javiertordable.com/visualizations-causality <script type="text/javascript" src="http://www.google.com/jsapi"> </script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['corechart']}); google.load('visualization', '1', {packages: ['motionchart']}); </script> <script type="text/javascript"> function drawVisualization1() { // Create and populate the data table. var data = new google.visualization.DataTable(); data.addColumn('string', 'Product'); data.addColumn('number', 'Revenue'); data.addRows(7); data.setValue(0, 0, 'iPhone'); data.setValue(0, 1, 8822); data.setValue(1, 0, 'Laptops'); data.setValue(1, 1, 3194); data.setValue(2, 0, 'Desktops'); data.setValue(2, 1, 1676); data.setValue(3, 0, 'iPad'); data.setValue(3, 1, 2792); data.setValue(4, 0, 'iPod'); data.setValue(4, 1, 1477); data.setValue(5, 0, 'iTunes'); data.setValue(5, 1, 1243); data.setValue(6, 0, 'Other'); data.setValue(6, 1, 1139); // Create and draw the visualization. new google.visualization.PieChart(document.getElementById('visualization1')). draw(data, {title:"Apple. Revenue by product in Q4 2010 (M). Total: 20,343"}); } google.setOnLoadCallback(drawVisualization1); function drawVisualization2() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Year'); data.addColumn('number', 'Revenue'); data.addColumn('number', 'Net Income'); data.addRows(4); data.setValue(0, 0, '2007'); data.setValue(0, 1, 24578); data.setValue(0, 2, 3495); data.setValue(1, 0, '2008'); data.setValue(1, 1, 37491); data.setValue(1, 2, 6119); data.setValue(2, 0, '2009'); data.setValue(2, 1, 42905); data.setValue(2, 2, 8235); data.setValue(3, 0, '2010'); data.setValue(3, 1, 65225); data.setValue(3, 2, 14013); var chart = new google.visualization.LineChart(document.getElementById('visualization2')); chart.draw(data, {width: 600, height: 400, title: 'Apple. Financial performance per year (M).'}); } google.setOnLoadCallback(drawVisualization2); function drawVisualization3() { var data = new google.visualization.DataTable(); data.addColumn('number', 'Population'); data.addColumn('number', 'Population / GDP'); data.addRows(6); data.setValue(0, 0, 81); data.setValue(0, 1, 2806); data.setValue(1, 0, 65); data.setValue(1, 1, 2108); data.setValue(2, 0, 62); data.setValue(2, 1, 2139); data.setValue(3, 0, 60); data.setValue(3, 1, 1704); data.setValue(4, 0, 46); data.setValue(4, 1, 1360); data.setValue(5, 0, 17); data.setValue(5, 1, 658); var chart = new google.visualization.ScatterChart(document.getElementById('visualization3')); chart.draw(data, {width: 500, height: 400, title: 'GDP (PPP) versus population', hAxis: {title: 'Population (Million)', minValue: 0, maxValue: 15}, vAxis: {title: 'GDP (PPP Adjusted. USD Billion)', minValue: 0, maxValue: 15}, legend: 'none' }); } google.setOnLoadCallback(drawVisualization3); function drawVisualization4() { var data = new google.visualization.DataTable(); data.addRows(2); data.addColumn('string', 'Name'); data.addColumn('date', 'Date'); data.addColumn('number', 'Time (Hours)'); data.addColumn('number', 'Distance (Miles)'); data.setValue(0, 0, 'Runner'); data.setValue(0, 1, new Date (0,0,1)); data.setValue(0, 2, 0); data.setValue(0, 3, 0); data.setValue(1, 0, 'Runner'); data.setValue(1, 1, new Date (0,0,2)); data.setValue(1, 2, 1); data.setValue(1, 3, 6); var motionchart = new google.visualization.MotionChart( document.getElementById('visualization4')); motionchart.draw(data, {'width': 470, 'height': 350, 'showChartButtons' : false, 'showSidePanel' : false, 'showXScalePicker': false, 'showYScalePicker': false}); } google.setOnLoadCallback(drawVisualization4); </script> <p> Recently I have been reading about the best way to design a graph / visualization / infographic to express a particular message. Some cases are easier than others. To show distribution of a total into parts one chart that works well is the Pie Chart. Take a look at this example: </p> <p> <div id="visualization1" style="position: relative; left: -30px; width: 600px; height: 400px;"></div> Source: <a href="http://www.apple.com/pr/library/2010/10/18results.html"> http://www.apple.com/pr/library/2010/10/18results.html</a> </p> <p> It works well because the pie represents a total, and all the parts add up to the total. The area of each part is proportional to the fraction of the total that it represents. This graph shows the distribution of the total revenue among it’s parts, but it doesn’t explain for instance how this revenue changes over time. To show changes over time a chart that works well is a line chart. This chart shows the years in increasing order from left to right. In Western cultures we normally associate time progress with movement from left to right because it's the same direction in which we read. </p> <p> <div id="visualization2" style="position: relative; left: -30px; width: 500px; height: 400px;"></div> Source: <a href="http://www.google.com/finance?q=NASDAQ:AAPL&fstype=ii"> http://www.google.com/finance?q=NASDAQ:AAPL&fstype=ii</a> </p> <p> Notice that in both cases the title indicates what data is shown in the graph and the time period in which it applies. Also we have units for all the numbers in the chart (Million / M). And in the second chart the axis are correctly labeled. Finally, the source of the data is indicated for both charts. </p> <p> A more difficult problem is how to show causality. That is, how to show in a a graph that a certain condition results in a corresponding effect. Or that a change in one variable results in a change in a different value. </p> <p> Usually causality is expressed with a scatter plot, or a line chart. However in those cases it’s hard to distinguish between real causality and mere correlation. If we plot for example the speed of a runner with the total distance traveled after 1 hour, it’s obvious that both numbers are completely determined by each other, and the correlation is 1. However causality is generally more “unidirectional”, where correlation is “bidirectional”. What I mean by this, is that when we talk about causality we normally express that one condition implies another. When we talk about correlation that usually means that two measures are tied together, but it’s not clear if there is a causal relationship from one to the other, or vice-versa. </p> <p> In a static graph in general it’s hard to distinguish correlation from causality. The most common resource is to write the independent variable (the source in the causal relationship) in the lower axis, while leaving the dependent variable in the vertical axis. However this may not be as effective as intended. </p> <p> For example, this chart shows the population and GDP of 6 European countries: Germany, France, UK, Italy, Spain and Netherlands. From the chart it’s not clear weather a higher population implies a higher GDP, or the other way around. Most likely there is no causal relationship altogether. India for example has a higher population than all of them combined, but it’s GDP (PPP) is comparable to Spain. The other implication is not true either, Australia has a higher GDP (PPP) then Mexico, but less than 20% of the population. </p> <p> <div id="visualization3" style="position: relative; left: -30px; width: 500px; height: 400px; margin-left: auto; margin-right: auto;"></div> Source: <a href="http://en.wikipedia.org/wiki/List_of_countries_by_GDP_(nominal)"> http://en.wikipedia.org/wiki/List_of_countries_by_GDP_(nominal)</a> </p> <p> I think one tool that is very useful to distinguish causality from correlation is a dynamic chart. In this chart not only we can put the causal variable in the lower axis, but we can also give the reader the freedom to alter that variable manually. This will trigger the change in the dependent variable. And because of the technical implementation of the chart it’s impossible to modify it the other way around. There is no way to modify the dependent variable and see the value of the independent variable. This asymmetry in the visualization is what enhances the message of causality, as opposed to mere correlation. Try it out in the example below! </p> <p> <div id="visualization4" style="width: 470px; height: 350px; padding-left: 70px;"></div> </p> <p> Source: v = ds/dt <a href="http://en.wikipedia.org/wiki/Speed"> http://en.wikipedia.org/wiki/Speed</a> </p> The Facebook Like Button http://www.javiertordable.com/facebook-like-button Wed, 24 Nov 2010 22:31:56 GMT http://www.javiertordable.com/facebook-like-button <p> This one is going to be a small post. A friend of mine told me about the Facebook Like buttons. One can put them in a site or in a blog post, and people can click on it to indicate that they like that item. Then the blog post or the site will appear in the Facebook homepage of that person. I checked it out and it’s actually pretty easy. </p> <p> To start, there is a page to get the code of the <a href="http://developers.facebook.com/docs/reference/plugins/like"> Facebook button</a>, in a style that matches the style of the site. Right after adding the button code to the post, it looks like this: </p> <img src="http://www.javiertordable.com/img/fbb-before-like.png" alt="Facebook button, before like" /> <p> Then if I click on it, it changes to: </p> <img src="http://www.javiertordable.com/img/fbb-like.png" alt="Facebook button, like" /> <p> and I can also add a comment. Then after I reload it looks like: </p> <img src="http://www.javiertordable.com/img/fbb-after-like.png" alt="Facebook button, after like" /> <p> and the names and faces of people that liked the item post appear below the button. Also in my Facebook profile now it says: </p> <img src="http://www.javiertordable.com/img/fbb-result-in-stream.png" alt="Facebook button, result in stream" /> <p> So that other people in Facebook can see what I am doing and bring more people to the blog. Yay! Check for yourself and click the button below :) </p> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.javiertordable.com%2Fblog%2F2010%2F11%2F24%2Ffacebook-like-button&amp;layout=standard&amp;show_faces=true&amp;width=500&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:500px; height:80px; margin-left: auto; margin-right:auto; display:block;" allowTransparency="true"> </iframe> Say No to the TSA. National Opt Out Day http://www.javiertordable.com/no-tsa-national-opt-out-day Thu, 18 Nov 2010 21:43:09 GMT http://www.javiertordable.com/no-tsa-national-opt-out-day <p> This one if off topic, but I couldn't resist posting it. If you have traveled by air recently you know about the porno-scanners. The TSA is forcing everyone to pass through the scanner or be subject to a thorough pat-down. So they will either watch you naked or touch all your body, including your private parts. And this includes you, your wife, your children and your grandma. </p> <p> Fortunately, people have started to stand up against this outrageous invasion of privacy and constitutional rights. Please check out <a href="http://wewontfly.com/">wewontfly.com</a> and if you are traveling by air on November 24, opt out of the porno-scanner. </p> <img src="http://www.javiertordable.com/img/tsa-banner.jpg" alt="Say NO to the TSA. Opt out of the porno-scanner" /> New Webmaster Central http://www.javiertordable.com/new-webmaster-central Wed, 15 Sep 2010 16:12:23 GMT http://www.javiertordable.com/new-webmaster-central <p> Google recently launched a new promotion for Webmaster Central and Webmaster Tools, which are undoubtedly the most important resources that the webmasters of the entire world have to optimize their sites for search (Disclaimer: I work at Webmaster Tools so I’m kind of slightly biased). </p> <p> Now if you go to Google and search for the pages of your site, for example, <a href="http://www.google.com/search?q=site:javiertordable.com"> www.google.com/search?q=site:javiertordable.com</a> you will see something like this: </p> <p> <a href="http://www.javiertordable.com/img/google-promotion-big.png"> <img src="http://www.javiertordable.com/img/google-promotion-small.png" alt="Google promotion for Webmaster Tools"/> </a> </p> <p> If you are a webmaster you may already know about the site: operator, however you can get more reliable indexing data from Webmaster Tools than from the site: results. </p> <p> The link will take you to the redesigned <a href="http://www.google.com/webmasters/"> Webmaster Central</a> page which looks more or less like this: </p> <p> <a href="http://www.javiertordable.com/img/webmaster-central-big.png"> <img src="http://www.javiertordable.com/img/webmaster-central-small.png" alt="Webmaster Central screenshot"/> </a> </p> <p> It has a button to take you to Webmaster Tools, and a few other very helpful links, including the user forums, help center and the official Webmaster Central blog. And in case you didn’t even know about Webmaster Tools (really?), it will explain what are some of the most important features. </p> <p> <img src="http://www.javiertordable.com/img/webmaster-tools-features.png" alt="Webmaster Tools features"/> </p> <p> I hope you like it! And if you have any comments, suggestions, etc. you can reach me <a href="http://www.javiertordable.com/contact">here</a> or in twitter <a href="http://www.twitter.com/tordable">@tordable</a>. </p> P versus NP http://www.javiertordable.com/p-versus-np Sat, 14 Aug 2010 16:54:43 GMT http://www.javiertordable.com/p-versus-np <p> During the past week shocking news have stormed through the world of Theoretical Computer Science. A researcher from HP Labs, <a href=http://www.hpl.hp.com/personal/Vinay_Deolalikar/> Vinay Deolalikar</a> claimed that he had a proof that P ≠ NP. The paper is available <a href=http://www.hpl.hp.com/personal/Vinay_Deolalikar/Papers/pnp_8_11.pdf> here</a>. But so far it seems that it will not stand. Several researchers pointed out critical defects in the proof that Deolalikar proposed. It is especially interesting to follow the discussion in Dick Lipton’s blog (In 5 posts so far: <a href="http://rjlipton.wordpress.com/2010/08/08/a-proof-that-p-is-not-equal-to-np/"> 1</a> <a href="http://rjlipton.wordpress.com/2010/08/09/issues-in-the-proof-that-p≠np/"> 2</a> <a href="http://rjlipton.wordpress.com/2010/08/10/update-on-deolalikars-proof-that-p≠np/"> 3</a> <a href="http://rjlipton.wordpress.com/2010/08/11/deolalikar-responds-to-issues-about-his-p≠np-proof/"> 4</a> <a href="http://rjlipton.wordpress.com/2010/08/12/fatal-flaws-in-deolalikars-proof/"> 5</a>). Or in Wikipedia for the <a href="http://en.wikipedia.org/wiki/Vinay_Deolalikar#P_.E2.89.A0_NP"> short version</a>. It’s amazing to see how many of the world’s most brilliant mathematicians worked so fast to analyze Deolalikar’s proof, including <a href="http://rjlipton.wordpress.com/2010/08/10/update-on-deolalikars-proof-that-p≠np/#comment-4885"> Terence Tao</a>, and <a href="http://gowers.wordpress.com/2010/08/11/my-pennyworth-about-deolalikar/"> Timothy Gowers</a>. The fatal blow to the attempted proof seems to be in a letter from <a href="http://michaelnielsen.org/polymath1/index.php?title=Immerman's_letter"> Neil Immerman</a>. There are plenty of references about the proposed proof and the refutations in <a href="http://michaelnielsen.org/polymath1/index.php?title=Deolalikar's_P!%3DNP_paper"> this Wiki</a>. </p> <p> Now for anybody that is not an expert in complexity theory (myself included), here is a short explanation of what this is all about and why it matters: P and NP are two classes of algorithms. Colloquially, algorithms in P are those for which the amount of time that it takes to execute with an input of size n is a polynomial of n. For example, finding the maximum in a list of n elements takes approximately n steps because we just need to go through all n elements and keep track of the maximum. Problems for which the best possible algorithm is in P are in general solvable in reasonable time, because even for large values of the input the time that it takes to run the algorithm is not too big. </p> <p> Algorithms in NP are those for which, if we have a proposed solution, we can check if it actually solves the problem in polynomial time. For example, given a set of integers {−7, −3, −2, 5, 8} of size 5 we can check if a subset like {−3, −2, 5} adds up to zero in less than 5 steps. We simply need to add the numbers. However finding a solution in general takes a much bigger number of steps. One way to solve it is to analyze all subsets, and for each one, check if it’s a solution. But the number of subsets grows exponentially with n, hence the difficulty. </p> <p> Obviously all algorithms in P are also in NP, because if we can find the solution in polynomial time then we can verify the solution in polynomial time (for example by finding it again). The complex question is whether P is equal to NP or not. </p> <p> These two classes of algorithms are especially interesting for their practical applications but there are not the only classes by any means. The following diagram shows some of the most important ones. The classes at the bottom are contained in the classes on top. </p> <a href="http://en.wikipedia.org/wiki/Complexity_class"> <img src="http://www.javiertordable.com/img/algorithm-hierarchy.png" alt="Hierarchy of algorithm complexity classes"/> </a> <p> And there are many more. The <a href="http://qwiki.stanford.edu/wiki/Complexity_Zoo"> Complexity Zoo</a> lists 489 complexity classes. </p> <p> Now that we have seen what the problem is about, why does it matter? I am going to talk about two important real world consequences of a possible proof of P=NP. You can find many more <a href="http://en.wikipedia.org/wiki/P_versus_NP_problem#Consequences_of_proof"> here</a> if you are interested. </p> <p> The first application is in mathematical research. As Stephen Cook says, we can <a href="http://www.claymath.org/millennium/P_vs_NP/Official_Problem_Description.pdf"> verify a proof of a theorem in polynomial time</a> so if P=NP then we would be able to create a proof in polynomial time. This would allow us to build <a href="http://isabelle.in.tum.de/overview.html"> automatic theorem provers</a> that basically do scientific research for us 24/7, continuously discovering new knowledge. It’s obvious the tremendous repercussions that this would have in the world. </p> <a href="http://isabelle.in.tum.de/overview.html"> <img src="http://www.javiertordable.com/img/automatic-theorem-prover.png" alt="Automatic theorem prover"/> </a> <p> The second example is in biology. It is known that the <a href="http://en.wikipedia.org/wiki/Hydrophobic-polar_protein_folding_model"> HP protein folding model</a> <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi="> is in NP</a>. This model basically simplifies the way that amino acids fold in space to form proteins, the essential actors in all cells. If we had an algorithm in P to solve this problem we could possibly design substances that have specific 3D shapes and properties, instead of simply finding them. For example <a href="http://en.wikipedia.org/wiki/Anti-idiotypic_vaccine"> some vaccines</a> work because the 3D shape of a protein in the vaccine fits the 3D shape of a protein in the pathogen. Who knows how many illnesses we could cure with that technology. </p> <a href="http://en.wikipedia.org/wiki/Protein_folding"> <img src="http://www.javiertordable.com/img/protein-folding.jpg" alt="Protein folding"/> </a> High Frequency Trading Art http://www.javiertordable.com/high-frequency-trading-art Sat, 31 Jul 2010 19:29:49 GMT http://www.javiertordable.com/high-frequency-trading-art <p> The folks at <a href="http://www.zerohedge.com/">Zero Hedge</a> published a very interesting post about <a href="http://www.zerohedge.com/article/its-not-market-its-hft-crop-circle-crime-scene-further-evidence-quote-stuffing-manipulation-"> high frequency trading and market manipulation</a>. I am not going to discuss economy or finance now, but there is something about that post that is quite shocking. The images which show the prices and volumes of the orders routed to the market have a certain aesthetic appeal. </p> <p> All the patterns below were most likely created by high frequency trading algorithms, which send thousands of orders to the financial markets and cancel them in milliseconds. The top part of the graph shows the price of the order, and the bottom part the number of shares of the bid or ask. The descriptions are copied from Zero Hedge. Click on the images to see a high resolution version. </p> <p> BATS "Flag Repeater". 15,000 quotes in 11 seconds, dropping the ASK price 1 penny each quote from $9.36 to $8.58 and back up again. 07-29-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%201%20Nanex.png"> <img src="http://www.javiertordable.com/img/hft-1-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> "The Crown". While not a large number of quotes, this NASDAQ/BATS Bidsize sequence was just too unusual to bypass. 07-29-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%202%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-2-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> BATS "Batsicles". BATS price cycling through a large price range, each intermittent with a stub quote, drop it down and start over. 07-28-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%203%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-3-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> NASDAQ "Blotter". One of the more unusual repeating Asksize cycles. 07-27-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%204%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-4-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> BATS "Stubby Triangles". Drop the quote from a valid price to 0.001 and then back up to a lower price level. When the new price level hits 0.001 as well, do it all over again at approx. 380 times a second. 07-23-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%205%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-5-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> NASDAQ "Flutter". 4000 quotes in 2 seconds, alternating the bid price/size in 3 increments and effecting the Best Bid along the way. 07-23-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%206%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-6-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> BATS "Periscopes". 8000 quotes in 3 seconds, alternating the bid price each quote. Pop the size up 1 every second or so. 07-23-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%207%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-7-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> NASDAQ "Double Dip". Symbol SH. 10,000 Quotes in 4 seconds, each affecting the Best Bid. 07-22-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%208%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-8-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> NASDAQ "Racing Stripe". Symbol WYNN. 2000 Quotes in one second, each affecting the Best Ask. 07-19-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%209%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-9-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> PACIFIC "Puzzle Pieces". Symbol IIC. 07-19-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%2010%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-10-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> NASDAQ "Blue Bandsaw". Symbol SHG. (760 quotes in 1 second, taken from a total sampling of 10,000 quotes in 12 seconds). 07-14-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%2011%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-11-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> BATS "60-Step". Symbol SAH. Take sixty steps up (a penny at a time) and one step down (0.60), reset and do it all over again (at approx. 700 times per second). 07-13-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%2012%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-12-s.jpg" alt="High Frequency Trading Art 1"/> </a> <p> NASDAQ "Ask Mountain". Symbol IAU. Over 56,000 quotes in 10 seconds, all with same Ask Price and the Ask Size increasing or decreasing by 1 (to almost 40,000!). 07-12-10. </p> <a href="http://www.zerohedge.com/sites/default/files/images/user5/imageroot/trichet/1%2013%20nanex.png"> <img src="http://www.javiertordable.com/img/hft-13-s.jpg" alt="High Frequency Trading Art 1"/> </a> Beauty and Truth in Science http://www.javiertordable.com/beauty-and-truth-in-science Sat, 24 Jul 2010 00:20:05 GMT http://www.javiertordable.com/beauty-and-truth-in-science <object width="480" height="300"> <param name="movie" value="http://www.youtube.com/v/UuRxRGR3VpM&amp;hl=en_US&amp;fs=1"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/UuRxRGR3VpM&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="300"> </embed> </object> <p> I just watched this fascinating talk from <a href="http://en.wikipedia.org/wiki/Murray_Gell-Mann"> Murray Gell-Mann</a>. The core idea of the talk is that in Physics, as in so many other areas of Science and Mathematics, incredibly complex ideas can be expressed in a simple and concise way. This is a remarkable property of the universe in which we live, and in that fact there is an amazing beauty. </p> <p> Gell-Mann gives an example from Physics, </p> <img src="http://www.javiertordable.com/img/newton-gravity-law.png" alt="Newton's Gravity Law"/> <p> This is the <a href="http://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation"> Law of Gravitation discovered by Newton</a>. It describes both the mechanism by with objects fall to the ground when dropped, as well as why the planets move in space. For its time it was a massive unification of many seemingly unrelated phenomena. It explains so much of how the world works, yet it can be written with just a few characters. </p> <p> Here is another example from Mathematics, the <a href="http://en.wikipedia.org/wiki/Prime_number_theorem"> Prime Number Theorem</a>, </p> <img src="http://www.javiertordable.com/img/prime-number-theorem.png" alt="The Prime Number Theorem"/> <p> Natural numbers are some of the most elemental constructions of the human mind, but they allow us to count from the fingers in our hand to the last atom in the entire universe. We know from basic arithmetic that all natural numbers can be factored into primes, so primes are in a sense the “building blocks” of all numbers. And even though primes are distributed in an incredibly intricate way, the Prime Number Theorem explains the very structure of these building blocks. </p> Edward Tufte, Presenting Data and Information http://www.javiertordable.com/edward-tufte-presenting-data-and-information Sun, 20 Jun 2010 01:25:20 GMT http://www.javiertordable.com/edward-tufte-presenting-data-and-information <p> Last week I attended <a href="http://www.edwardtufte.com/tufte/courses"> Edward Tufte's course on data visualization</a> here in Seattle. For those who don't know him, Tufte is one of the world's top experts on information visualization. Here is a short description, from his website: </p> <div id="special-text"> Edward Tufte has written seven books, including Beautiful Evidence, Visual Explanations, Envisioning Information, The Visual Display of Quantitative Information, and Data Analysis for Politics and Policy. He writes, designs, and self-publishes his books on analytical design, which have received more than 40 awards for content and design. He is Professor Emeritus at Yale University, where he taught courses in statistical evidence, information design, and interface design. His current work includes landscape sculpture, printmaking, video and a new book. </div> <p> During the course Tufte made several observations that go against what some other people in the field recommend. The most notable from my point of view is to use visualizations with lots of content. And instead of trying to simplify the data, let people understand it on their own. I believe this can be appropriate in many cases, for example in an <a href="http://www.tfl.gov.uk/assets/downloads/standard-tube-map.gif"> underground map</a>: </p> <a href="http://www.tfl.gov.uk/assets/downloads/standard-tube-map.gif"> <img src="http://www.javiertordable.com/img/underground-map-detail.png" alt="Detail of the London tube map"/> </a> <p> However in some other cases the information overload hides what is really important. For example in this awful visualization in <a href="http://www.forbes.com/2010/06/04/migration-moving-wealthy-interactive-counties-map.html"> Forbes about where Americans are moving</a>: </p> <a href="http://www.forbes.com/2010/06/04/migration-moving-wealthy-interactive-counties-map.html"> <img src="http://www.javiertordable.com/img/forbes-where-americans-move.jpg" alt="Forbes visualization. Moving patterns of Americans"/> </a> <p> It's impossible to understand everything that is going on. What I got out of it is that people are moving from the most economically impacted areas (Southern California, Detroit, Miami, etc.) and into the least impacted areas (Pacific northwest, Texas, New York, Washington, etc.). Also I think I saw a minor trend of movement from colder areas to warmer areas. However with all that clutter it's hard to understand the overall picture. It is true that overload in general is a failure of design, not a problem with information, however it's definitely easier to make bad designs when one tries to present too much data. </p> <p> In general the course was interesting, but for the most part it covered basic content. However they gave us a copy of Tufte's four books in visualization! Click on the following images to go to the corresponding Amazon pages: </p> <p> <a href="http://www.amazon.com/gp/product/0961392142?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392142">The Visual Display of Quantitative Information</a> </p> <a href="http://www.amazon.com/gp/product/0961392142?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392142"> <img src="http://www.javiertordable.com/img/tufte-visual-display.jpg" alt="Edward Tufte. The Visual Display of Quantitative Information"> </a> <p> <a href="http://www.amazon.com/gp/product/0961392118?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392118">Envisioning Information</a> </p> <a href="http://www.amazon.com/gp/product/0961392118?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392118"> <img src="http://www.javiertordable.com/img/tufte-envisioning-information.jpg" alt="Edward Tufte. Envisioning Information"> </a> <p> <a href="http://www.amazon.com/gp/product/0961392126?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392126">Visual Explanations</a> </p> <a href="http://www.amazon.com/gp/product/0961392126?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392126"> <img src="http://www.javiertordable.com/img/tufte-visual-explanations.jpg" alt="Edward Tufte. Visual Explanations"> </a> <p> <a href="http://www.amazon.com/gp/product/0961392177?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392177">Beautiful Evidence</a> </p> <a href="http://www.amazon.com/gp/product/0961392177?ie=UTF8&tag=javitordblogo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0961392177"> <img src="http://www.javiertordable.com/img/tufte-beautiful-evidence.jpg" alt="Edward Tufte. Beautiful Evidence"> </a> The Best Cities for Singles in America http://www.javiertordable.com/best-cities-for-singles-in-america Sun, 06 Jun 2010 03:38:36 GMT http://www.javiertordable.com/best-cities-for-singles-in-america <script type='text/javascript' src='http://www.google.com/jsapi'> </script> <p> A few weeks back I had a conversation with a friend about different places in the US where she was considering moving. And one of the factors was the dating scene in each one of those places. This brought to my memory a graph that probably many of you have already seen: </p> <img src="http://www.javiertordable.com/img/national-geographic-chart.jpg" alt="National Geographic Chart"> <p> This map basically says the following: </p> <ul> <li>If the dot is blue, there are more men than women</li> <li>If the dot is orange, there are more women than men</li> <li>The bigger the dot, the greater the difference</li> </ul> <p> However it has a series of problems. First of all, it's too dense. Second, it is not clear that the number of single men minus the number of single women (or the opposite) is what really matters, because obviously the bigger the city the less important the difference is. For example, in a city of 1 million we could have 100K singles and 20K more single men than woman. This means there are 3 single men for every two single woman. However in a city of 10 million, with 1 million singles, the fact that there are 20K more single men, only means there are approximately 1.02 single men for every single woman. It seems that the proportion of single men to single woman is more indicative than the difference. And third and most important, I didn't know for sure if the data in the graph is reliable, as there are no sources cited. So, as you can imagine I decided to check if there is actually any truth in this chart. </p> <p> Here is the list of steps necessary to get the interesting data from the Census: </p> <ol> <li>Start in the <a href="http://factfinder.census.gov"> Census fact finder homepage</a></li> <li>Click on Data Sets on the left navigation bar</li> <li>Select SF3 and click on Detailed Table</li> <li>In the Geography Type section choose Metropolitan Statistical Area</li> <li>Make sure all statistical areas are selected and click Next</li> <li>Now choose the table P18. Sex by marital status for the population 15+ years</li> <li>Click on Add and then Show result</li> </ol> <p> From this table we want the "Never married" rows. Because the table is too big to analyze directly (280 columns) Let's download it and map the results using the Google Charts API. </p> <p> You may need to clean up the downloaded file, because there are copyright notices and extra end of line characters. Also you may keep only the interesting lines, which are 3: </p> <ul> <li>The header of the table, which contains the name of the metropolitan areas</li> <li>The row for Male / Never Married individuals</li> <li>The row for Female / Never Married individuals</li> </ul> <p> After removing all other rows, it's possible to parse the file and extract the interesting data with a small python script like this: </p> <pre> input_file = open('DTDownload.csv') # First process the header line. header = input_file.readline() header = header[5:-2] # Remove " ", at beginning and "\n at the end. tokens = header.split('","') cities = [] for token in tokens: token = token.replace('MSA', '') # Eliminate the MSA suffix. token = token.replace('CMSA', '') if token.find('--'): # Remove everything after -- token = token[:token.find('--')] cities.append(token) # Now process "Never married" men. line = input_file.readline() line = line[17:-2] # Remove "Never married" at beginning and " at end. tokens = line.split('","') single_men = [] for token in tokens: token = token.replace(',', '') # Eliminate the , for thousands. single_men.append(int(token)) # Now process "Never married" women. line = input_file.readline() line = line[17:-2] # Remove "Never married" at beginning and " at end. tokens = line.split('","') single_women = [] for token in tokens: token = token.replace(',', '') # Eliminate the , for thousands. single_women.append(int(token)) # And from those two quantities compute the ratio of single men # to single women. The higher, the better for women. Reverse the # quotient to get the other side. ratios = [] for i in xrange(len(single_men)): ratio = float(single_men[i]) / float(single_women[i]) ratios.append(ratio) # Now print the name of the city and ratio in the format accepted # by the Google Charts API, which is: # data.setValue(0, 0, 'New York'); # data.setValue(0, 1, 1.064382); for i in xrange(len(cities)): print 'data.setValue(%(row)d, 0, \'%(city)s\');' % \ {'row': i, 'city': cities[i]} print 'data.setValue(%(row)d, 1, %(ratio)f);' % \ {'row': i, 'ratio': ratios[i]} </pre> <p> And to display the data, just include it into a <a href="http://code.google.com/apis/ajax/playground/?type=visualization#geo_map"> Google Charts visualization</a>. Unfortunately I couldn't figure out how to make the circles bigger or smaller based on one parameter and to set the color based on another parameter. Please tell me if you know how to do it. Anyway, until I find some time to learn <a href="http://vis.stanford.edu/protovis/">Protovis</a>, bear with me. What I did is split the chart into two, one for guys and one for girls. And to have it load faster, and avoid overloading with too much detail, I just took a small number of cities (This was actually Noha's idea so the credit should go to her). Here is how the chart looks like for girls, the bigger and bluer the better. It means there are more single guys for each single girl: </p> <script type="text/javascript"> google.load('visualization', '1', {'packages': ['geomap']}); google.setOnLoadCallback(drawMap1); function drawMap1() { var data = new google.visualization.DataTable(); data.addRows(28); data.addColumn('string', 'City'); data.addColumn('number', 'Ratio'); data.setValue(0, 0, 'Atlanta'); data.setValue(0, 1, 1.167621); data.setValue(1, 0, 'Boston'); data.setValue(1, 1, 1.082052); data.setValue(2, 0, 'Chicago'); data.setValue(2, 1, 1.128832); data.setValue(3, 0, 'Cleveland'); data.setValue(3, 1, 1.080480); data.setValue(4, 0, 'Dallas'); data.setValue(4, 1, 1.250400); data.setValue(5, 0, 'Denver'); data.setValue(5, 1, 1.271842); data.setValue(6, 0, 'Detroit'); data.setValue(6, 1, 1.121086); data.setValue(7, 0, 'Houston'); data.setValue(7, 1, 1.225656); data.setValue(8, 0, 'Indianapolis'); data.setValue(8, 1, 1.116891); data.setValue(9, 0, 'Jacksonville'); data.setValue(9, 1, 1.184223); data.setValue(10, 0, 'Kansas City'); data.setValue(10, 1, 1.137844); data.setValue(11, 0, 'Las Vegas'); data.setValue(11, 1, 1.417289); data.setValue(12, 0, 'Los Angeles'); data.setValue(12, 1, 1.214651); data.setValue(13, 0, 'Memphis'); data.setValue(13, 1, 1.049954); data.setValue(14, 0, 'Miami'); data.setValue(14, 1, 1.178491); data.setValue(15, 0, 'Milwaukee'); data.setValue(15, 1, 1.089912); data.setValue(16, 0, 'Minneapolis'); data.setValue(16, 1, 1.146799); data.setValue(17, 0, 'New Orleans'); data.setValue(17, 1, 1.028731); data.setValue(18, 0, 'New York'); data.setValue(18, 1, 1.064382); data.setValue(19, 0, 'Orlando'); data.setValue(19, 1, 1.224336); data.setValue(20, 0, 'Philadelphia'); data.setValue(20, 1, 1.055936); data.setValue(21, 0, 'Phoenix'); data.setValue(21, 1, 1.325386); data.setValue(22, 0, 'Portland'); data.setValue(22, 1, 1.253985); data.setValue(23, 0, 'Salt Lake City'); data.setValue(23, 1, 1.270336); data.setValue(24, 0, 'San Diego'); data.setValue(24, 1, 1.378117); data.setValue(25, 0, 'San Francisco'); data.setValue(25, 1, 1.261324); data.setValue(26, 0, 'Seattle'); data.setValue(26, 1, 1.270545); data.setValue(27, 0, 'Washington'); data.setValue(27, 1, 1.061015); var options = {}; options['region'] = 'US'; options['width'] = 500; options['height'] = 300; options['colors'] = [0xFFFFFF, 0x0000FF, 0x000055]; options['dataMode'] = 'markers'; var container = document.getElementById('map_canvas1'); var geomap = new google.visualization.GeoMap(container); geomap.draw(data, options); }; </script> <p> <div id='map_canvas1' style="margin-left: 40px;"></div> </p> <p> It seems that the West Coast, Texas and Florida are the best places for girls. Here is how it looks like when taking all 280 cities. I did not include the visualization, but a simple image because it takes quite a while to load. </p> <img src="http://www.javiertordable.com/img/best-cities-for-singles-chart-guys.jpg" alt="Chart of the best cities for single guys"> <p> The one for guys is the opposite, the bigger and more pink, the better. It means there are more single girls for each single guy: </p> <script type="text/javascript"> google.load('visualization', '1', {'packages': ['geomap']}); google.setOnLoadCallback(drawMap2); function drawMap2() { var data = new google.visualization.DataTable(); data.addRows(28); data.addColumn('string', 'City'); data.addColumn('number', 'Ratio'); data.setValue(0, 0, 'Atlanta'); data.setValue(0, 1, 0.856442287); data.setValue(1, 0, 'Boston'); data.setValue(1, 1, 0.924170003); data.setValue(2, 0, 'Chicago'); data.setValue(2, 1, 0.885871414); data.setValue(3, 0, 'Cleveland'); data.setValue(3, 1, 0.925514586); data.setValue(4, 0, 'Dallas'); data.setValue(4, 1, 0.799744082); data.setValue(5, 0, 'Denver'); data.setValue(5, 1, 0.786261187); data.setValue(6, 0, 'Detroit'); data.setValue(6, 1, 0.891992229); data.setValue(7, 0, 'Houston'); data.setValue(7, 1, 0.815889613); data.setValue(8, 0, 'Indianapolis'); data.setValue(8, 1, 0.895342518); data.setValue(9, 0, 'Jacksonville'); data.setValue(9, 1, 0.84443555); data.setValue(10, 0, 'Kansas City'); data.setValue(10, 1, 0.878855098); data.setValue(11, 0, 'Las Vegas'); data.setValue(11, 1, 0.705572399); data.setValue(12, 0, 'Los Angeles'); data.setValue(12, 1, 0.823281749); data.setValue(13, 0, 'Memphis'); data.setValue(13, 1, 0.952422678); data.setValue(14, 0, 'Miami'); data.setValue(14, 1, 0.848542755); data.setValue(15, 0, 'Milwaukee'); data.setValue(15, 1, 0.917505266); data.setValue(16, 0, 'Minneapolis'); data.setValue(16, 1, 0.871992389); data.setValue(17, 0, 'New Orleans'); data.setValue(17, 1, 0.972071416); data.setValue(18, 0, 'New York'); data.setValue(18, 1, 0.939512318); data.setValue(19, 0, 'Orlando'); data.setValue(19, 1, 0.816769253); data.setValue(20, 0, 'Philadelphia'); data.setValue(20, 1, 0.947027093); data.setValue(21, 0, 'Phoenix'); data.setValue(21, 1, 0.75449718); data.setValue(22, 0, 'Portland'); data.setValue(22, 1, 0.797457705); data.setValue(23, 0, 'Salt Lake City'); data.setValue(23, 1, 0.787193309); data.setValue(24, 0, 'San Diego'); data.setValue(24, 1, 0.725627795); data.setValue(25, 0, 'San Francisco'); data.setValue(25, 1, 0.792817706); data.setValue(26, 0, 'Seattle'); data.setValue(26, 1, 0.787063819); data.setValue(27, 0, 'Washington'); data.setValue(27, 1, 0.942493744); var options = {}; options['region'] = 'US'; options['width'] = 500; options['height'] = 300; options['colors'] = [0xFFFFFF, 0xFF0088, 0xFF0022]; options['dataMode'] = 'markers'; var container = document.getElementById('map_canvas2'); var geomap = new google.visualization.GeoMap(container); geomap.draw(data, options); }; </script> <p> <div id='map_canvas2' style="margin-left: 40px;"></div> </p> <p> So the best places for guys seem to be the East Coast and the Great Lakes area. In particular the Bos-Wash corridor seems to be quite good. And here is how it looks like when taking all metropolitan areas: </p> <img src="http://www.javiertordable.com/img/best-cities-for-singles-chart-girls.jpg" alt="Chart of the best cities for single girls"> <p> Does anyone know of similar charts for other countries? I have never seen one myself. But after what we said before, if you can find census-like data now you can make one yourself! </p> Quantitative Ponzinomics http://www.javiertordable.com/quantitative-ponzinomics Fri, 07 May 2010 22:40:28 GMT http://www.javiertordable.com/quantitative-ponzinomics <p> Just a quick pointer to a book that I am reading right now, <strong>Quantitative Ponzinomics</strong>, an essential guide to understand what is going on currently in the financial markets around the world. </p> <img src="http://www.javiertordable.com/img/quantitative-ponzinomics.jpg" alt="Quantitative Ponzinomics"> <p> Ok, it's not a real book, but you should really check out the source, the financial blog <a href="http://www.zerohedge.com">Zero Hedge</a>. And in order to keep this blog on-topic, here is an interesting link about <a href="http://www.wikinvest.com/wiki/High-Frequency_Trading_(HFT)"> High Frequency Trading</a>, which is an automated procedure to make financial transactions using computer algorithms to get an advantage over other investors. </p> Machine Learning at Stanford http://www.javiertordable.com/machine-learning-stanford Sat, 01 May 2010 23:28:57 GMT http://www.javiertordable.com/machine-learning-stanford <p> This quarter I am leading a study group in Machine Learning at Google's Kirkland Office. And while I was looking for datasets and resources I found <a href="http://ai.stanford.edu/~ang/">Andrew Ng's</a> course in Machine Learning at Stanford. All the lectures are available online at YouTube. You can find the links in the <a href="http://see.stanford.edu/see/lecturelist.aspx?coll=348ca38a-3a6d-4052-937d-cb017338d7b1"> Stanford Engineering Everywhere Machine Learning course page</a>. </p> <p> Here is the first class of the series: </p> <object width="480" height="385"> <param name="movie" value="http://www.youtube.com/v/UzxYlbK2c7E&hl=en_US&fs=1&"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/UzxYlbK2c7E&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed> </object> <p> Also you can check out the main <a href="http://see.stanford.edu/see/courses.aspx"> Stanford Engineering Everywhere page</a> for other courses in computer science. </p> Preserving the Wealth Creation Engine of America http://www.javiertordable.com/preserving-the-wealth-creation-engine-of-america Sun, 18 Apr 2010 04:28:46 GMT http://www.javiertordable.com/preserving-the-wealth-creation-engine-of-america <p> Over the last few decades hundreds of companies, thousands of jobs and billions of dollars of real wealth were created by startups with the support of angel investors. The possibility of a small company to obtain seed funding with little more than an idea is indeed one of the most important wealth creation engines of America. Now this possibility, this engine, is at stake. </p> <p> There is a bill currently under review in the Senate that includes two provisions that directly threaten the way that startups are funded. The bill is the "<strong>Restoring American Financial Stability Act of 2010</strong>” supported by Senator Dodd. Even though the intention of the bill is noble, to attempt to protect investors against fraudulent investment requests, two of its sections can have severe unintended consequences for the economy and the society of the United States. The first one is the following: </p> <div class="special-text"> <p> <strong>SEC. 412. ADJUSTING THE ACCREDITED INVESTOR STANDARD FOR INFLATION</strong>.<br/> The Commission shall, by rule—<br/> (1) increase the financial threshold for an accredited investor, as set forth in the rules of the Commission under the Securities Act of 1933, by calculating an amount that is greater than the amount in effect on the date of enactment of this Act of $200,000 income for a natural person (or $300,000 for a couple) and $1,000,000 in assets, as the Commission determines is appropriate and in the public interest, in light of price inflation since those figures were determined; and (2) adjust that threshold not less frequently than once every 5 years, to reflect the percentage increase in the cost of living. </p> </div> <p> This basically raises the minimum income and assets that an investor needs to have to be considered qualified to invest in a startup. The limit would go from $1 million of net worth to $2.3 million and from $200,000 of annual income to $449,000. This could affect more than two thirds of all angel investors. </p> <img src="http://www.javiertordable.com/img/senate-committee-banking.jpg" alt="United States Senate committee on Banking" /> <p> The second section is: </p> <div class="special-text"> <p> <strong>SEC. 926. AUTHORITY OF STATE REGULATORS OVER REGULATION D OFFERINGS</strong>.<br/> [...]<br/> IN GENERAL.—The Comission shall review any filings made relating to any security issued under Commission rules or regulations under section 4(2), other than one designated as a non-covered security under subparagraph (A)(iv), not later than 120 days of the filing with the Commission.<br/> [...]<br/> IN GENERAL.—Nothing in subparagraph (A)(iv), (B), or (C), shall be construed to prohibit a State from imposing notice filing requirements that are substantially similar to filing requirements required by rule or regulation under section 4(4) that were in effect on September 1, 20 1996.<br/> [...]<br/> </p> </div> <p> it essentially would require startups to make a filing with the SEC, which will have up to 120 days to review it. If the SEC doesn't review the filing then securities regulators in all states involved in the deal will have the chance to review it. What this means is that cash-strapped startups will have to wait 4 months for funds, and they will have to comply with securities laws of up to 50 states, with significant costs in legal fees. </p> <p> <a href="http://www.saveregd.com/">http://www.saveregd.com/</a>, contains more information about the significance of this sections and the impact that they may have on startups. Also you may find the full bill <a href="http://banking.senate.gov/public/_files/ChairmansMark31510AYO10306_xmlFinancialReformLegislationBill.pdf"> here</a>. </p> <p> I believe that these two sections of the bill will impact negatively startups, angel investors, and as a result the mechanism by which entrepreneurs get funding for new ideas, innovate, and generate jobs and wealth. To express your oposition to these two sections of the bill, and help preserve one of the most important wealth creation engines of America, I would like to ask you to review and <a href="http://gopetition.com/online/32354.html"> sign this petition now</a>. </p> How to Make an Infographic Résumé http://www.javiertordable.com/how-to-make-an-infographic-resume Tue, 23 Mar 2010 04:08:19 GMT http://www.javiertordable.com/how-to-make-an-infographic-resume <script type="text/javascript" src="http://www.google.com/jsapi"> </script> <script type="text/javascript"> google.load('visualization', '1',{packages: ['annotatedtimeline']}); google.load('visualization', '1', {packages: ['table']}); </script> <p> <strong>Infographics</strong>, or information graphics are visual representations of data. In a good visualization or representation of a data set, the author expresses an idea that is deeper that the data itself. A good visualization conveys a message that is clear and helps to extract conclusions, but also a message that is precise and based on the data, without transforming or manipulating the data in dishonest ways. </p> <p> In the case of a <strong>résumé</strong>, the data is obviously the education, professional experience and interests of the candidate. And the purpose of an <strong>infographic résumé</strong> is to show the greatest highlights of his or her education and professional experience, to convince a potential employer of the value of the candidate. To do that, the charts and visualization elements have to be adequate to the characteristics that we want to remark. For example: </p> <ul> <li> If a candidate has a lot of international professional experience, one way to show that is to include a world map with the location of the last work assignments </li> <li> Or if the candidate is a senior executive of a public corporation, it may be interesting to show the stock value of the company at the time that the executive launched new products, or took important business-wide decisions </li> <li> In case of a professor with a long publication history, it may be very valuable to show a chart of important publications and their citation index, as a measure of the impact of those publications in the scientific community </li> </ul> <h3>Some Example Résumés</h3> <p> Over the last few years several designers have experimented with inforgraphic résumés. Recently <strong>Randy Krum</strong> wrote a post about it in his blog <a href="http://www.coolinfographics.com/blog/2010/1/8/16-infographic-resumes-a-visual-trend.html"> Cool Infographics</a>. I am not going to repeat what he said, but I will mention a few of the most famous ones. </p> <p> The résumé of <strong>Michael Anderson</strong> is probably the most cited one, it includes a timeline with education and experience, and marks for the most important events. It is visually attractive, but the colors and sizes of the different elements don't really mean anything. And the whole bottom left part of the chart is only meant to show some sense of humor. You can click on the thumbnail below to see the full image. </p> <a href="http://theportfolio.ofmichaelanderson.com/wp-content/uploads/2008/05/resume-infographic.jpg"> <img src="http://www.javiertordable.com/img/michael-anderson-resume-infographics.jpg" alt="Infographic resume of Michael Anderson" /> </a> <p> <strong>Christoper Perkins</strong> designed another résumé using the common look of a subway map. Also it is visually original, but the connections between the different elements are not very complex (only two intersections between lines), so using the look of a subway map seems to add more complexity that it removes. Also this visualization uses intersections between lines to represent the fact that two events happened at the same point in time. But the fact that two work projects or education courses happened at the same time is probably not the most important characteristic of a résumé. </p> <a href="http://www.flickr.com/photos/ernestolago/4144781475/sizes/o/"> <img src="http://www.javiertordable.com/img/christopher-perkins-inforgaphic-resume.jpg" alt="Infographic resume of Christopher Perkins"/> </a> <p> Compare this use of the subway visualization with the Map of Rock of <strong>Ernesto Lago</strong>. Here what is important is how some musicians merge two different styles, or inherit from two different musical schools or traditions, and that is exactly what the subway intersections represent. </p> <a href="http://www.flickr.com/photos/ernestolago/4144781475/"> <img src="http://www.javiertordable.com/img/rockmap-ernesto-lago.jpg" alt="Rock Map of Ernesto Lago"/> </a> <p> <strong>Greg Dizzia</strong> gives a different point of view. In his résumé he adds the skills involved in each professional project. I think this is very valuable to potential employers, and it's one of the main points of a résumé. In this case I think the visualization is a little bit too charged and repetitive but the main message is very well expressed. </p> <a href="http://dizzia.deviantart.com/art/Curriculum-Vitae-PDF-69050981"> <img src="http://www.javiertordable.com/img/curriculum-vitae-by-greg-dizzia.png" alt="Infographic resume of Greg Dizzia"/> </a> <p> As a last example let's take a look at the résumé of <strong>Gabriele Bozzi</strong>. In this case he forgets almost completely about the temporal element of the résumé and concentrates on the functional areas. And he divides them between general skills, and knowledge of particular applications and tools. To me this has too much detail, and way too much <em>keyword hunting</em>, but the visual display is very interesting. </p> <a href="http://www.kaukana.be/wp/?p=430"> <img src="http://www.javiertordable.com/img/gabriele-bozzi-infographic-resume.png" alt="Infographic resume of Gabriele Bozzi"/> </a> <h3>How to Make an Infographic Résumé yourself</h3> <p> First of all, just like any other infographic project we need to decide what data we are going to show. In my case I will take short snippets of projects in which I have worked on. Because the main point of this post is to show how to develop the visual component I won't spend too much time in getting a great wording of each project, or using the correct keywords. </p> <p> Second, it's necessary to decide what is the most important messages that we want to convey from that data. In my case these messages are: </p> <ul> <li> <strong>Education</strong>: I have a thorough education in Computer Science and Mathematics. It is not too varied because I don't have courses or certifications in other areas, and I studied all my degrees in the same University. But I have spent 10 years on it. Also, I don't want to add much detail about college projects, because they are less interesting than professional projects. And I don't want to mix education and work, because I combined both over the last few years and it would just look confusing </li> <li> <strong>Work</strong>: I have worked in some of the most prestigious companies in the world, in increasing degrees of responsibility and success and I definitely want to emphasize that. Also I want to mention that I worked in some particular areas in software, like machine learning. And I started doing a little bit of research lately. So I think it's worth showing that I am versatile, in terms of work skills. Finally I think it's also worth mentioning my contributions to open source and internships, because they add variety to my professional experience </li> <li> <strong>Impact</strong>: Finally, because I have been lucky to work in projects that are public and other people are using, I have had a significant impact outside of my employers. I want to emphasize that as well </li> </ul> <p> And third, after the message is clear, it's turn to decide what kind of visualization would fit best the data and the message. I won't go very deep into this topic, because there is so much to talk about that we could fill several books. So here are the decisions I took: <p> <ul> <li> For the education I will simply show a bar with all the degrees that I have attained, in a straight line. The size of each part of the bar indicates how long it took to get that degree. The colors are only to differentiate sections. A legend at the bottom will indicate what is each section. Also as this is the weakest section, it will go at the end of the résumé </li> <li> For the experience part, I will show a timeline of professional positions, and the main projects within those positions. I will add the logos of the corresponding companies on the left side. And for each project I will indicate the functional skills that I used. In order to keep it simple I will have only 5 main skills. Also to have space for all the positions, I will have a vertical timeline, instead of the most common horizontal one </li> <li> Finally, the impact of my projects is probably the most differentiating characteristic of my resume, so I will put it on top. And in order to show data that is easy to check I will use as a measure of impact the number of search results in google.com for the project name, divided by the number of developers in the project. In order to indicate which project corresponds to which value in the graph I will use an annotated time series. </li> </ul> <p> And without any more delay, here is the result! </p> <h3> Impact </h3> <script type="text/javascript"> function drawVisualization1() { var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); data.addColumn('number', 'Impact'); data.addColumn('string', 'title1'); data.addColumn('string', 'text1'); data.addRows(8); data.setValue(0, 0, new Date(2005, 7 ,1)); data.setValue(0, 1, 11000); data.setValue(0, 2, 'Microsoft'); data.setValue(0, 3, '<em>Intern</em> <a href="http://www.google.com/search?q=windows+vista+webdav+testing">Windows Vista WebDAV Testing</a><br/>(134K / 12)'); data.setValue(1, 0, new Date(2006, 6 ,2)); data.setValue(1, 1, 7800); data.setValue(1, 2, 'McKinsey'); data.setValue(1, 3, '<em>Intern</em> <a href="http://www.google.com/search?q=mckinsey+arcelor+mittal+merger">Arcelor Mittal Merger</a><br/>(47K / 6)'); data.setValue(2, 0, new Date(2007, 3 ,3)); data.setValue(2, 1, 24000); data.setValue(2, 2, 'Microsoft'); data.setValue(2, 3, '<em>Engineer</em> <a href="http://www.google.com/search?q=live+search+relevance">Live Search Relevance</a><br/>(24M / 1K)'); data.setValue(3, 0, new Date(2008, 3 ,4)); data.setValue(3, 1, 2500); data.setValue(3, 2, 'OpenSource'); data.setValue(3, 3, '<em>Author</em> <a href="http://www.google.com/search?q=financeAI">FinanceAI</a><br/>(2.5K / 1)'); data.setValue(4, 0, new Date(2008, 10 ,5)); data.setValue(4, 1, 11000); data.setValue(4, 2, 'Google'); data.setValue(4, 3, '<em>Engineer</em>, <a href="http://www.google.com/search?q=webmaster+tools+new+GData+API">Webmaster Tools new GData API</a><br/>(11K / 1)'); data.setValue(5, 0, new Date(2009, 6 ,6)); data.setValue(5, 1, 12000); data.setValue(5, 2, 'OpenSource'); data.setValue(5, 3, '<em>Author</em> <a href="http://www.google.com/search?q=map+reduce+integer+factorization">Map Reduce Integer Factorization</a><br/>(11K / 1)'); data.setValue(6, 0, new Date(2009, 10 ,7)); data.setValue(6, 1, 47000); data.setValue(6, 2, 'Google'); data.setValue(6, 3, '<em>Engineer</em>, <a href="http://www.google.com/search?q=webmaster+tools+labs">Webmaster Tools Labs</a><br/>(700K / 15)'); data.setValue(7, 0, new Date(2009, 11 ,8)); data.setValue(7, 1, 65000); data.setValue(7, 2, 'Google'); data.setValue(7, 3, '<em>Tech Lead</em>, <a href="http://www.google.com/search?q=fetch+as+googlebot">Fetch as Googlebot</a><br/>(65K / 1)'); var annotatedtimeline = new google.visualization.AnnotatedTimeLine( document.getElementById('visualization1')); annotatedtimeline.draw(data, {'displayAnnotations': true, 'max': 70000, 'allowHtml': true}); } google.setOnLoadCallback(drawVisualization1); </script> <p> <div id="visualization1" style="position: relative; left: -30px; width: 600px; height: 400px;"></div> </p> <p> Clicking in each one of the marks in the time series highlights the description of the project. For each case I have included the employer, the position and a very short description of the project. In parentheses is the number of search results divided by the number of people that worked in the project. Also clicking in the description takes to a search results page. The results are usually a reference my personal work, or work in which I participated. </p> <h3> Experience </h3> <script type="text/javascript"> function drawVisualization2() { // Create and populate the data table. var data = new google.visualization.DataTable(); data.addColumn('string', '<div style="text-align: center;">Position</div>'); data.addColumn('string', '<div style="text-align: center;">Software Engineering</div>'); data.addColumn('string', '<div style="text-align: center;">Cloud Computing</div>'); data.addColumn('string', '<div style="text-align: center;">Machine Learning</div>'); data.addColumn('string', '<div style="text-align: center;">Mathematical Research</div>'); data.addColumn('string', '<div style="text-align: center;">Strategic Consulting</div>'); data.addRows(6); data.setCell(0, 0, '<img src="http://www.google.com/intl/en_ALL/images/logo.gif" width=70><em>Tech Lead</em>'); data.setCell(0, 1, '<a href="http://www.google.com/search?q=fetch+as+googlebot">Fetch as Googlebot</a>'); data.setCell(0, 2, '<a href="http://www.google.com/search?q=webmaster+tools+backend">Webmaster Tools backend</a>'); data.setCell(0, 3, null); data.setCell(0, 4, null); data.setCell(0, 5, null); data.setCell(1, 0, '<img src="http://www.google.com/intl/en_ALL/images/logo.gif" width=70><em>Engineer</em>'); data.setCell(1, 1, '<a href="http://www.google.com/search?q=webmaster+tools+labs">Webmaster Tools Labs</a>'); data.setCell(1, 2, '<a href="http://www.google.com/search?q=webmaster+tools+new+GData+API">Webmaster Tools new GData API</a>'); data.setCell(1, 3, null); data.setCell(1, 4, null); data.setCell(1, 5, null); data.setCell(2, 0, '<img src="http://www.javiertordable.com/img/open-source.png" width=70>'); data.setCell(2, 1, null); data.setCell(2, 2, null); data.setCell(2, 3, '<a href="http://www.google.com/search?q=financeAI">FinanceAI</a>'); data.setCell(2, 4, '<a href="http://www.google.com/search?q=map+reduce+integer+factorization">Map Reduce Integer Factorization</a>'); data.setCell(2, 5, null); data.setCell(3, 0, '<img src="http://www.microsoft.com/library/toolbar/3.0/images/banners/ms_masthead_ltr.gif" width=70><em>Engineer</em>'); data.setCell(3, 1, null); data.setCell(3, 2, null); data.setCell(3, 3, '<a href="http://www.google.com/search?q=live+search+relevance">Live Search Relevance</a>'); data.setCell(3, 4, null); data.setCell(3, 5, null); data.setCell(4, 0, '<img src="http://www.javiertordable.com/img/mckinsey-logo.gif" width=70><em>Intern</em>'); data.setCell(4, 1, null); data.setCell(4, 2, null); data.setCell(4, 3, null); data.setCell(4, 4, null); data.setCell(4, 5, '<a href="http://www.google.com/search?q=mckinsey+arcelor+mittal+merger">Arcelor Mittal Merger</a>'); data.setCell(5, 0, '<img src="http://www.microsoft.com/library/toolbar/3.0/images/banners/ms_masthead_ltr.gif" width=70><em>Intern</em>'); data.setCell(5, 1, '<a href="http://www.google.com/search?q=windows+vista+webdav+testing">Windows WebDAV Testing</a>'); data.setCell(5, 2, null); data.setCell(5, 3, null); data.setCell(5, 4, null); data.setCell(5, 5, null); // Create and draw the visualization. visualization = new google.visualization.Table(document.getElementById('visualization2')); visualization.draw(data, {'width': 600, 'allowHtml': true}); } google.setOnLoadCallback(drawVisualization2); </script> <p> <div id="visualization2" style="position: relative; left: -30px;"></div> </p> <p> In the experience table I have added basically the same projects as above, but I have classified them by the main area of expertise. The link in each one of the projects point to search results, exactly the same way as before. It would have been also a good idea to point to a short description of the project. Initially I though about using color codes to indicate each main area of expertise, but this would add a little bit of duplication, because that is exactly what the columns mean. I think it is cleaner and more understandable without color coding the skills. </p> <h3> Education </h3> <img src="http://www.javiertordable.com/img/javier-tordable-education.png" alt="Education of Javier Tordable"/> <p> And finally, the education section. Here I decided to do a static image. The interactivity of the other visualizations wouldn't add anything. Also I used a similar color palette to the previous visualizations. Even though as it is there is no relationship with the visualizations above, I could have explored this idea further. Also I didn't add the university to avoid repeating the name four times. </p> <h3>Conclusion</h3> <p> To finish the post, I will repeat the core principles of how to make a good visualization: </p> <ol> <li> Collect the data to display, make sure its complete and precise </li> <li> Decide what is the most important message that you want to express </li> <li> Choose visualizations that convey that message but respect the data </li> </ol> Really Simple SEO http://www.javiertordable.com/really-simple-seo Fri, 12 Mar 2010 00:36:31 GMT http://www.javiertordable.com/really-simple-seo <p> SEO stands for Search Engine Optimization, and is the process of improving a website's structure and content in order to make it easy for search engines to gather the pages and display them in search results in the best position possible. </p> <img src="http://www.javiertordable.com/img/all-search-engines.png" alt="Search Engines"/> <p> In this post I am going to explain a few basic principles of SEO and show examples of how I implemented them in my blog. Also, as I am the Tech Lead of Webmaster Tools backend, I am going to talk a little bit about some features of Webmaster Tools that are very helpful for SEO. Please remember that all these tips are not only good for search engines, but also for users. If you have to choose between doing something to benefit users or search engines, always choose what is best for users. </p> <p> Here is the list of simple SEO tips: </p> <ul> <li><strong>Use a good URL structure, with descriptive URLs.</strong> If the URL has keywords related to the page topic it will be easier to find in search results. For example, the url of this post includes the words <em>really simple seo</em>, that are the topic of the post <pre> http://www.javiertordable.com/blog/2010/03/11/really-simple-seo </pre> </li> <li> <strong>Use good page titles.</strong> Similar to the previous tip, good page titles, with appropriate keywords make it easier to find the page in search results. Even though the title of this page includes the full name of the site, the title begins with a good description of the content <pre> Really Simple SEO - Javier Tordable blog on Software, Mathematics and Technology </pre> </li> <li> <strong>Have a good meta description for each page.</strong> The meta description is used by some search engines to show in the snippets in search results (the small paragraph with a description of the page). If you don't use it, you will have the risk that the search engine will generate it by itself, with unexpected results. This happened to me before I had a meta description, my snippet was taken from the RSS feed and looked awful. My current meta description for the homepage is: <pre> &lt;meta name="description" content="Javier Tordable blog on Software, Mathematics and Technology. Javier Tordable is a software engineer at Google and Ph.D. candidate in Mathematics."&gt; </pre> </li> <li> <strong>Structure the page appropriately, using HTML header tags.</strong> The most important parts should be within a H1 tag, the second most important in H2, etc. until H6. For example in this post the blog title and subtitle are within H1 and H2 tags. The title of the particular post is in a H2, and other less important sections, the about box and the archives are within an H3 HTML tag <pre> &lt;h1&gt;&lt;a href="/"&gt;Javier Tordable&lt;/a&gt;&lt;/h1&gt; &lt;h2&gt;A blog on Software, Mathematics and Technology&lt;/h2&gt; &lt;h3&gt;About&lt;/h3&gt; &lt;h3&gt;Archives&lt;/h3&gt; &lt;h2&gt;Really Simple SEO&lt;/h2&gt; </pre> </li> <li> <strong>Use the simplest format possible.</strong> Currently search engines are very advanced and can process Flash, Javascript and other content types, however it's always easier to access raw HTML content. So prefer to use HTML for most content, unless Flash or Javascript are essential. Also it will be easier to access the page from old browsers or other platforms. For example iPhone users can't see Flash pages </li> <li> <strong>Have a flat internal link structure.</strong> The flatter your link structure is, the easier it will be for search engines to access a page. Also the easier it will be for users to access whatever content they are looking for. In my blog I have all the main sections linked in the top navigation bar, which appears in all pages. And in the right side of most pages there is a link to all the blog posts <pre> &lt;a href="/blog/all"&gt;All Posts&lt;/a&gt; </pre> From the homepage of the site it's possible to access any other content page in two clicks or less. </li> </ul> <p> And now, some interesting pieces of information about your site that you can find in <a href="http://www.google.com/webmasters/tools/">Webmaster Tools</a>: </p> <ul> <li> One of my favorites is <strong>Backlinks</strong>, which will show you all the links pointing to your site, from all over the Web. Having many quality links is important because it will be easier for people to find your site, and it will show to search engines that the site is relevant. <img src="http://www.javiertordable.com/img/screenshot-webmaster-tools-backlinks.png" alt="Screenshot of Webmaster Tools Backlinks"/> </li> <li>Another very useful tool is <strong>Top Search Queries</strong>, which will show for which queries my site appears in search results. For example, the "bundle adjustment" query has more requests than "javier tordable" and it appears in the second row in the following table, while the other query is in the third row. However my site appears in position 16 for bundle adjustment, and it appears in position one for searches of my own name <img src="http://www.javiertordable.com/img/screenshot-webmaster-tools-top-search-queries.png" alt="Screenshot of Webmaster Tools Top Search Queries"/> </li> <li> Also, another cool piece of information is <strong>Subscriber Stats</strong> which shows how many subscribers I have for my RSS feed from <a href="http://www.google.com/reader">Google Reader</a>. In my case I can see that I have 10 people subscribed. And I can also submit this feed as a Sitemap, which will help getting my site indexed <img src="http://www.javiertordable.com/img/screenshot-webmaster-tools-subscriber-stats.png" alt="Screenshot of Webmaster Tools Subscriber Stats"/> For example, my Sitemap statistics show that I have 11 pages in this sitemap, and they are all indexed <img src="http://www.javiertordable.com/img/screenshot-webmaster-tools-sitemaps.png" alt="Screenshot of Webmaster Tools Sitemaps"/> </li> <li> And to check that my site is being correctly crawled, I can check the <strong>Crawl Stats </strong> feature. As you can see in the graph, the number of pages that are crawled in my site per day has been going up significantly since I implemented all this SEO tips <img src="http://www.javiertordable.com/img/screenshot-webmaster-tools-crawl-stats.png" alt="Screenshot of Webmaster Tools Crawl Stats"/> </li> </ul> <p> To finish, I am just going to point out that there are a lot of SEO resources online. Doing proper search engine optimization doesn't need to be complicated or expensive. And is not only good for search engines, but also for users. For more tips, you should check the <a href="http://googlewebmastercentral.blogspot.com/2008/11/googles-seo-starter-guide.html"> Google SEO guide</a>. </p> Collaborative Mathematics and The Future of Science http://www.javiertordable.com/collaborative-mathematics-future-of-science Thu, 25 Feb 2010 20:02:55 GMT http://www.javiertordable.com/collaborative-mathematics-future-of-science <p> Mathematical research is traditionally seen as a one-man job. To quote <a href="http://books.google.com/books?id=lQosnIw05dYC"> Jean Dieudonné in The Music of Reason</a>: </p> <div id="special-text"> Research in the experimental sciences is done in laboratories, where larger and larger teams are needed to manipulate the instruments and to scrutinize the results. To do research in mathematics nothing is needed except paper and a good library. Team-work, as practiced in the experimental sciences is, then, quite unusual in mathematics, most mathematicians finding it difficult to think seriously except in silence and solitude. Collaborative work, while quite common, most often consists in putting together results that each of the collaborators has managed to obtain in isolation, albeit with mutual profit from each other's ideas, enabling them to progress form new points of departure. </div> <p> In spite of that, about a year ago <a href="http://en.wikipedia.org/wiki/Timothy_Gowers">Tim Gowers</a> asked himself if it would be possible to solve important mathematical problems by collaborating openly over the internet. Not a collaboration among a few colleagues, but among everybody that had any insight about the problems. He shared this question with the mathematical community through a <a href="http://gowers.wordpress.com/2009/01/27/is-massively-collaborative-mathematics-possible/"> post in his blog</a>. That was the birth of the <a href="http://polymathprojects.org/">Polymath</a> project. </p> <p> The first problem that the Polymath group worked on is the attempt to obtain a simple proof for the <a href="http://en.wikipedia.org/wiki/Hales–Jewett_theorem"> Hales–Jewett theorem</a>. This theorem is a very important result from <a href="http://en.wikipedia.org/wiki/Ramsey_theory"> Ramsey theory</a>. In very gross terms Ramsey theory says that for many mathematical structures, there is no such thing as complete randomness. </p> <p> For example, take a group of six people: Alice, Bob, Charles, David, Erin and Fritz. The Ramsey theorem tells us that there are either 3 people that all know each other, or 3 people that are all strangers to each other. Even in something as random as a party, if there are at least 6 people then we can find a very special subgroup of 3 people. </p> <p> Here is the proof: Take Alice, imagine that she knows less than 3 people at the party. That is, she knows only Bob, or knows only Bob and Charles. Then we consider David, Erin and Fritz. If they all know each other, we have a group of 3 people that know each other. If not, two of them don't know each other, for example David doesn't know Erin. As a consequence Alice, David and Erin are all strangers to each other. If Alice knows 3 people or more, the proof is the same, say she knows Bob, Charles and David. If none of them knows each other then there we have our group of 3 strangers. But if two of them know each other, for example Bob knows Charles, the group Alice, Bob and Charles all know each other. </p> <p> So far the Polymath group has discussed 5 problems, which are all shown in the <a href="http://michaelnielsen.org/polymath1/index.php?title=Main_Page"wiki> Wiki</a> and they have started to publish some of the results. Here is link to a paper from D.H.J. Polymath on arXiv, <a href="http://arxiv.org/abs/0910.3926"> A new proof of the density Hales-Jewett theorem</a>. </p> <p> The following image is a part of a 3D Maldelbrot fractal, as described <a href="http://www.skytopia.com/project/fractal/mandelbulb.html"> here</a>. It has nothing to do with the rest of the post, but the Hales-Jewett theorem doesn't lend itself easily to fancy pictures. </p> <img src="/img/3d-fractal.jpg" alt="Maldelbulb 3D fractal" /> <p> And for comparison purposes this is a piece of romanesco broccoli. </p> <img src="/img/romanesco-broccoli.jpg" alt="Romanesco broccoli" /> <p> Of course, Mathematics is not the only scientific discipline in which people collaborate openly in interesting problems. Michael Nielsen has a great blog <a href="http://michaelnielsen.org/blog/doing-science-online/"> post</a> about doing science online. Probably the most important point is that the way that scientists work with each other is changing. And the change is driven mostly by new online collaboration tools. To finish the post I will quote Michael: </p> <div id="special-text"> Blogs, wikis, open notebooks, InnoCentive and the like aren’t the end of online innovation. They’re just the beginning. The coming years and decades will see far more powerful tools developed. We really will enormously scale up scientific conversation; we will scale up scientific collaboration; we will, in fact, change the entire architecture of expert attention, developing entirely new ways of navigating data, making connections and inferences from data, and making connections between people. </div> New Google Chart Tools http://www.javiertordable.com/new-google-chart-tools Wed, 17 Feb 2010 02:03:13 GMT http://www.javiertordable.com/new-google-chart-tools <p> Google recently released a new set of tools for graphics and interactive visualizations called <a href="http://code.google.com/apis/charttools/"> Google Chart Tools</a>. Google Chart Tools replaces the previous Charts API (for static images) and Visualization API (for dynamic graphics). And it combines both APIs within a single framework. Here is a <a href="http://googlecode.blogspot.com/2010/02/announcing-google-chart-tools.html"> link to the official announcement</a>. </p> <p> This is an example of the Charts API, a map with a couple of countries marked in a different color: </p> <img src="http://chart.apis.google.com/chart?cht=t&chtm=world&chs=440x220&chld=USES&chd=t:10,50&chco=FFFFFF,00FF00,005500&chf=bg,s,EAF7FE" alt="Example of Google Charts API, colored map"/> <p> This map was generated with the following link: </p> <pre> http://chart.apis.google.com/chart?cht=t&chtm=world&chs=440x220 &chld=USES&chd=t:10,50&chco=FFFFFF,00FF00,005500&chf=bg,s,EAF7FE </pre> <p> Let me go over each part in that link and explain what it means: </p> <ul> <li><strong>cht=t</strong> indicates that this is a graph of type map</li> <li><strong>chtm=world</strong> says that the map should include the whole world</li> <li><strong>chs=440x220</strong> is the size of the chart</li> <li><strong>chld=USES</strong> is the list of countries to display in a different color, US and ES</li> <li><strong>chd=t:10,50</strong> is the intensity of the color of each country. US=10, ES=50</li> <li><strong>chco=FFFFFF,00FF00,005500</strong> is the color gradient FFFFFF=white for the background, 00FF00 light green (US) and 005500 medium green (ES)</li> <li><strong>chf=bg,s,EAF7FE</strong> is the background color, light blue</li> </ul> <p> Here is another example, but this time of an interactive visualization: </p> <script type='text/javascript' src='http://www.google.com/jsapi'> </script> <script type='text/javascript'> google.load('visualization', '1', {'packages': ['geomap']}); google.setOnLoadCallback(drawMap); function drawMap() { var data = new google.visualization.DataTable(); data.addRows(6); data.addColumn('string', 'Country'); data.addColumn('number', 'Coolness'); data.setValue(0, 0, 'Spain'); data.setValue(0, 1, 100); data.setValue(1, 0, 'Brazil'); data.setValue(1, 1, 80); data.setValue(2, 0, 'United States'); data.setValue(2, 1, 70); data.setValue(3, 0, 'Canada'); data.setValue(3, 1, 40); data.setValue(4, 0, 'Russia'); data.setValue(4, 1, 20); data.setValue(5, 0, 'China'); data.setValue(5, 1, 10); var options = {}; options['dataMode'] = 'regions'; options['width'] = 440; options['height'] = 220; options['colors'] = [0xEAF7FE, 0xA5EF63, 0x50AA00, 0x267114] var container = document.getElementById('map_canvas'); var geomap = new google.visualization.GeoMap(container); geomap.draw(data, options); }; </script> <p> <div id='map_canvas' style="margin-left: 70px;"></div> </p> <p> In this case the map is dynamic. Moving the mouse over the different countries will display a message, which contains the value used to select the color of the country. Now the code is a little bit longer, about 30 lines of Javascript, so I am not going to include it, but there is a detailed explanation here: <a href="http://code.google.com/apis/visualization/documentation/"> Google Chart Tools, Introduction</a>. </p> <p> These tools are probably not as powerful as custom made visualizations, like the ones that I talked about in a previous post, <a href="http://www.javiertordable.com/blog/2009/12/03/interesting-visualizations-changes-over-time"> Interesting Visualizations: Changes Over Time</a>, but they are definitely easier to create and modify. </p> <p> To finish, I am just going to quote Robert Kosara and his blog on visualization <a href="http://eagereyes.org/">Eager Eyes</a>, "JavaScript for visualization is clearly the way to go. It's fast, versatile, works much better than Flash or Java, and is obviously way ahead of static images". You can check the complete post <a href="http://eagereyes.org/blog/2010/javascript-key-to-in-browser-visualization"> here</a>. Nounoublog updated http://www.javiertordable.com/nounoublog-updated Sat, 06 Feb 2010 00:00:00 GMT http://www.javiertordable.com/nounoublog-updated <p> Over the last few weeks this blog has changed dramatically. It looks pretty much the same as when it started but under the covers the code of the blogging platform, <a href="http://code.google.com/p/nounoublog/">Nounoublog</a> is very different. I am going to talk about three of the features that I have been working on lately: </p> <ul> <li>Archives</li> <li>RSS Feed</li> <li>Admin console</li> </ul> <p> And I will show a few snippets of the actual code that powers the blog. </p> <p> For those that visit the blog for the first time, Nououblog is a small blogging platform developed in <a href="http://code.google.com/appengine/">Google App Engine</a>. I started working on it basically for two reasons. First, I wanted to learn how to develop applications for Google App Engine. And second, because I wanted a simple but highly customizable platform, with free hosting and no ads. </p> <p> <img src="http://code.google.com/appengine/images/appengine_lowres.gif" alt="Google App Engine logo" /> </p> <h3>Archives</h3> <p> Now the blog has an archives section. It is the small set of links in the right side. It will let you view all the posts since the creation of the blog. </p> <p> For example, if you click in <a href="/blog/2009">2009</a>, it will show you all the posts from the previous year. In order to enable this I had to update the url structure of the blog. Now paths have the form: </p> <pre> http://www.javiertordable.com/blog/2010/01/30/the-eternal-night </pre> <p> With slashes separating the different parts of the url. And all the following are valid urls: </p> <pre> http://www.javiertordable.com/blog/2010/01/30/ http://www.javiertordable.com/blog/2010/01/ http://www.javiertordable.com/blog/2010/ </pre> <p> Each one will show respectively all the posts of the day, the month, and the year. Each one has its own handler. Here is for example the handler that returns all the posts in a year: </p> <pre> class BlogYear(webapp.RequestHandler): """Request handler for all blog posts in a given year. This handler answers all requests for /blog/YYYY and /blog/YYYY/. """ def get(self): # Get the year from the path. path = self.request.path[len('/' + config.BLOG_PREFIX + '/'):] (year, month, day, desired_url) = extract_url_parts(path) # Get the list of all posts of the year. posts = get_posts_in_date(year, month=None, day=None) # And return an archives page with the posts. s = pages.ArchivesPageGenerator() self.response.out.write(s.generate(posts, str(year))) </pre> <p> There are similar handlers for all the posts in a month and all the posts in a day. </p> <h3>RSS Feed</h3> <p> An <a href="http://en.wikipedia.org/wiki/RSS">RSS feed</a> is a specially formatted XML file, which includes data about the posts in a blog. It is updated automatically by the blog, so that when it changes, RSS subscribers know that there is new content. There are applications like <a href="http://www.google.com/reader/">Google Reader</a> that are very helpful to keep track of many RSS feeds and alerting when there is new stuff to read. </p> <p> In the <a href="http://code.google.com/p/nounoublog/"> Nounoublog blogging platform</a>, you can access the RSS feed by clicking in the <a href="/blog/rss.xml">RSS</a> link at the top of the page. In the browser you may see only a bunch of text, but if you add this link to your Google Reader subscriptions you will see a list of the most recent posts. </p> <p> Same as before the RSS feed is powered by its own handler, which is very simple: </p> <pre> class RssFeed(webapp.RequestHandler): """Handler for the RSS feed. This feed contains a list with all the blog posts, from last to first. This list is subject to the maximum item retrieval limit of the DB. """ def get(self): # Get the list of all posts. posts = get_all_posts() # Return the xml feed with the posts. template_values = {'posts': posts} self.response.out.write(template.render(template_path("rss_feed"), template_values)) </pre> <p> Where the template provides the XML structure of the feed, and inserts the data corresponding to the posts </p> <pre> &lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt; &lt;rss version=&quot;2.0&quot;&gt; &lt;channel&gt; &lt;title&gt;Javier Tordable Blog&lt;/title&gt; &lt;link&gt;http://www.javiertordable.com&lt;/link&gt; &lt;description&gt; Javier Tordable blog on Software, Mathematics and Technology &lt;/description&gt; &lt;generator&gt;Nounoublog&lt;/generator&gt; &lt;docs&gt;https://code.google.com/p/nounoublog/&lt;/docs&gt; {# Loop over all the blog posts. #} {% for post in posts %} &lt;item&gt; &lt;title&gt;{{ post.title }}&lt;/title&gt; &lt;link&gt;{{ post.absolute_url }}&lt;/link&gt; &lt;pubDate&gt;{{ post.rss_pub_date }}&lt;/pubDate&gt; &lt;guid&gt;{{ post.absolute_url }}&lt;/guid&gt; &lt;description&gt;{{ post.escaped_content }}&lt;/description&gt; &lt;/item&gt; {% endfor %} &lt;/channel&gt; &lt;/rss&gt; </pre> <p> Notice that in the Django template the post elements appear as attributes while in fact they are method calls. Also I use as GUID the url of the post, as it is intended to be a permanent link</a>. </p> <h3>Admin console</h3> <p> The last item that I have been working on is the administration console. This is still work in progress, but I expect that once I am done with it I will post more often. </p> <p> The admin console will have options to: </p> <ul> <li>Add posts</li> <li>Edit posts</li> <li>Add static pages</li> <li>Edit static pages</li> <li>Edit the CSS</li> <li>Edit redirects</li> </ul> <p> All these options seem very normal with the exception of the redirects. How does it work? For example, when going to: </p> <pre> http://www.javiertordable.com/blog/2009-12-01/my-first-blog-post </pre> <p> You are redirected to another url, which appears in the url bar. Notice how the dashes are now forward slash bars </p> <pre> http://www.javiertordable.com/blog/2009/12/01/my-first-blog-post </pre> <p> I added support for redirects because I changed the site several times (including the url structure), and I didn't want to serve 404 error pages for all old urls. </p> <p> Keep visiting the blog or subscribe to the <a href="/blog/rss.xml">RSS</a> feed for more news on Nouonublog! </p> The Eternal Night http://www.javiertordable.com/the-eternal-night Sat, 30 Jan 2010 00:00:00 GMT http://www.javiertordable.com/the-eternal-night <p> My brother David is a film director. He has been making short film for a few years, he has even won a few prizes. Most of his work is at <a href="http://www.tpmpictures.com">tpmpictures.com</a>. Today I just wanted to show his last piece of work, a science fiction short about the end of the world. The short is in Spanish but with English subtitles. </p> <object> <param name="movie" value="http://www.notodofilmfest.com/ediciones/09/es/swf/player.swf?corto=22321.flv&duracion=03:30"></param> <param name="wmode" value="transparent"></param> <embed src="http://www.notodofilmfest.com/ediciones/09/es/swf/player.swf?corto=22321.flv&duracion=03:30" type="application/x-shockwave-flash" wmode="transparent" width="500" height="370"></embed> </object> <p> There are a couple of things that are interesting in this short. First, the script is not wildly improbable. Check out this (humorous) list of the <a href="http://www.cracked.com/article_16583_the-5-scientific-experiments-most-likely-to-end-world.html"> 5 scientific experiments most likely to end the world</a>. And second, the special effects are pretty nice for a zero budget short. If you liked it, please go ahead and leave a comment at the <a href="http://www.notodofilmfest.com/ediciones/09/?lg=es&corto=22321"> Notodo film festival</a>. </p> TRANSCEND http://www.javiertordable.com/trascend-book-kurzweil-grossman Fri, 15 Jan 2010 00:00:00 GMT http://www.javiertordable.com/trascend-book-kurzweil-grossman <p> A couple of days ago I started reading <a href="http://www.transcendbook.com/">TRANSCEND</a>, the new book from Ray Kurzweil and Terry Grossman. The book starts from the principle that our knowledge of medicine and biology is increasing to a point where we can start to control effectively how fast our own bodies age. And even more important the amount of knowledge that we gather is increasing over time. If the trend continues we may reach a point where we can effectively reverse engineer our bodies in order to avoid aging. </p> <img src="/img/trascend-book-kurzweil-grossman.png" alt="TRANSCEND book by Ray Kurzweil and Terry Grossman" /> <p> Whether you believe that we will reach that point or not, the book is an interesting read. It is filled with healthy habits, complete diets and recipes, exercise programs and more. Even if you leave aside the supplements and the fancy biomedical technologies, there are plenty of actionable tips for inproving your quality of life. For example to check for food intolerances. There are millions of people out there that can't digest milk or wheat very well and are not even aware of it. </p> <p> Disclaimer: I didn't get paid to write this post. </p> MapReduce Integer Factorization in arXiv http://www.javiertordable.com/mapreduce-integer-factorization-in-arxiv Thu, 07 Jan 2010 00:00:00 GMT http://www.javiertordable.com/mapreduce-integer-factorization-in-arxiv <p> This Monday I published my article on <a href="http://arxiv.org/abs/1001.0421">MapReduce for integer factorization in arXiv</a>. The article is essentially the same that can be downloaded in the <a href="/research">research</a> section of this site. So if you have already checked it out, you won't find anything new. However I am very excited because it is my first addition to arXiv. </p> <img src="/img/mapreduce-integer-factorization-arxiv.png" alt="MapReduce for Integer Factorization in arXiv." /> <p> In case that you are not familiar with <a href="http://www.arxiv.org">arXiv</a>, it is one if the greatest scientific sites in the web. It has over half a million articles, especially in the fields of mathematics, physics and computer science, and many relevant papers are published in the arXiv months before they appear in any peer reviewed journal. </p> MapReduce Integer Factorization released! http://www.javiertordable.com/mapreduce-integer-factorization-released Tue, 29 Dec 2009 00:00:00 GMT http://www.javiertordable.com/mapreduce-integer-factorization-released <p> Recently I published the code of <a href="http://code.google.com/p/mapreduce-integer-factorization/"> MapReduce for Integer Factorization</a>. It is available under the Apache 2.0 License in Google Code. It includes everything necessary to run in <a href="http://hadoop.apache.org/">Apache Hadoop</a>, as well as the numerical libraries used. It has no dependencies apart from the last version of Hadoop. </p> <p> <img src="http://hadoop.apache.org/images/hadoop-logo.jpg" alt="Hadoop logo" /> </p> <p> This project is a proof of concept that shows how to use MapReduce, a framework for distributed computation to solve a purely numerical problem. The main conclussion is that it's possible to use MapReduce for problems that lie far ahead from its original area of application, for example number theory. Also in this case the difficulty involved in developing the MapReduce program is similar to the difficulty of creating a worksheet in a mathematical tool like Maple. But the performance of MapReduce is significantly higher. </p> <p> If you have some time, please download it from <a href="http://code.google.com/p/mapreduce-integer-factorization/">here</a>, and let me know how it works for you. </p> A small blogging platform in Google App Engine http://www.javiertordable.com/small-blog-platform-in-google-app-engine Thu, 17 Dec 2009 00:00:00 GMT http://www.javiertordable.com/small-blog-platform-in-google-app-engine <p> If you have never made a <a href="http://en.wikipedia.org/wiki/Web_application">web application</a> it may seem daunting. There are hundreds of alternative technologies and frameworks out there. And web apps development is quite different from client applications, which is what most developers are used to. </p> <p> Here is an example of a web application. Wikipedia! </p> <img src="/img/screenshot-wikipedia.png" alt="Screenshot of Wikipedia" /> <p> Most web applications share a few common elements: </p> <ul> <li>A persistence layer, for authored content or user created content</li> <li>A system to connect each user request with a part of the application</li> <li>A method to render and display that content to users</li> </ul> <p> Traditionally the persistence layer is a <a href="http://en.wikipedia.org/wiki/SQL_database">SQL database</a>, the requests are directed for example to <a href="http://en.wikipedia.org/wiki/Servlet">Java servlets</a> in an app server like <a href="http://tomcat.apache.org/">Tomcat</a>, and there is a more or less refined templating engine, in which the content is added to create the whole page returned to the user. </p> <p> Another alternative is <a href="http://code.google.com/appengine/">Google App Engine</a>. Google App Engine is a platform and a set of libraries to develop web applications based in Google's own infrastructure. It is available in Java and Python, but here I will concentrate on the Python version. </p> <p> The persistence layer of Google App Engine is the <a href="http://code.google.com/appengine/docs/python/datastore/overview.html"> Datastore</a>, a highly parallel but simple to use storage solution. The Datastore doesn't support queries as complex SQL does, however it can scale up to a level which is beyond what a normal database can do. And it can do so in a way that is trivial for the developer. </p> <p> Google App Engine uses <a href="http://en.wikipedia.org/wiki/YAML">yaml</a> and the webapp framework to answer user queries. One can set a configuration file which assigns certain url paths (via a regular expression) to instances of webapp.RequestHandler. </p> <pre> handlers: - url: /.* script: app.py </pre> <p> The instance can implement a get() method which generates the response returned to the user. </p> <pre> class App(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, World!') </pre> <p> Finally, in order to generate HTML, Google App Engine incorporates the templating engine from <a href="http://www.djangoproject.com/">Django</a>. A template is essentially a document with <em>variables</em> instead of content. When the application needs to answer a user request it can load the template and replace the <em>variables</em> with real content, for example information from the data storage. </p> <p> This is basically the way that this blog is made. It is a very simple Google App Engine application. It uses the Datastore for the blog posts, which are retrieved when it receives a request for the /blog url path. Then it replaces the blog post content into the blog template and returns that content. Here is a sample of code. It is not the actual code, but it gives a complete example: </p> <pre> class Blog(webapp.RequestHandler): def get(self): # Retrieve the posts from the database. query = 'SELECT * FROM Post WHERE public = True ORDER BY date DESC ' 'LIMIT %d ' % NUM_POSTS_IN_MAIN_PAGE posts = db.GqlQuery(query).fetch(NUM_POSTS_IN_MAIN_PAGE) # Render them into html. if len(posts) > 0: template_values = &#123;'posts': posts &#125; template_path = os.path.join(os.path.dirname(__file__), 'templates/blog') content = template.render(template_path, template_values) else: content = '' # And return a full page with the blog content. s = pages.FullPageGenerator() self.response.out.write(s.generate(content)) </pre> <p> To sum up, Google App Engine is a great option for developing web applications. Expecially if you will require it to scale seamlessly, or to integrate with Google services. Check out the <a href="http://code.google.com/appengine/docs/python/gettingstarted/introduction.html"> Google App Engine tutorial</a>. </p> <img src="http://code.google.com/appengine/images/appengine-noborder-120x30.gif" alt="Powered by Google App Engine" /> Interesting Visualizations: Changes Over Time http://www.javiertordable.com/interesting-visualizations-changes-over-time Thu, 03 Dec 2009 00:00:00 GMT http://www.javiertordable.com/interesting-visualizations-changes-over-time <p> Visualizations are simply ways of representing data. But if they are good, they can bring us deep insights, that go well beyond what is possible to understand by simply looking at the raw data. </p> <p> There are several categories of visualizations, for example: <ul> <li>Compare two entities based on a given set of metrics. An example of this is a benchmark between two competing companies or products</li> <li>Track the value of a given metric over time. A well known visualization of this type is a financial chart, with the value of an asset</li> <li>Compare the value of a single metric in different geographic locations. We have all seen maps in which the color of each region is based on the value of the metric</li> </ul> <p> Another very interesting set of visualizations are those that allow us to track a particular situation over time. Here are three examples: </p> <p> <a href="http://www.flickr.com/photos/ciaranhughes/4121291229/"> Tracking a change in ranking over time (by Ciaran Hughes)</a> </p> <p> <img src=/img/visualization-changes-ranking-over-time.png alt="Visualization for changes in ranking over time" /> </p> <p> <a href="http://www.ge.com/visualization/health_costs/index.html"> Tracking a change in distribution over time (from GE)</a>. The bottom slider changes the chart based on the age. Each section of the chart represent one kind of illness </p> <p> <img src=/img/visualization-changes-distribution-over-time-40.png alt="Visualization for changes in distribution over time" /> <img src=/img/visualization-changes-distribution-over-time-50.png alt="Visualization for changes in distribution over time" /> <img src=/img/visualization-changes-distribution-over-time-60.png alt="Visualization for changes in distribution over time" /> </p> <p> <a href="http://www.xach.com/moviecharts/2008.html"> Tracking changes in volume or magnitude over time (from xach.com)</a>. Each color block is a movie, and the size represents the box office in each week. </p> <img src=/img/visualization-changes-volume-over-time.png alt="Visualization for changes in volume or magnitude over time" /> <p> The first visualization doesn't attempt to indicate quantity because it displays an abstract concept such as brand appreciation. However in the third case the quantity is very concrete, the total box office in dollars. </p> <p> We could use also the first or third approach for the second data set. But if we went with the first kind of visualization most likely we would only remember the most important expense for each age. Also we would be constrained in the number of years to show. If we decided to go with a visualization of the third kind it would be hard to compare how the expenses change relatively to each other as all of them are likely to increase over time. </p> My first blog post http://www.javiertordable.com/my-first-blog-post Tue, 01 Dec 2009 00:00:00 GMT http://www.javiertordable.com/my-first-blog-post <p> Hello everybody. This is the first post in my new blog. This is not your common Wordpress or Blogger blog. It runs on a custom blogging platform made from scratch, on top of Google App Engine. Soon I will add a couple of posts about how it's done, and I will release the code of the platform. </p> <p> In the future I will use this blog to talk about stuff that interests me. For example: <ul> <li>Google App Engine, Django and other tools for rapid web application development</li> <li>Sage, an open source mathematics package</li> <li>Devi Prasad Shetty, and how he transformed medicine through mass production</li> <li>Interesting visualizations! As information is more and more available it is becoming increasingly important how to visualize and understand easily</li> </ul> </p> <p> The subscribe links don't work yet, so I am afraid you won't be able to read this blog in your favorite RSS reader. But I hope that I will see you again soon. Thanks for coming! </p>