Skip to content

Instantly share code, notes, and snippets.

View luzfcb's full-sized avatar

Fábio C. Barrionuevo da Luz luzfcb

View GitHub Profile
import requests
from BeautifulSoup import BeautifulSoup
def megasena_api():
URL_ULTIMOS_RESULTADOS = 'http://www1.caixa.gov.br/loterias/loterias/megasena/megasena_pesquisa_new.asp'
page = requests.get(URL_ULTIMOS_RESULTADOS)
bs = BeautifulSoup(page.content)
numeros_sena = [ n.contents[0] for n in bs.findAll('li')[:6]]
results = page.content.split('|')
@addyosmani
addyosmani / headless.md
Last active May 17, 2024 03:38
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

@csdy
csdy / file.html
Last active January 3, 2019 19:50
Javascript vendor libraries via CDN with local fallback
<!-- JQUERY -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/vendor/jquery-2.0.3.min.js"><\x3C/script>')</script>
<!-- JQUERY UI -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script>window.jQuery.ui || document.write('<script src="/js/vendor/jquery.ui-1.10.3.min.js"><\x3C/script>')</script>
<!-- JQUERY VALIDATE -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/jquery.validate.min.js"></script>
@guillaumepiot
guillaumepiot / gist:5583149
Created May 15, 2013 10:54
DJANGO - Admin custom list filter
class CategoryListFilter(SimpleListFilter):
# USAGE
# In your admin class, pass trhe filter class as tuple for the list_filter attribute:
#
# list_filter = (CategoryListFilter,)
# Human-readable title which will be displayed in the
# right admin sidebar just above the filter options.
@matheussl
matheussl / admin.py
Last active July 26, 2018 01:32
Django 1.5: Add suport to create and edit custom users. SiteUser is identical to auth.User
from django.contrib import admin
from forms import SiteUserCreationForm, SiteUserChangeForm
from django.contrib.auth.admin import UserAdmin
from models import SiteUser
class SiteUserAdmin(UserAdmin):
form = SiteUserChangeForm
add_form = SiteUserCreationForm
@noromanba
noromanba / abp-whitelist-export.js
Last active October 14, 2017 14:21
Adblock Plus Whitelist Export
// Adblock Plus Whitelist Export. require Developer Tools Console
// @author noromanba
// @license MIT License http://nrm.mit-license.org/2013
// chrome-extension://cfhdojbkjhnklbpkdaibdccddilifddb/options.html#tab-whitelisted
var area = document.createElement('textarea');
area.id = 'rawDomainText';
//area.readOnly = true;
area.style.width = '500px';
area.style.height = '150px';
@audreyfeldroy
audreyfeldroy / pypi-release-checklist.md
Last active March 27, 2025 19:16
My PyPI Release Checklist
  • Update HISTORY.md
  • Commit the changes:
git add HISTORY.md
git commit -m "Changelog for upcoming release 0.1.1."
  • Update version number (can also be minor or major)
bumpversion patch
@rknLA
rknLA / gist:6086098
Last active December 20, 2015 06:29 — forked from djq/gist:2846196
update after adding `for-science` should remove the need to install the packages twice. also fixed typo.
#!/bin/bash
#
# Install Postgres 9.1, PostGIS 2.0 and pgRouting on a clean Ubuntu 12.04 install (64 bit)
# updated to PostGIS 2.0.1
# basics
apt-get install python-software-properties
apt-add-repository ppa:sharpie/for-science # To get GEOS 3.3.3
apt-get update
@glasslion
glasslion / generic_relations.py
Created August 16, 2013 07:25
Cache the generic relation field of all the objects in the queryset, using larger bulk queries ahead of time. Improved from original by Daniel Roseman: http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/ and justinfx's gist cache_generics.py : https://gist.github.com/justinfx/3095246#file-cache_generics-py Su…
'''
Cache the generic relation field of all the objects
in the queryset, using larger bulk queries ahead of time.
Improved from original by Daniel Roseman:
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/
and
justinfx's gist cache_generics.py :
from django.http import HttpResponse
from tastypie import http
from tastypie.exceptions import ImmediateHttpResponse
from tastypie.resources import convert_post_to_put
class PublicEndpointResourceMixin(object):
""" Public endpoint dispatcher, for those routes upon which you don't want
to enforce the current resources authentication limits."""