Skip to content

Instantly share code, notes, and snippets.

View luzfcb's full-sized avatar

Fábio C. Barrionuevo da Luz luzfcb

View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import re
# dado um título e lista de listas no formato
# ('<variável>', '<tipo>', '<descricao>', '<fórmula>')
# pede-se qual variável calcular, pede os valores e dá o resultado
# qualquer valor vazio saida da função
from django.views.generic.base import View, TemplateResponseMixin
from django.views.generic.edit import FormMixin, ProcessFormView
class MultipleFormsMixin(FormMixin):
"""
A mixin that provides a way to show and handle several forms in a
request.
"""
form_classes = {} # set the form classes as a mapping
"""
Simple web server that listens for Github webhooks to implement push-to-deploy
with Pelican static sites
Settings are loaded from a json file except for SECRET which should be an
environment variable
Example `deployer.json`
{

Kerberos setup

This guide explains how to set up Kerberos authentication for an HTTP service on a corporate network based on Active Directory.

All instructions will use the following placeholders:

  • COMPANYAD.COM: Windows Domain
  • COMPANYAD: NETBIOS Domain
  • companyad.com: network domain
  • Update HISTORY.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test

Kerberos setup

This guide explains how to set up Kerberos authentication for:

  • SSH access to a server,
  • HTTP access to a service.

It assumes you're running Active Directory and Debian servers.

#!/usr/bin/env python
#-*- coding: utf-8 -*-
class User(object): # Definição da classe User que herda de object(ler sobre new-stye class)
# seq é um atributo da classe para contar quantas instâncias de User já foram salvas(chamaram o método save)
seq = 0
# objects é a lista de instâncias de User que foram salvas(que chamaram o método save).
# O atributo poderia ter qualquer nome.
objects = []
# Orignal version taken from http://www.djangosnippets.org/snippets/186/
# Original author: udfalkso
# Modified by: Shwagroo Team and Gun.io
import sys
import os
import re
import hotshot, hotshot.stats
import tempfile
import StringIO
@login_required
def reclame(request):
if request.method == 'POST':
form = FormReclame(request.POST)
if form.is_valid():
reclamacao = form.save(commit=False)
reclamacao.usuario = request.user
reclamacao.save()
subject = 'Uma nova reclamção foi adicionada.'
// This function gets cookie with a given name
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));