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
import csv | |
import MySQLdb | |
mydb = MySQLdb.connect( | |
host='', | |
user='root', | |
passwd='', | |
db='') | |
cursor = mydb.cursor() |
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
servers = { | |
'frontend': { | |
'address': '33.33.33.33', | |
'user': 'vagrant', | |
'roles': [ | |
FrontEnd | |
], | |
'options': { | |
'mysql-db-password': | |
AskFor('mysql-db-password', |
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
Vagrant::Config.run do |config| | |
config.vm.define "frontend" do |inner_config| | |
inner_config.vm.box = "base" | |
inner_config.vm.forward_port(80, 8080) | |
inner_config.vm.network :hostonly,"33.33.33.33" | |
end | |
config.vm.define "backend" do |inner_config| | |
inner_config.vm.box = "base" |
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 | |
import webbrowser, urllib, json, sys | |
def login(): | |
#Dicionário de parâmetros usados para obter code. | |
args = { | |
'client_id': '318829251513892', | |
'redirect_uri': 'http://localhost:5000/', | |
'scope': 'friends_likes,user_likes,manage_pages' |
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 | |
'''Entre com o nome de um usuário Twitter para ver seus seguidores e | |
quantos seguidores cada um deles têm''' | |
import json, urllib2, sys | |
#Requisição para pegar a lista de followers de um usuário. | |
resp = urllib2.urlopen('http://api.twitter.com/1/followers/ids.json?screen_name=%s' % sys.argv[1]) | |
#Carrega a lista de followers para um dicionário. |
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 | |
import urllib2, json, sys | |
#Requisição para pegar quem deu retweet de um post. O sys.argv[1] é o id do tweet. | |
resp = urllib2.urlopen('http://api.twitter.com/1/statuses/%s/retweeted_by.json' % sys.argv[1]) | |
#Carrega a resposta para um dicionário. | |
retweeters = json.loads(resp.read()) | |
#Percorre a lista de quem deu retweet e mostra as informações de cada pessoa. |
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 -*- | |
import os | |
from fabric.api import local, env, abort, cd, sudo | |
env.hosts = ['IP OU DOMINIO PARA O SERVIDOR'] | |
env.user = 'ubuntu' # UBUNTU É O USUÁRIO PADRÃO DOS NOSSOS SERVIDORES. | |
HOME = os.environ.get("HOME") |
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
#encoding: utf-8 | |
import csv | |
import time | |
from datetime import datetime, timedelta | |
import tweepy | |
def login(): | |
auth = tweepy.BasicAuthHandler('user', 'pass') | |
return tweepy.API(auth) |
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
Dados de entrada: | |
input = { | |
"wishlist": [ | |
{ | |
"sku": 123, | |
"name": "Kindle" | |
},{ | |
"sku": 147, | |
"name": "iPhone" | |
},{ |
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 -*- | |
from django.forms import ModelForm | |
from django import forms | |
from django.contrib.auth.models import Group, User | |
class GroupAdminForm(ModelForm): | |
class Meta: | |
model = Group | |
group_users = forms.ModelMultipleChoiceField(label=u'Usuários deste Grupo', queryset=User.objects.all()) |