This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from re import compile | |
from django.conf import settings | |
from django.contrib.auth import REDIRECT_FIELD_NAME | |
from django.contrib.auth.views import redirect_to_login | |
if hasattr(settings, "LOGIN_REQUIRED_URLS"): | |
URLS = [compile(expr) for expr in settings.LOGIN_REQUIRED_URLS] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ProgressItem = Backbone.Model.extend({ | |
defaults: { | |
max: 100, | |
value: 0 | |
}, | |
getValueRatio: function () { | |
return this.get('value') * 100 / this.get('max'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "precise64" | |
config.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
config.vm.network :forwarded_port, guest: 80, host: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.views.generic import TemplateView | |
if settings.DEBUG: | |
# enable local preview of error pages | |
urlpatterns += patterns('', | |
(r'^403/$', TemplateView.as_view(template_name="403.html")), | |
(r'^404/$', TemplateView.as_view(template_name="404.html")), | |
(r'^500/$', TemplateView.as_view(template_name="500.html")), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// # Globbing | |
// for performance reasons we're only matching one level down: | |
// 'test/spec/{,*/}*.js' | |
// use this if you want to recursively match all subfolders: | |
// 'test/spec/**/*.js' | |
// OBS: | |
// Replace the string with informations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyModelForm(ModelForm): | |
class Meta: | |
model = MyModel | |
fields = ('field2', 'field3', 'field4', 'field5') | |
def clean(self): | |
""" | |
Clean MyModel | |
""" | |
# Get the cleaned data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simples fabfile para aplicar o patch para o bug CVE-2014-6271 | |
__author__ = 'juliomelo' | |
from fabric.api import * | |
from fabric.decorators import hosts | |
import re | |
env.use_ssh_config=True | |
@hosts('host_foo', 'host_bar') | |
@task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The context of this program is a course of an hour to journalists who know nothing about programming in a lab with Python 3 only. | |
import urllib.request | |
url = 'http://www.portaltransparencia.gov.br/copa2014/api/rest/empreendimento' | |
resp = urllib.request.urlopen(url).read().decode('utf-8') | |
total = 0 | |
j = 0 | |
and1 = '<andamento>' | |
and2 = '</andamento>' | |
abre = '<valorTotalPrevisto>' | |
fecha = '</valorTotalPrevisto>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = { | |
init: function(){ | |
// app initialization and startup goes here | |
} | |
} | |
App.init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$("#meu-form").submit(function(e) { | |
e.preventDefault(); | |
var data = $(this).serialize(); | |
$.ajax( { | |
url: "minha-url", | |
type: "post", | |
data: data, | |
dataType: "json", | |
success: function(json) { |
OlderNewer