Skip to content

Instantly share code, notes, and snippets.

View vinigracindo's full-sized avatar
🏠
Working from home

Vinnicyus Gracindo vinigracindo

🏠
Working from home
View GitHub Profile
@vinigracindo
vinigracindo / steps.md
Created February 27, 2019 20:46 — forked from nicobytes/steps.md
Remeber you fuck steps, config for deploy django project

Conectarse con el server

  1. ssh user@your_ip
  2. Generar llave ssh-keygen -b 4096 (dentro de .ssh)
  3. Enviar llave al server ssh-copy-id -i .ssh/name.pub user@your_ip
  4. Conectar: ssh user@your_ip

Install Nginx

  1. update apt-get update
def test_login_page(self):
"""
Test Login Page
"""
# Faz um requisição GET
response = self.client.get(reverse("login"))
# Checa o status.
self.assertEqual(response.status_code, 200)
@vinigracindo
vinigracindo / gist:5388567
Created April 15, 2013 14:37
Android Download Image from URL
package utils;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
#!/usr/bin/env python
#
# Copyright 2010 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
>>> user.twitter.me()
<tweepy.models.User objects at [...]>
>>> user.twitter.me().location
u'São Paulo'
>>> user.twitter.me().timeline() # Mostra as 20 últimas 'twittadas' do usuário
[Retorna uma lista de objetos tweepy.models.Status]
# Vamos pegar um twitter:
>>> twitter = user.twitter.me().timeline()[0]
>>> twitter.text
u'Meu twitter'
import settings
import tweepy
From user_auth.models import UserSocialAuth
From django.contrib.auth.models import User
user = User.objects.get(id=10) # Suponha que existe um usuário 10 com facebook
oauth = tweepy.OAuthHandler(settings.TWITTER_CONSUMER_KEY, settings.TWITTER_CONSUMER_SECRET)
access_token = UserSocialAuth.objects.get(user = user, provider = 'twitter').extra_data['access_token']
oauth.set_access_token(access_token ['oauth_token'][0], access_token ['oauth_token_secret'][0])
user._twitter = tweepy.API(oauth)
From django.contrib.auth.models import User
From user_auth.models import UserSocialAuth
import facebook # (Facebook.py [3])
user = User.objects.get(id=10) # Suponha que existe um usuário 10 com facebook
access_token = UserSocialAuth.objects.get(user = user, provider = 'facebook').extra_data['access_token']
user._facebook = facebook.GraphAPI(access_token)
user.facebook
>> <facebook.GraphAPI object [...]>
# Levando em consideração que exista um Usuário com ID 3 e que possua facebook
user = User.objects.get(id=3)
user.social_auth.get_query_set().filter(provider = 'twitter')