Skip to content

Instantly share code, notes, and snippets.

@vankovsky
vankovsky / gist:57115decf66defe517fc
Created January 24, 2016 07:47
Clean docker imaga
# Remove images:
docker rmi $(docker images -q)
# Remove containers:
docker rm $(docker ps -a -q)
SELECT
p.sku AS sku,
p.price_amount::int AS price_amount,
p.price_iso_code AS price_iso_code,
p.discount as discount,
true AS is_from_db,
p.is_new AS is_new,
CASE WHEN old_price_amount IS NULL THEN False ELSE True END AS is_sale,
p.new_from AS new_from,
p.gender AS gender,

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@vankovsky
vankovsky / Multiple Context Managers
Last active August 29, 2015 13:56
How to use multiple context managers
from contextlib import contextmanager
import sys
@contextmanager
def aggregate(handlers):
for handler in handlers:
handler.__enter__()
err = None
exc_info = (None, None, None)
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from django.contrib.sites.models import Site
from django.db import transaction
from cms.models import Page
class Command(BaseCommand):