Skip to content

Instantly share code, notes, and snippets.

View johnsardine's full-sized avatar

João Sardinha johnsardine

View GitHub Profile
@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()
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:
$(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();
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"},
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="yes" name="apple-mobile-web-app-capable">
<title>iOS Web App</title>
<!-- iPhone -->
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@johnsardine
johnsardine / dabblet.css
Created June 19, 2012 08:01 — forked from LeaVerou/dabblet.css
CSS Pebbles!
/**
* CSS Pebbles!
*/
html {
background: url("http://michaeliahotel.com/img/sand.jpg");
min-height: 100%;
}
.aside-icons {
@johnsardine
johnsardine / dabblet.css
Created June 11, 2012 21:43 — forked from LeaVerou/dabblet.css
CSS Pebbles!
/**
* CSS Pebbles!
*/
html {
background: url("http://michaeliahotel.com/img/sand.jpg");
min-height: 100%;
}
.aside-icons {
@johnsardine
johnsardine / dabblet.css
Created June 5, 2012 20:07 — forked from LeaVerou/dabblet.css
drop-shadow filter vs box-shadow
/**
* drop-shadow filter vs box-shadow
*/
html {
background: url('http://subtlepatterns.com/patterns/purty_wood.png')
}
.speech-bubble {
position: relative;
@johnsardine
johnsardine / dabblet.css
Created April 21, 2012 13:54 — forked from LeaVerou/dabblet.css
Image interpolation demo
/* Image interpolation demo */
@keyframes browsers {
from, to { background-image: url('http://lea.verou.me/css-4d/img/firefox-logo.png'); }
20% { background-image: url('http://lea.verou.me/css-4d/img/chrome-logo.png'); }
40% { background-image: url('http://lea.verou.me/css-4d/img/safari-logo.png'); }
60% { background-image: url('http://lea.verou.me/css-4d/img/opera-logo.png'); }
80% { background-image: url('http://lea.verou.me/css-4d/img/ie-logo.png'); }
}