First create the user and folder structure:
adduser git
su git
mkdir -p ~/repos/myrepo.git
git --bare init ~/repos/myrepo.git
Now our remote is ready to add to our local repository. In the local repo:
def bytes_to(bytes, to, bsize=1024): | |
a = {'k': 1, 'm': 2, 'g': 3, 't': 4, 'p': 5, 'e': 6} | |
r = float(bytes) | |
for i in range(a[to]): | |
r /= bsize | |
return r | |
class ShardedCache(object): | |
""" |
#!/usr/bin/env python | |
import sys | |
""" | |
Given a file of the following format: | |
MyClass | |
- My test case | |
- Another test case | |
- And another test case |
[color] | |
ui = auto | |
[user] | |
name = Phil Tysoe | |
email = phil@***.com | |
[push] | |
default = simple | |
[alias] | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
st = status |
SELECT `TABLE_SCHEMA`, `TABLE_NAME`, `TABLE_ROWS`, `DATA_LENGTH`, `INDEX_LENGTH`, `DATA_FREE` FROM `TABLES` WHERE `TABLE_SCHEMA` LIKE "my_database" ORDER BY `DATA_LENGTH` DESC; |
import logging | |
from contextlib import contextmanager | |
from django.db.backends import BaseDatabaseWrapper | |
from django.db.backends.util import CursorWrapper | |
@contextmanager | |
def turn_off_sql_logging(): |
First create the user and folder structure:
adduser git
su git
mkdir -p ~/repos/myrepo.git
git --bare init ~/repos/myrepo.git
Now our remote is ready to add to our local repository. In the local repo:
#!/usr/bin/env python | |
from time import sleep | |
def simulate_defer(_callable, *args, **kwargs): | |
"""mocking Appengine's deferred.defer""" | |
sleep(2) | |
_callable(*args, **kwargs) | |
import json | |
from rest_framework.test import APIClient | |
def get(self, *args, **kwargs): | |
response = super(APIClient, self).get(*args, **kwargs) | |
try: | |
response.content_as_python = json.loads(response.content) | |
except ValueError as e: |
from django.db.models import get_models, get_app | |
MY_APPS = ('foo', 'bar') | |
# get all the models | |
models = [] | |
for app in MY_APPS: | |
try: | |
models += get_models(app_mod=get_app(app)) | |
except ImproperlyConfigured: |
# search all files ignoring those paths that contain regex_pattern (should be quoted) | |
ack -v -g regex_pattern | ack -x pattern | |
# practical Django usage to ignore migrations files | |
ack --python -v -g 'migrations' | ack -x foo |