Skip to content

Instantly share code, notes, and snippets.

@macndesign
macndesign / gist:3146212
Created July 19, 2012 19:29
using Class Based Generic ListView to seach forms and List
....
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):
@macndesign
macndesign / .zshrc.sh
Created August 9, 2012 17:43 — forked from lucasvo/.zshrc.sh
Automatically activate your python virtualenvironment
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
@macndesign
macndesign / tw_trends.py
Created September 8, 2012 22:53 — forked from fabiocerqueira/tw_trends.py
Get and save Twitter Trends
@macndesign
macndesign / time_dict_value_max.py
Created December 4, 2012 11:47 — forked from perone/time_dict_value_max.py
Python max dict value
import timeit
t = timeit.Timer("v=sorted(d.items(), key=lambda x: x[1])[-1]",
"d = {'a': 1000, 'b': 3000, 'c':100}")
print t.timeit()
# 1.648s
t = timeit.Timer("v=max(d.iteritems(), key = operator.itemgetter(1))[0]",
"import operator; d = {'a': 1000, 'b': 3000, 'c':100}")
print t.timeit()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, re
import itertools
from functools import wraps
from pyquery import PyQuery as pq
class scrape:
>>> from posts.models import User, Post, Amigos
>>> # Cria joao
>>> joao = User(username="joao", first_name="João", email="[email protected]")
>>> joao.save()
>>> # Cria jose
>>> jose = User(username="jose", first_name="José", email="[email protected]")
>>> jose.save()
from django import http
try:
from django.conf import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
XS_SHARING_ALLOWED_METHODS = settings.XS_SHARING_ALLOWED_METHODS
XS_SHARING_ALLOWED_HEADERS = settings.XS_SHARING_ALLOWED_HEADERS
XS_SHARING_ALLOWED_CREDENTIALS = settings.XS_SHARING_ALLOWED_CREDENTIALS
except AttributeError:
XS_SHARING_ALLOWED_ORIGINS = '*'
@macndesign
macndesign / app.js
Created January 4, 2014 03:12 — forked from auser/app.js
angular.module('myApp',
['ngRoute', 'myApp.services', 'myApp.directives']
)
.config(function(AWSServiceProvider) {
AWSServiceProvider.setArn('arn:aws:iam::<ACCOUNT_ID>:role/google-web-role');
})
.config(function(StripeServiceProvider) {
StripeServiceProvider.setPublishableKey('pk_test_YOURKEY');
})
.config(function($routeProvider) {
# -*- coding: utf-8 -*-
#--------------------------------------------------------------
# myposconfig.py - *Configuração após instalar Ubuntu 13.04 >
# Autor: Jhonathan Paulo Banczek
# 09-03-2014 - jhoonb.com
# Python 2.7 >
# - *configurações pessoais
#--------------------------------------------------------------
Feature: Log in django admin
Scenario: Log in django admin with correct user and password
Given I have the user admin and password admin
When I fill the form and submit
Then I see the text "Encerrar sessão"
Scenario: Log in django admin with incorrect user and password
Given I have the user invald_admin and password invalid_password
When I fill the form and submit