Skip to content

Instantly share code, notes, and snippets.

View silpol's full-sized avatar
🏠
Email is best comm tool.

Andriy Tymchenko silpol

🏠
Email is best comm tool.
View GitHub Profile
@rtt
rtt / gist:5029885
Last active January 15, 2022 19:50
python / jinja2 bytecode cache for Redis
from jinja2 import BytecodeCache
class RedisTemplateBytecodeCache(BytecodeCache):
'''Implements a Jinja2 bytecode cache on top of a pyredis.StrictRedis
connection
See: http://jinja.pocoo.org/docs/2.10/api/#bytecode-cache
'''
def __init__(self, redis_cnx, template_cache_key_prefix=None, ttl=86400):
@terotil
terotil / nda2csv.rb
Created January 10, 2013 21:03
Processor for Nordea machine readable bank statements (NDA format). Functionally minimal, just enough to outline a friendly interface and be able to export main transaction records to CSV, which is further processable to OFX using https://github.com/terotil/ofxify
require 'date'
module Nordea
module NDA
class Record
def self.parse(str)
self.new(str).normalized
end
def initialize(str)
@lorin
lorin / blog.json
Created July 30, 2012 14:28
Example Mezzanine blog fixtures
[
{
"pk": 1,
"model": "blog.blogpost",
"fields": {
"status": 2,
"expiry_date": null,
"allow_comments": true,
"description": "This is an example of a blog post.",
"title": "example blog post",
@evildmp
evildmp / gist:3094281
Last active June 30, 2023 10:55
Set up Django, nginx and uwsgi

This document has now been incorporated into the uWSGI documentation:

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

@woodb
woodb / default.conf
Created July 8, 2012 16:48
nginx configuration for uWSGI
server {
listen 80;
server_name blog;
server_name blog.example.com;
root /var/www/blog;
location /static/ {
alias /var/www/blog/static/;
expires 30d;
access_log off;
@woodb
woodb / blog.ini
Created July 8, 2012 16:47
uWSGI configuration for simple blog
[uwsgi]
# Variables
base = /var/www/blog
app = simple
# Generic Config
plugins = http,python
home = %(base)/venv
pythonpath = %(base)
socket = /var/www/run/%n.sock
module = %(app)
@woodb
woodb / uwsgi.conf
Created July 8, 2012 16:46
Configuration file for uWSGI
description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn
env UWSGI=/usr/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log
exec $UWSGI --master --emperor /etc/uwsgi/apps-enabled --die-on-term --uid nginx --gid nginx --logto $LOGTO
@woodb
woodb / setup_flask_and_friends.sh
Created July 8, 2012 16:43
Shell script to get setup with Flask, nginx and uWSGI on an Amazon EC2 Linux image
#!/bin/bash
#
# Shell script to automatically configure a new Flask, nginx and uWSGI based blog
# on an Amazon EC2 instance.
#
# See http://bit.ly/MeGwjD for more information!
#
# If you are forking this for your own custom configuration script, see the following other gists:
# https://gist.github.com/3071737
# https://gist.github.com/3071739
@jcinis
jcinis / gist:2866253
Created June 4, 2012 04:02
Generate a random username for Django
from random import choice
from string import ascii_lowercase, digits
from django.contrib.auth.models import User
def generate_random_username(length=16, chars=ascii_lowercase+digits, split=4, delimiter='-'):
username = ''.join([choice(chars) for i in xrange(length)])
if split:
username = delimiter.join([username[start:start+split] for start in range(0, len(username), split)])
@woodb
woodb / tree.md
Created May 10, 2012 00:25 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!