count history commands
history | cut -c8- | sort | uniq -c | sort -rn | head
# Deal exclusively with unicode objects as much as possible | |
# by decoding things to unicode objects when you first get them and | |
# encoding them as necessary on the way out. | |
# https://stackoverflow.com/a/6048203 | |
>>> s = 'abc' | |
>>> type(s) | |
<type 'str'> | |
>>> u = u'abc' # note the u prefix |
import argparse | |
import xlrd | |
import xlwt | |
def chunks(l, n): | |
"""Yield successive n-sized chunks from l.""" | |
for i in range(0, len(l), n): | |
yield l[i:i + n] |
AF | Afghanistan | |
---|---|---|
EG | Ägypten | |
AL | Albanien | |
DZ | Algerien | |
AD | Andorra | |
AO | Angola | |
AI | Anguilla | |
AQ | Antarktis | |
AG | Antigua und Barbuda | |
GQ | Äquatorial Guinea |
count history commands
history | cut -c8- | sort | uniq -c | sort -rn | head
{ | |
"folders": | |
[ | |
{ | |
"path": "django_project_dir" | |
}, | |
{ | |
"path": "lib/python2.7" | |
} | |
], |
A proof of concept.
If you cant't/won't use the apps Migration files this workaround can be helpful for you.
We assume you have a clean Database without any Migrations applied and a Project named my_project
that you are working on.
Add the below snippet in your settings.py
right after INSTALLED_APPS
.
This tells django to use migration files from the module in my_project.migrations.<appname>.migrations
.
from django.test import TestCase | |
from .models import Thing | |
# Create your tests here. | |
class TestModels(TestCase): | |
def test_saving_a_model(self): | |
thing = Thing.objects.create() | |
thing.save() |
from compat import import_string | |
from django.conf import settings | |
for app_name in settings.INSTALLED_APPS: | |
app = __import__(app_name) | |
print "Information for " + app_name | |
try: | |
print "verion: " + app.__version__ | |
except Exception as e: | |
print "version: " + str(e) |
from django.core import urlresolvers | |
from django.contrib.contenttypes.models import ContentType | |
from django.db import models | |
class MyModel(models.Model): | |
def get_admin_url(self): | |
content_type = ContentType.objects.get_for_model(self.__class__) | |
return urlresolvers.reverse("admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.id,)) |
import atexit | |
import os | |
import sys | |
try: | |
import readline | |
except ImportError: | |
print "Module readline not available." | |
else: | |
import rlcompleter | |
readline.parse_and_bind('tab:complete') |