Skip to content

Instantly share code, notes, and snippets.

View henriquebastos's full-sized avatar
😏

Henrique Bastos henriquebastos

😏
View GitHub Profile
@henriquebastos
henriquebastos / redmine-issue-inspire_on.patch
Created March 26, 2009 03:31
Patch for Redmine to persist form state when adding multiple issues
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index cba8e59..af53ec2 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -139,6 +139,7 @@ class IssuesController < ApplicationController
if request.get? || request.xhr?
@issue.start_date ||= Date.today
+ @issue.inspire_on(params[:inspire_on]) if params[:inspire_on]
else
@henriquebastos
henriquebastos / graphviz_svg.py
Created November 30, 2009 03:01
Modified Graphviz extension for Sphinx with SVG format support
# -*- coding: utf-8 -*-
"""
sphinx.ext.graphviz
~~~~~~~~~~~~~~~~~~~
Allow graphviz-formatted graphs to be included in Sphinx-generated
documents inline.
:copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
@henriquebastos
henriquebastos / route.py
Created November 2, 2010 21:11
Route is a better urls function.
# -*- encoding: utf-8 -*-
# Usage:
# urlpatterns += patterns('',
# route(r'^$', GET='getview', POST='postview', name='viewname'),
# )
#
from django.http import Http404
from django.core.urlresolvers import RegexURLPattern, get_callable
def discover_view(view, prefix=''):
@henriquebastos
henriquebastos / formrange.py
Created December 27, 2011 16:59
Snippet para demonstrar validação de um form com range e valor entre eles.
from django import forms
from django.test import RequestFactory
class RangeForm(forms.Form):
min = forms.IntegerField()
max = forms.IntegerField()
valor = forms.IntegerField()
def clean(self):
@henriquebastos
henriquebastos / slideshare.py
Created June 17, 2012 11:29
Templatetag for rendering slideshare embeds
from django import template
from django.template import Context, Template, Node
TEMPLATE = """
<object id="__sse{{ id }}" width="425" height="355">
<param name="movie"
value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc={{ doc }}" />
<param name="allowFullScreen" value="true"/>
<param name="allowScriptAccess" value="always"/>
@henriquebastos
henriquebastos / style.css
Created September 22, 2012 16:36
CSS do Eventex
/*
CSS
*/
html {
background-color: #E8DDCB;
}
body {
margin: 0;
@henriquebastos
henriquebastos / index.html
Last active October 10, 2015 23:28
HTML da Landingpage
{% load static %}
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="EventeX" />
<meta http-equiv='content-Language' content='en-US' />
<link type="image/x-icon" href="{% static 'favicon.ico' %}" rel="shortcut icon" />
<title>EventeX</title>
@henriquebastos
henriquebastos / aggregate_if.py
Created December 24, 2012 23:05
Simple implementation of Conditional Aggregates in Django
# coding: utf-8
'''
Implements conditional aggregates.
This code was based on the work of others found on the internet:
1. http://web.archive.org/web/20101115170804/http://www.voteruniverse.com/Members/jlantz/blog/conditional-aggregates-in-django
2. https://code.djangoproject.com/ticket/11305
3. https://groups.google.com/forum/?fromgroups=#!topic/django-users/cjzloTUwmS0
4. https://groups.google.com/forum/?fromgroups=#!topic/django-users/vVprMpsAnPo
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={{ encoding }}"/>
{{ metatags }}
{%- block htmltitle %}