This file contains hidden or 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
@staticmethod | |
def copy_range(ws_source, ws_target, source_range, target_start): | |
start_col, start_row, _, _ = range_boundaries(target_start) | |
for row, row_cells in enumerate(ws_source[source_range], start_row): | |
for column, cell in enumerate(row_cells, start_col): | |
target_cell = ws_target.cell(row=row, column=column) | |
target_cell.value = cell.value | |
target_cell.font = cell.font |
This file contains hidden or 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 health_web.utils import send_email | |
send_email('EMAIL TEST', 'TEST EMAIL', ['test@yandex.ru']) |
This file contains hidden or 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
''' | |
Add CORS headers for tastypie APIs | |
Usage: | |
class MyModelResource(CORSModelResource): | |
... | |
class MyResource(CORSResource): | |
... | |
This file contains hidden or 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
Ubuntu End of Life Package Repository | |
If you’re using a normal version of Ubuntu such as Saucy, Raring, Quantal, Oneiric, Natty, Maverick, etc, you may have already (and will eventually) start getting “Failed to fetch 404 Not Found” errors when trying to run apt-get update , or even sometimes running apt-get install , but fear not, it is easy to fix, and here’s how… | |
Why am I getting this error? | |
Normal Ubuntu releases are supported for 9 months, whereas LTS (Long Term Support) releases are supported for 5 years. Once support is up for the version of Ubuntu you are using the repository is moved to another server and will no longer be available on the standard http://archive.ubuntu.com/ubuntu/dist/ location. | |
Ubuntu Release Details | |
The most simple solution would be to upgrade to a newer version: |
This file contains hidden or 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 openpyxl.styles import Alignment, Font, Border, Side, PatternFill | |
from openpyxl.workbook import Workbook | |
from openpyxl import load_workbook, drawing | |
from lxml.html import document_fromstring, HTMLParser | |
# Value must be one of set(['hair', 'medium', 'dashDot', 'dotted', 'mediumDashDot', 'dashed', | |
# 'mediumDashed', 'mediumDashDotDot', 'dashDotDot', 'slantDashDot', 'double', None, 'thick', 'thin']) | |
_BORDER_STYLE = { | |
'0': None, | |
'1': 'thin', |
This file contains hidden or 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
<table border="1"> | |
<tr> | |
<td>1 </td> | |
<td>1 </td> | |
<td>1 </td> | |
<td align="center" rowspan="4">Thing</td> | |
<td>1 </td> | |
</tr> | |
<tr> | |
<td>2 </td> |
This file contains hidden or 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
find . -print -exec touch {} \; |
This file contains hidden or 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 PIL import Image | |
class CropImageModel(CleanupFileModel): | |
class Meta: | |
abstract = True | |
def _get_crop_fields(self): | |
for field in self._meta.fields: | |
if isinstance(field, models.ImageField) and getattr(self, field.name + '_width', None) and \ |
This file contains hidden or 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
If your network connection blocks both outbound TCP ports 25 and 587 but allows outgoing TCP port 465, you need your e-mail server to relay mail through a smarthost using SMTPS. Unfortunately, new versions of Postfix no longer natively support using an SMTPS smarthost. Gather the server name, username, and password for your SMTPS-enabled smarthost, then follow these directions for a quick fix. | |
In this example, I’m using the Comcast SMTP server as my smarthost — replace smtp.comcast.net:465 with the mail server you wish to use as a smarthost. | |
Install stunnel and Postfix with sudo apt-get install stunnel mailutils postfix | |
If you weren’t automatically prompted to configure Postfix, run sudo dpkg-reconfigure postfix to access the configuration wizard. Configure Postfix as a “Satellite system”. You must enter a valid domain name for “System mail name”, so use example.com. For “SMTP relay host”, enter [127.0.0.1]:10465 | |
Enable stunnel automatic startup. Run sudo vim /etc/default/stunnel4 and change ENABLED=0 to EN |
This file contains hidden or 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 os | |
from itertools import ifilter | |
from PIL import Image | |
from django.db import models | |
from django.db.transaction import atomic | |
class CleanupFileModel(models.Model): |
NewerOlder