A Pen by Will Farley on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pdb; pdb.set_trace() | |
# --or-- | |
import pudb; pudb.set_trace() | |
# l | |
# n >> nextline | |
# context >> get current context |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleAjaxForm = (form) => { | |
$.ajax({ | |
url: form.action, | |
dataType: 'html', | |
type: 'POST', | |
data: $(form).serialize(), | |
success: data => { | |
$(form.parentElement).fadeOut(); | |
setTimeout(() => $('#success-message').fadeIn(), 1000); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<img class="lowq" | |
data-src="/static/orginal-img.png" | |
data-lowq_path='/static/lowq_imgs/' data-qualities="5,10,15,20,25,30,35,50,60,70"> | |
<script src="/main.js"></script> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.contrib.staticfiles.finders import find as find_static_file | |
from django.conf import settings | |
register = template.Library() | |
@register.simple_tag | |
def encode_static(path, encoding='base64', file_type='image'): | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getDataset = (elem) => { | |
/* ie <= 10 does not support elem.dataset | |
* ie <= 10 also doesn't support Array.from | |
* collect an elements data properties and return them in a similar format | |
* to the elem.dataset method | |
*/ | |
let attrs = Array.prototype.slice.call(elem.attributes).filter(attr => !!~attr.nodeName.indexOf('data-')); | |
return attrs.reduce((a, attr) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getActiveHeightTrigger(triggersMap) { | |
// returns the smalles height from a set of heights that is more than the window height | |
return triggersMap.reduce((pV, cV) => { | |
// is this height more than window? | |
let checkWindow = (cV.height >= window.innerHeight); | |
// is this height less than previous height? | |
let checkPrev = (cV.height < pV.height); | |
if (checkWindow) { | |
if (checkPrev || !pV.height) return cV; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ContextComponent extend React.Componet { | |
static contextTypes = { | |
store: PropTypes.object, | |
} | |
componentDidMount() { | |
this.unsubscribe = this.context.store.subscribe(() => { | |
this.forceUpdate(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let katdawg = { | |
kat: { | |
says: { | |
meow: '...' | |
} | |
}, | |
dawg: { | |
bark: 'woof' | |
} |