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 random import choice | |
import string | |
def genPasswd(length=8): | |
p = ''.join([choice(string.letters+string.digits) for i in range(length)]) | |
return p |
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.db import models | |
from django.contrib import admin | |
class Pessoa(models.Model): | |
nome = models.CharField(max_length=75) | |
idade = models.IntegerField() | |
def __unicode__(self): | |
return self.nome |
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 ListView | |
from sgf.utils.decorators import page, permission_required_sgf | |
from sgf.administrativo.models import ComiteRegional | |
from sgf.administrativo.forms import FormComiteRegionalBusca | |
...... | |
class SearchListView(ListView): |
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
$(document).ready(function(){ | |
$('button').click(function(){ | |
var data = JSON.stringify({ | |
"content": "A new post.", | |
"is_active": true, | |
"title": "New Title", | |
"slug": "new-title", | |
"user": "/api/v1/users/1/" | |
}); |
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
# API JSON | |
from django.http import HttpResponse | |
from django.utils import simplejson | |
from django.views.generic.detail import BaseDetailView | |
from django.views.generic.list import BaseListView | |
from django.db.models.query import QuerySet | |
class JSONResponseMixin(object): | |
def render_to_response(self, context): | |
return self.get_json_response(self.convert_context_to_json(context)) |
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 tastypie.api import Api | |
from basic.api.resources import NoteResource, UserResource | |
api = Api(api_name='v1') | |
api.register(NoteResource(), canonical=True) | |
api.register(UserResource(), canonical=True) |
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 auto_activate { | |
SEARCHPATH=`pwd` | |
function activate_env { | |
# ZSH outputs errors for the ls * command if you don't disable the nomatch output | |
unsetopt nomatch 2>/dev/null | |
ls $SEARCHPATH/*/bin/activate > /dev/null 2> /dev/null | |
if [ "$?" = '0' ]; then | |
deactivate > /dev/null 2> /dev/null |
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
$.preLoadImages = function() { | |
var args_len = arguments.length; | |
for (var i=0; i < args_len; i++) { | |
var cacheImage = document.createElement('img'); | |
cacheImage.src = arguments[i]; | |
} | |
} | |
$.preLoadImages('/img/img1.png', '/img/img2.png') |
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
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
import urllib | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
import pickle | |
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
# coding: utf-8 | |
""" | |
Código inicial usado na Lista de Exercícios 1 do curso | |
"Objetos Pythonicos" de Luciano Ramalho, Oficinas Turing. | |
""" | |
from collections import Counter | |
class Contador(object): | |
def __init__(self): |
OlderNewer