Skip to content

Instantly share code, notes, and snippets.

View pije76's full-sized avatar

panjianom pije76

View GitHub Profile
from classytags.arguments import Argument, MultiValueArgument
from classytags.values import StringValue
from cms.templatetags.cms_tags import Placeholder, PlaceholderOptions
from cms.models.placeholdermodel import Placeholder as PlaceholderModel
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
{% load i18n future static fb_tags mezzanine_tags %}
{% load sorl_thumbnail %}
{% if query.pop %}
<style>
{% if query.pop == '4' %}
#media-library-popup #header, #media-library-popup .object-tools {display: none;}
#media-library-popup h1 {margin: -60px 0 15px 0;}
{% else %}
h1 {margin:-30px 0 15px 0;}
@pije76
pije76 / gist:6773380
Last active December 24, 2015 08:49 — forked from emilepetrone/gist:3147937
Thumbnail at admin page for mezzanine on AWS
from cStringIO import StringIO
@register.simple_tag
def thumbnail(image_url, width, height, quality=95):
"""
Given the URL to an image, resizes the image using the given width and
height on the first time it is requested, and returns the URL to the new
resized image. if width or height are zero then original ratio is
maintained.
"""
if not image_url:
@pije76
pije76 / models.py
Created August 24, 2013 18:54 — forked from mbrochh/models.py
Attach the django-shop cart to a User that started shopping anonymously
# add this soewhere where it gets loaded very early, i.e.
# your shop's models.py
from django.contrib.auth import login
from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
from registration.signals import user_activated
from shop.models.defaults.cart import Cart
@pije76
pije76 / gist:5930876
Last active December 19, 2015 09:09 — forked from agiliq/gist:278962
Django & Wordpress Integration
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.
from django.db import models
#!/bin/bash
mkdir prancing_heroku
cd prancing_heroku
django-admin.py startproject prancing_heroku
echo "Django==1.3" > requirements.txt
echo "psycopg2" >> requirements.txt
echo "web: prancing_heroku/run_heroku_run.sh" > Procfile
namespace :heroku do
desc "Generate the Heroku gems manifest from gem dependencies"
task :gems do
RAILS_ENV='production'
Rake::Task[:environment].invoke
list = Rails.configuration.gems.collect do |g|
command, *options = g.send(:install_command)
options.join(" ") + "\n"
end

Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git curl
  • Copy/paste from the command line:

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

{% load core_utils %}
<ul id="tags" class="nav nav-tabs nav-stacked">
{% for tag in tags %}
{% if tag_full_list|list_count:tag %}
<li>
<a href="{% url "post:posts-tagged-related" tag.slug %}">
{{ tag.name }} <span class="label label-info">{{ tag_full_list|list_count:tag }}</span>
</a>
</li>