This file contains 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
//listen on event on an element that is in the DOM when the page load | |
$('#my_element').change(function(e){ | |
//do stuff | |
}); | |
//listen on event on an element that is NOT in the DOM when the page, formerly .live() | |
$(document).on( 'change', '#my_element', function(e) { | |
//do stuff | |
}); |
This file contains 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 FieldBuilder(object): | |
"""Return the default form field for a model field. This field will be validated oin the same | |
way as the form field would be on a ModelForm. | |
Optionally, extra kwargs can be added to override what the form field is initialized with. | |
So this: | |
class ExampleForm(forms.ModelForm): | |
class Meta: | |
model = ExampleModel |
This file contains 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 sys | |
import traceback | |
from django.utils import timezone | |
from django.db import transaction | |
from django.core.management.base import BaseCommand, CommandError | |
# django will strip new lines split helptext in 80 char lines | |
HELP_TEXT = """ |
This file contains 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
[user] | |
name = Marco Alabruzzo | |
email = marco.alabruzzo@gmail.com | |
# signingkey = KEY_HERE | |
[merge] | |
conflictstyle = diff3 | |
[push] | |
default = simple | |
[alias] | |
unadd = reset HEAD |
This file contains 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
# virtualenvwrapper | |
export WORKON_HOME=~/.vienvs | |
source /usr/local/bin/virtualenvwrapper.sh | |
export PATH=/Users/$USER/Library/Python/2.7/bin/:/usr/local/bin:$PATH | |
# nicer prompt | |
export PS1='\u@\h:\[\033[36;2m\]\w\[\033[m\]\$ ' | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxBxDxCxegedabagacad |
This file contains 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 createFunctions() { | |
var i; | |
var functions = []; | |
for (i = 0; i < 5; i++){ | |
functions[i] = function(){ | |
console.log(i); | |
}; | |
} |
This file contains 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
{ | |
/* Remap Home / End keys to be correct */ | |
"\UF729" = "moveToBeginningOfLine:"; /* Home */ | |
"\UF72B" = "moveToEndOfLine:"; /* End */ | |
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */ | |
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */ | |
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */ | |
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */ | |
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */ | |
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */ |
This file contains 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
// original reference https://davidwalsh.name/es6-generators | |
/** | |
* This function create a timeout that should be executed after 1 millisecond | |
*/ | |
function timeoutFunction() { | |
setTimeout(function() { | |
console.log('Timeout'); | |
}, 1); | |
} |
This file contains 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
#!/bin/sh | |
# colors for pretty output | |
RED="\033[00;31m" | |
BLUE="\033[00;34m" | |
GREEN="\033[00;32m" | |
RESET=$(tput sgr0) | |
echo "Linting python files with flake8" | |
LINTER="$(git diff --name-only --cached | grep .py | xargs python3 -m flake8 --config /Users/marco/Code/development/festicket/setup.cfg {})" |