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
def not_found(method): | |
def wrap(*args, **kwargs): | |
from django.core.exceptions import ObjectDoesNotExist | |
from django.http import Http404 | |
try: | |
return method(*args, **kwargs) | |
except ObjectDoesNotExist, ex: | |
raise Http404(ex.message) |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import unicodedata | |
def elimina_tildes(cadena): | |
s = ''.join((c for c in unicodedata.normalize('NFD',unicode(cadena)) if unicodedata.category(c) != 'Mn')) | |
return s.decode() | |
string_acentos = 'café'.decode('utf-8') |
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(old) { | |
$.fn.attr = function() { | |
if(arguments.length === 0) { | |
if(this.length === 0) { | |
return null; | |
} | |
var obj = {}; | |
$.each(this[0].attributes, function() { | |
if(this.specified) { |
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 HTMLParser | |
h = HTMLParser.HTMLParser() | |
s = h.unescape('© 2010') | |
print s |
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
from django.views.decorators.cache import cache_page | |
from functools import wraps | |
from django.utils.decorators import available_attrs | |
def cache_on_auth(timeout): | |
def decorator(view_func): | |
@wraps(view_func, assigned=available_attrs(view_func)) | |
def _wrapped_view(request, *args, **kwargs): | |
return cache_page(timeout, key_prefix="_auth_%s_" % request.user.is_authenticated())(view_func)(request, *args, **kwargs) | |
return _wrapped_view |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import random | |
from string import digits | |
from string import letters | |
def _pw(length=10): | |
s = '' | |
for i in range(length): |
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
sudo groupadd developers | |
adduser username | |
usermod -a -G developers username | |
mkdir repository.git | |
cd !$ | |
git --bare init | |
touch readme.md |
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
sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python27.repo >> /etc/yum.repos.d/scl.repo' | |
sudo yum install python27 | |
scl -l | |
python27 | |
scl enable python27 bash | |
python -V |
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
### Makes you owner of /usr/local | |
$ sudo chown -R `whoami` /usr/local | |
### Force uninstalls failed python | |
$ brew uninstall -f python | |
### Clear the brew cache | |
$ rm -rf `brew --cache` | |
### Cleanup - cleans up old homebrew files |
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
# first install mysql | |
brew install mysql | |
# second export path mysql | |
PATH="$PATH:/usr/local/Cellar/mysql/5.6.15/bin/" | |
# finally install mysql-python | |
sudo pip install mysql-python --upgrade |
OlderNewer