Skip to content

Instantly share code, notes, and snippets.

View brunobbbs's full-sized avatar

Bruno Barbosa brunobbbs

View GitHub Profile
#!/usr/bin/env python
# Copyright 2016 Pablo Santiago Blum de Aguiar <scorphus@gmail.com>. All rights
# reserved. Use of this source code is governed by the BSD 2-Clause License that
# can be found in the LICENSE file.
import argparse
import json
import os
import sys
@brunobbbs
brunobbbs / default.vcl
Last active July 5, 2020 08:45
Varnish example file for Plone installation
# VCL file optimized for plone.app.caching. See vcl(7) for details
vcl 4.0;
import directors;
import std;
probe healthcheck {
.interval = 10s;
.request = "HEAD / HTTP/1.1";

Keybase proof

I hereby claim:

  • I am brunobbbs on github.
  • I am brunobbbs (https://keybase.io/brunobbbs) on keybase.
  • I have a public key ASAczGGn_0ov45gVznTTiCy1LP80xrQjS2w9Fb44zmdleAo

To claim this, I am signing this object:

@brunobbbs
brunobbbs / tsuru-now-ubuntu-1404.sh
Last active January 9, 2017 22:01
Script to install tsuru on ubuntu 14.04
#!/bin/bash -ue
# Copyright 2016 tsuru-now authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
set -eu
release=""
codename=""
@brunobbbs
brunobbbs / forms.py
Created March 15, 2016 14:54
Login with email on Django
from django.contrib.auth import authenticate, login as l
class LoginForm(forms.Form):
email = forms.EmailField(
label=_("Email"),
widget=forms.TextInput(
attrs={'class': 'form-control', 'placeholder': 'Email'}
)
)
@brunobbbs
brunobbbs / secret_gen.py
Created January 18, 2016 01:52 — forked from henriquebastos/secret_gen.py
SECRET_KEY generator.
#!/usr/bin/env python
"""
Django SECRET_KEY generator.
"""
from django.utils.crypto import get_random_string
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
print(get_random_string(50, chars))
@brunobbbs
brunobbbs / asciifilesystemstorage.py
Created August 11, 2015 14:55
UnicodeDecodeError on file's upload
# -*- coding: utf-8 -*-
import unicodedata
from django.core.files.storage import FileSystemStorage
class ASCIIFileSystemStorage(FileSystemStorage):
"""
Convert unicode characters in name to ASCII characters.
@brunobbbs
brunobbbs / formatters.py
Last active July 5, 2020 08:45 — forked from igorsobreira/formatters.py
Django form field for Brazilian Real (R$)
from django.template.defaultfilters import floatformat
from django.contrib.humanize.templatetags.humanize import intcomma
from django.utils.encoding import force_unicode
def decimal_to_real(value, precision=2):
'''
Receives a Decimal instance and returns a string formatted as brazilian Real currency:
12,234.00. Without the "R$".
'''
value = floatformat(value, precision)
@brunobbbs
brunobbbs / README.md
Created July 21, 2015 13:32
Convert recursively from html files to pdf using wkhtmltopdf

Installation

wkhtmltopdf

Install Xvfd:

$ sudo apt-get install xvfb

Install Fonts:

# -*- coding: utf-8 -*-
# $Id: offline_bootstrap.py 73407 2011-08-21 20:35:04Z glenfant $
"""Offline buildout bootstraping for use on installation targets with no
Internet access.
See http://glenfant.wordpress.com/2011/07/31/bootstrap-and-install-a-buildout-based-project-without-internet-connection/
We assume that the directory that contains this file has the following
structure: