Skip to content

Instantly share code, notes, and snippets.

View dahlia's full-sized avatar

Hong Minhee (洪 民憙) dahlia

View GitHub Profile
from wand.image import Image
with Image(file=file) as img:
x = 275
y = 275
img.resize(x, y)
with open('path/filename_already_exists.png', 'wb') as f:
img.save(file=f)
@dahlia
dahlia / gist:4407166
Created December 29, 2012 14:15
Jinja2 htmlfill ext
# htmlfill
with app.test_request_context('/'):
html = render_template_string('''
{%- autoescape true -%}
{%- form 'user.signup' with {'a': 123, 'b': 456} -%}
<input type="number" name="a"> {{- '' -}}
<input type="number" name="b" value="2"> {{- '' -}}
<input type="number" name="c" value="3">
{%- endform -%}
{%- endautoescape -%}
@dahlia
dahlia / gist:4567277
Created January 18, 2013 18:58
My SCSS gets more imperative.
div {
@each $_vp in '', -moz-, -webkit-, -ms-, -o- {
#{$_vp}transition-property: box-shadow;
#{$_vp}transition-duration: 2s;
#{$_vp}transition-timing-function: ease-out;
}
}
@dahlia
dahlia / requirements.txt
Created February 13, 2013 13:33
Playing with Heroku Postgres
heroku == 0.1.2
@dahlia
dahlia / .gitignore
Last active December 13, 2015 20:29
This is a simple proxy web app that makes POST requests by requesting GET payloads to this.
.*.swp
*.pyc
@dahlia
dahlia / sqla_intlist.py
Last active December 8, 2017 09:58
This module provides integer list in portable way for SQLAlchemy. In this context “portable way” means that you can use it with any backends (dialects) SQLAlchemy supports. It implements special optimizations using `integer[]` type and `@>` operator in PostgreSQL — so you can index the column of this type using GIN as well.
""":mod:`sqla_intlist` --- Portable integer list type for SQLAlchemy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See the docstring of :class:`IntegerList` type.
"""
import collections
import io
from sqlalchemy.dialects.postgresql import ARRAY
@dahlia
dahlia / gist:5081821
Created March 4, 2013 12:00
Wand experiments with PixelGet{Red,Green,Blue,Alpha}Quantum() functions
import ctypes
from wand.api import library
from wand.color import Color
library.PixelGetRedQuantum.argtypes = [ctypes.c_void_p]
library.PixelGetRedQuantum.restype = ctypes.c_size_t
library.PixelGetGreenQuantum.argtypes = [ctypes.c_void_p]
@dahlia
dahlia / form.py
Last active December 15, 2015 23:59
Jinja2 extension for Flask + FormEncode
from flask import current_app, request, url_for
from formencode.htmlfill import render
from formencode.api import Invalid
from jinja2 import Markup, Undefined
from jinja2.exceptions import TemplateSyntaxError
from jinja2.ext import Extension
from jinja2.nodes import (Const, Filter, FilterBlock, Keyword, Output,
TemplateData)
from werkzeug.utils import escape
@dahlia
dahlia / MAIL
Last active December 17, 2015 10:09
Response to Nicolas de Bari Embriz Garcia Rojas <[email protected]>
MIME-Version: 1.0
Date: Thu, 16 May 2013 14:48:35 +0100
From: Nicolas de Bari Embriz Garcia Rojas <[email protected]>
List-Archive: <http://librelist.com/archives/wand/>
List-Id: [email protected]
List-Post: <mailto:[email protected]>
Reply-To: [email protected]
Sender: [email protected]
Subject: [wand] how to crop defining -gravity and -extent etc
To: [email protected]
@dahlia
dahlia / .gitignore
Last active December 17, 2015 23:09
Google Reader to Lookbook.nu (subscriptions → fans, stars → hypes)
.*.swp
*.pyc
credentials.ini