Skip to content

Instantly share code, notes, and snippets.

@pingwping
pingwping / nginx.conf
Last active May 11, 2017 09:50
resize image according to query string
#
# The image server
#
proxy_cache_path /tmp/nginx-images-cache/ levels=1:2 keys_zone=images:10m inactive=24h max_size=100m;
upstream image_8083 {
server 127.0.0.1:8083 max_fails=3 fail_timeout=2s;
}
@pingwping
pingwping / gist:92219a8a1e9d44e1dd8a
Last active March 6, 2023 18:35
Create and update embedded documents with MongoEngine
# REF: http://www.quora.com/How-do-I-create-and-update-embedded-documents-with-MongoEngine
class Comment(EmbeddedDocument):
content = StringField()
name = StringField(max_length=120)
class Post(Document):
title = StringField(max_length=120, required=True)
author = StringField(required=True)
@pingwping
pingwping / gist:b9c9180785c1bb0031c5
Created July 8, 2014 02:50
dict comprehension syntax

In Python 2.6 (or earlier), use the dict constructor:

d = dict((key, value) for (key, value) in sequence)

In Python 2.7+ or 3, you can just use the dict comprehension syntax directly:

d = {key: value for (key, value) in sequence}

@pingwping
pingwping / go-to-top
Created March 26, 2014 07:37
display go-to-top button automatically
<style TYPE="text/css">
<!--
#go-to-top {
display: none;
position: fixed;
right: 60px;
bottom: 100px;
padding: 18px;
color: #666;