Skip to content

Instantly share code, notes, and snippets.

def scale_size(size, scale=None):
'''
This function receives size form choices. i.e. 'XXS' or 10 or A or whatever,
and an optional scale. If not scale is passed, returns the value of size in any of the default scales.
If scale is passed, then it returns the value of size in such scale.
'''
#default scales for certain type of products.
default_sizes = {'XXXXXS':-6, 'XXXXS':-5, 'XXXS':-4, 'XXS':-3, 'XS':-2, 'S':-1, 'M':0, 'L':1, 'XL':2, 'XXL':3, 'XXXL':4, 'XXXXL':5, 'XXXXXS':6}
baby_sizes = {"NEWBORN":0, "0-3M":1, "3-6M":2, "6-12M":3, "6-18M":4, "6-12M":5, "6-18M":6, "12-18M":7, "18-24M":8, "18-36M":9 }
def known_sortable(size):
try:
return int(size)
return float(size)
except ValueError:
if size.isalpha()
return size
return False
@eedeep
eedeep / rewrite.py
Last active December 21, 2015 11:59
def toggle_new_relic_availability_monitoring(host_tag, action):
"""Given a valid action and a host tagname in env dictionary (shared among all tasks)
make an API call to newrelic to toggle availability monitoring on or off."""
valid_actions = ['enable', 'disable',]
if action.lower() not in valid_actions:
raise Exception('You must specify a valid action. Valid actions '\
'are: {valid_actions}'.format(valid_actions=valid_actions}))
try:
app_id = NEW_RELIC_APPS[host_tag]
except KeyError:
Hostname ec2-46-137-246-145.ap-southeast-1.compute.amazonaws.com
https://gist.github.com/6337805
Maybe the closest analogue to this is the PHP "debate":
(http://www.codinghorror.com/blog/2012/06/the-php-singularity.html)
(http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/)
Basically, MySQL works and you can definitely use it to build and run successful applications. Facebook uses it. But the point is that Postgres..... is better. That's the point. How and why? There are numerous articles out there for you to google up but [here's one] (http://www.youtube.com/watch?v=1PoFIohBSM4) that gives you a resaonable breakdown, by example.
So if you're currently a still running MySQL why not give Postgres a go, especially if you're starting a new project. Hell, why not use it even on existing projects which are using MySQL? Maybe because you have existing MySQL databases full of data and tables that you'd need to convert over to PostgreSQL? True this is a barrier, but it's by no means insurmountable. Which is what this post is about: easy conversion of your existing MySQL databases (schema and dat
alias efo
efo
runserver
127.0.0.1:8000
cd ~/projects
mkdir mysqldumped
cd mysqldumped
virtualenv --no-site-packages mysqldumped-env
source mysqldumped-env/bin/activate
#checkout {
header {
div {
@include clearfix;
}
.secure {
text-align: right;
padding-top: 24px;
img {
@include inline-block();
SHOP_CHECKOUT_STEP_DISPLAYED_FIELDS
https://gist.github.com/7112871