Skip to content

Instantly share code, notes, and snippets.

View brunobbbs's full-sized avatar

Bruno Barbosa brunobbbs

View GitHub Profile
Function Shortcut
previous tab ⌘ + left arrow
next tab ⌘ + right arrow
go to tab ⌘ + number
go to window ⌘ + Option + Number
go to split pane by direction ⌘ + Option + arrow
go to split pane by order of use ⌘ + ] , ⌘ + [
split window horizontally (same profile) ⌘ + D
split window vertically (same profile) ⌘ + d
@brunobbbs
brunobbbs / browserlayer.xml
Last active August 29, 2015 14:01
Registering a new viewlet on Plone 4.x
<?xml version="1.0"?>
<layers>
<layer
name="search_viewlet"
interface="meu.namespace.browser.viewlet.ISearch"
/>
</layers>
@brunobbbs
brunobbbs / configure.zcml
Last active August 29, 2015 14:02
Query portal_catalog filtering tags with plone.api in Plone 4
<browser:page
for="*"
name="getdocument_view"
class=".getdocument.GetDocument"
template="getdocument.pt"
allowed_interface=".getdocument.IGetDocument"
permission="zope.Public"
/>
class LoginRequiredMixin(object):
"""
View mixin which requires that the user is authenticated.
"""
@method_decorator(login_required)
def dispatch(self, request, *args, **kwargs):
return super(LoginRequiredMixin, self).dispatch(
self, request, *args, **kwargs)
# -*- 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:
@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 / setuphandlers.py
Last active December 18, 2015 14:38
Criação de conteúdo programaticamente no Plone a partir do arquivo setuphandlers.py
#-*- coding: utf-8 -*-
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.WorkflowCore import WorkflowException
def create_contents(context, contents):
for content in contents:
options = None
if 'options' in content.keys():
@brunobbbs
brunobbbs / numeros_primos.py
Last active December 20, 2015 10:08
Dejafio: O Objetivo deste Kata é escrever um código que encontre números primos utilizando o método do crivo de erastótenes.
#!/usr/bin/env
#-*- coding: utf-8 -*-
from sys import argv
from math import floor, sqrt
def gera_numeros_primos(lista, maior_num_checado):
for n in lista:
if n > maior_num_checado:
@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 / 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=""