Skip to content

Instantly share code, notes, and snippets.

View johnsardine's full-sized avatar

João Sardinha johnsardine

View GitHub Profile
jQuery.expr[':'].contains = function(a, i, m) {
var rExps=[
{re: /[\xC0-\xC6]/g, ch: "A"},
{re: /[\xE0-\xE6]/g, ch: "a"},
{re: /[\xC8-\xCB]/g, ch: "E"},
{re: /[\xE8-\xEB]/g, ch: "e"},
{re: /[\xCC-\xCF]/g, ch: "I"},
{re: /[\xEC-\xEF]/g, ch: "i"},
{re: /[\xD2-\xD6]/g, ch: "O"},
{re: /[\xF2-\xF6]/g, ch: "o"},
$(document).ready(function(){
// $sections incleudes all of the section divs that relate to menu items.
var $sections = $('.section');
// The user scrolls
$(window).scroll(function(){
// currentScroll is the number of pixels the window has been scrolled
var currentScroll = $(this).scrollTop();
import requests, re
problem_name = 'even-or-odd'
problem_url = 'https://www.codewars.com/kata/' + problem_name
users = [ 'fabiopedrosa', 'johnsardine', 'disbeat', 'pgcmarques', 'nnunobm', 'alexp100' ]
problem_id = re.findall('<div class="info-row code-challenge" data-id="(.+?)"', requests.get(problem_url).text)[0]
users = dict( [ (u, []) for u in users ] )
for user in users:
@johnsardine
johnsardine / middleware.py
Created March 17, 2017 11:42 — forked from thomasyip/middleware.py
Accept Tastypie API Key authentication for regular django app.
class TastypieApiKeyUserMiddleware(object):
"""
Middleware for per-request authentication with tastypie
"""
# Name of request header to grab username from. This will be the key as
# used in the request.META dictionary, i.e. the normalization of headers to
# all uppercase and the addition of "HTTP_" prefix apply.
header = 'HTTP_AUTHORIZATION'
method = 'apikey'
apikey_auth = ApiKeyAuthentication()