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
# export data | |
./manage.py dumpdata --indent=2 auth > initial_data.json | |
# no input | |
./manage.py syncdb --noinput | |
# load any fixture, which should be whitin a dir called fixture within some django app | |
./manage.py loaddata shipping_fixture.json | |
# migrations |
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
# -*- coding: utf-8 -*- | |
import unittest | |
class Calculadora(object): | |
def __init__(self, x=None, y=None): | |
self.x = x | |
self.y = y | |
def suma(self): | |
return self.x + self.y | |
def resta(self): | |
return self.x - self.y |
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
# giving permissions | |
sudo chown $USER /data/db | |
# change /data/db owner | |
sudo chown $USER /data/db |
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
# -*- coding: utf-8 -*- | |
import unittest | |
class Ordenamiento(object): | |
def __init__(self, numeros=None): | |
self.numeros = numeros | |
def insertion_sort(self): | |
# Tu código va aquí. | |
return self.numeros | |
class OrdenamientoTest(unittest.TestCase): |
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
// path of the file to override: /home/user/.config/sublime-text-2/Packages/Python/Python.sublime-build | |
// for simple scripts using virtualenv | |
{ | |
"cmd": ["python", "-u", "$file"], | |
"env": {"PYTHONPATH": "/home/chris/venvs/venv-authorize-sauce/lib/python2.7/site-packages"}, | |
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
"selector": "source.python" | |
} | |
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
[ | |
{ "keys": ["alt+1"], "command": "toggle_side_bar" }, | |
{ "keys": ["alt+2"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} }, | |
{ "keys": ["alt+m"], "command": "toggle_minimap" }, | |
{ "keys": ["alt+right"], "command": "next_view" }, | |
{ "keys": ["alt+left"], "command": "prev_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
from apps.rp.models.Permission import CustomPermission | |
CustomPermission.patch_model_attributes() | |
from django.contrib.auth.models import Permission | |
from django.db import models | |
class CustomPermission(object): | |
@classmethod | |
def patch_model_attributes(cls): | |
method = getattr(Permission, 'add_to_class') |
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
(r'^articles/(?P<year>\d{4}/?$, 'main.views.year'), | |
# When a use case comes up that a month needs to be involved as | |
# well, you add an argument in your regex: | |
(r'^articles/(?P<year>\d{4}/(?P<month>\d{2})/?$, 'main.views.year_month'), | |
# That works fine, unless of course you want to show something | |
# different for just the year, in which case the following case can be | |
# used, making separate views based on the arguments as djangoproject |
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
#http://docs.mongodb.org/manual/reference/sql-aggregation-comparison/ |
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 sys | |
import os | |
sys.path.insert(0, os.path.expanduser('/home/chris/Projects/royalpioneers')) | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'royal.settings' | |
from django.contrib.contenttypes.models import ContentType |