Saturday, December 3, 2011

Bobby McFerrin hacked my brain

Today this post is about Bobby McFerrin, a vocalist specialized in singing a capella (creating polyphonic effects) and also an orchestra conductor. Some of you might know him from the song "Don't worry be happy" but there's more, much more!

First video "Bobby McFerrin hacks your brain with music". It's a revealing video about how neuroscience works in terms of music and the pentatonic scale.



If that wasn't enough to convice you, he also sings Bach pieces..



Or two tones at the same time..



And improvises spectacular songs a capella

Saturday, September 3, 2011

Life!

While watching the Life BBC Documentary (which I couldn't recommend more) I got totally awesome-ed by the hunting technique of the Bottlenose Dolphins. So, here's the video but please, please PLEASE if you have the opportunity, watch the whole series!






Other dolphin strategies are "fish whacking" which consists on hitting a fish with its fluke and knocking it out of the water and "Strand feeding" where dolphins kick the fish out of the water and into the shore where they retrieve them, which can be easily understood in the video below:





Tuesday, August 30, 2011

Resum de vacances a La Isla Bonita

Recent tornats del festival de senderisme de la palma i després de fer un parell d'excursions més, la nostra estada a La Palma queda plasmada totalment en el següent vídeo:



Com al vídeo, nosaltres també vam sortir del Refugio del Pilar i vam seguir per La Ruta de Los Volcanes fent parada, obviament, al "Bar Parada", excursió que penjaré amb fotos i més info més endavant, però que va resultar ser espectacular. Quina gran illa La Palma i quines ganes de tornar al festival l'any que ve!

Wednesday, August 17, 2011

Easy solution to Satchmo Discounts malfunction.

Problem:
When applying a discount only to a number of products in the store, the message advertising the discount is shown in all the products (not only the ones which the discount is applicable to).

Solution: (as seen here)

1. Go to the product view: product/views/__init__.py
2. After context = RequestContext(request,extra_context) add this line:
context['sale']=best_discount

So your function to get the template context from the Product is like:

# Get the template context from the Product.
extra_context = product.add_template_context(context=extra_context,
request=request, selected_options=selected_options,
default_view_tax=default_view_tax)

template = find_product_template(product, producttypes=subtype_names)
context = RequestContext(request, extra_context)

context['sale']=best_discount #line added

3. Done.

Saturday, August 13, 2011

Animals have a shut down/freeze button

After minimal research, I arrived to the concussion conclusion that most of the animals have a shut down (or freeze) button. And here, some examples:

A cat..


A dog..


And finally, a sloth! Okay, I know there is a much more serious video proof of this, but this video made me laugh ;)



Tuesday, May 3, 2011

Solution for @googlenexus puzzle number 5 in Python, in less than a tweet.

b='tcag'
s=''
for c in i.lower():
if c in b:s+=c
if len(s)>2:print dict(zip([x+y for x in b for y in b],'***WL*HRIT*SVAE'))[s[:2]];s=''


That's it! Now the explanation:



It's assumed that the variable i contains the INPUT of the puzzle: a string with all the cities, with one modification: the letter 'ã' of São Paulo has been replaced by 'a'.
- But why? Isn't that cheating? The character 'ã' is not the character 'a'!
- Well, I justify that change in that the letter 'ã' does not represent Adenine, so if we take this solution down for that, the problem has to go down too... :o)


First: the chunk in red is a python dictionary mapping the two first letters of a codon (three bases) with its one code letter (see the second table here: http://www.hgvs.org/mutnomen/codon.html ).


>>> b='tcag' ; dict(zip([x+y for x in b for y in b],'***WL*HRIT*SVAE'))
{'aa': '*', 'ac': 'T', 'gt': 'V', 'ag': 'S', 'cc': '*', 'tt': '*', 'cg': 'R', 'gc': 'A', 'at': 'I', 'ga': 'E', 'tg': 'W', 'ca': 'H', 'ta': '*', 'tc': '*', 'ct': 'L'}

From that can be seen that every relevant couple of characters has a one code letter associated. Irrelevant couples have asterisks. For example (in green), when I find a codon of this shape gtX, being X any of {A, T, C, G},  I know that the one code letter will be 'V'. A while ago I mapped all three letters of a codon, but I realized that I didn't need that much precision, since with only the first two letters I could get a pretty decent mapping, not biunivocal but with only one ambiguity (that's nothing for an average human like me). The third letter was almos superflous. Almost. 

Now line by line:



Line 1: These are the bases.
Line 3: I iterate over the lowered input string...
Line 4: ...looking for interesting characters ('t', 'c', 'a', 'g') and storing them in s
Line 5: when I've got three interesting characters, I take the first two (ignoring the third one), look them up in the dictionary and print the associated one code letter.


Running it this happens:


$ python nexus.py 
T
R
A
V
E
L
T
H
E
E
A
R
T
H
W
I
T
H
S
T
S       <-- This is the ugly expected consequence of the untreated ambiguity.
E
E
T
V
I
E
W



The challenge was solving the puzzle in less than a tweet. Finally I got it in 137 characters (tabs, \n and spaces included!).


EDIT: Thanks to this guy http://www.petercollingridge.co.uk/python-bioinformatics-tools/codon-table . I took from him the idea for a short mapping!