Skip to content

Instantly share code, notes, and snippets.

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

Regis Santos rg3915

🏠
Working from home
View GitHub Profile
@fmasanori
fmasanori / Facebook Profile Python 3x.py
Created January 29, 2013 19:58
Python 3.x Facebook Profile
import urllib.request
import json
from pprint import pprint
url = 'https://graph.facebook.com/fmasanori'
resp = urllib.request.urlopen(url).read()
data = json.loads(resp.decode('utf-8'))
pprint (data)
@fmasanori
fmasanori / Facebook Profile Image Python 3x.py
Created January 29, 2013 20:06
Python 3.x Facebook Profile Image
import urllib.request
import json
user = 'fmasanori'
url = 'https://graph.facebook.com/'+user+'/picture?type=large'
figura = urllib.request.urlopen(url).read()
arquivo = user + '.jpg'
f = open (arquivo, 'wb')
f.write(figura)
@fmasanori
fmasanori / ChuckJokesPython3.py
Last active September 5, 2023 11:36
Chuck Norris Nerd Jokes
from urllib.request import Request, urlopen
import json
req = Request(
url='https://api.chucknorris.io/jokes/random',
headers={'User-Agent': 'Mozilla/5.0'}
)
resp = urlopen(req).read()
data = json.loads(resp.decode('utf-8'))
@goldhand
goldhand / Django + Ajax dynamic forms .py
Last active September 29, 2023 06:32
Django form with Ajax. A simple Task model that can be updated using a CBV with an AJAX mixin. The view sends post data with ajax then updates the view with a callback to a DetailView with a json mixin.There is an abstract CBV, AjaxableResponseMixin, based on the example form django docs, that is subclassed in the TaskUpdateView CBV. TaskUpdateV…
#models.py
class Task(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
def __unicode__(self):
return self.title
@neara
neara / forms.py
Last active April 17, 2024 19:54
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@luzfcb
luzfcb / anp_crawler.py
Last active April 2, 2018 04:15
Implementação simples de um Crawler pra extrair dados do site a ANP
# coding=utf-8
"""
NAO FUNCIONA MAIS. O sistema de CAPTCHA foi trocado.
**Implementa um Webcrawler para extracao de dados da pesquisa de media de precos realizada periodicamente pela ANP**
Desenvolvido por Fabio C. Barrionuevo da Luz. - 2013
Simple crawler to ANP site
Copyright (C) 2013 Fabio C. Barrionuevo da Luz.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@henriquebastos
henriquebastos / cpfchecksum.py
Last active August 21, 2020 01:36
Brincando com recursos do Python para calcular se um cpf é válido
# coding: utf-8
def cpf_checksum(value):
"""
CPF Checksum algorithm.
"""
def dv(partial):
s = sum(b * int(v) for b, v in zip(range(len(partial)+1, 1, -1), partial))
return s % 11
@edmondburnett
edmondburnett / gist:40e7db34416fdc734846
Last active April 17, 2019 16:21
Push-to-Deploy, Python edition - git post-receive hook script
#!/usr/bin/env python
# post-receive hook for git-based deployments
import sys
import os
from subprocess import call
# configuration
deploy_to_path = '/path/to/deploy/directory/'
deploy_branch = 'master'
@djq
djq / unions
Created November 22, 2014 21:23
How to union a list of geometries in GeoDjango
from django.contrib.gis.geos import GEOSGeometry
# sample data
geom_1 = GEOSGeometry('POLYGON((-71.8 42.1,-70.6 42.1,-70.5 41.2,-71.8 41.2,-71.8 42.1))')
geom_2 = GEOSGeometry('POLYGON((-71.12 42.23,-71.48 42.34,-71.52 42.55,-71.12 42.23))')
geom_3 = GEOSGeometry('POLYGON((-73.12 42.23,-71.48 42.34,-71.52 42.55,-73.12 42.23))')
polygons = [geom_1, geom_2, geom_3]
# get first polygon
polygon_union = polygons[0]
@anthanh
anthanh / table-emmet
Created February 20, 2015 19:36
Emmet table example
table[name="pepe"]>thead>tr>th*3^^+tbody>tr*7>td{Basico}*3