This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils improt timezone | |
class Person(models.Model): | |
first_name = models.CharField(max_length=42) | |
last_name = models.CharField(max_length=42) | |
birth_date = models.DateField() | |
email = models.EmailField() | |
@property |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Person.objects.extra(select={'email_provider': "(COALESCE(substring(email from '@(.*)$'), ''))"}).order_by('email_provider') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Person.objects.extra(select={'age': "(EXTRACT(year FROM age(birth_date)) :: int)"})\ | |
.values('first_name', 'birth_date', 'age') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.utils improt timezone | |
class Person(models.Model): | |
first_name = models.CharField(max_length=42) | |
last_name = models.CharField(max_length=42) | |
birth_date = models.DateField() | |
@property | |
def age(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Person(models.Model): | |
first_name = models.CharField(max_length=42) | |
last_name = models.CharField(max_length=42) | |
birth_date = models.DateField() | |
email = models.EmailField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_hotel_result(hotel, i, hotels) { | |
// Crea un nuevo elemento para mostrar los datos del hotel | |
var $new_hotel_result = $hotels_results.find('.template.hotel_result') | |
.clone() | |
.removeClass('template'); | |
$new_hotel_result.find('.hotel_name').html(hotel.hotel_name); | |
function add_rate_option(rate) { | |
// Agrega el tipo de habitacion para el hotel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class TestAutogenerated(unittest.TestCase): | |
values = [('a', 1), ('be', 20), ('cal', 3), ('dado', 2)] | |
@staticmethod | |
def make_test(s, n): | |
def new_test(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import unittest | |
class Avoid_twice(): | |
tasks_filename = '/tmp/avoid_twice' | |
def __init__(self, task_name): | |
self.current_task = task_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# vim: set fileencoding=utf-8 : | |
""" | |
http://c2.com/cgi/wiki?FizzBuzzTest | |
The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job | |
candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment | |
is as follows:: | |
"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f(n): | |
l = [] | |
for i in xrange(n): | |
l.append(i ** 2) | |
return l |
NewerOlder