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
// TR: StrSubstitutor.substitute() yöntemi, değiştirilecek değişkenle birlikte çağrılır | |
// EN: The StrSubstitutor.substitute() method is called with the variable to be substituted | |
protected boolean substitute(final LogEvent event, final StringBuilder buf, final int offset, final int length) { | |
return substitute(event, buf, offset, length, null) > 0; | |
} | |
// EN: The StrSubstitutor.substitute() method is called with the original variable lookup (i.e., ctx.apiversion) | |
// TR: StrSubstitutor.substitute() yöntemi, orijinal değişken aramasıyla (yani, ctx.apiversion) çağrılır; |
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
############# | |
# models.py # | |
############# | |
from django.db import models | |
class Goods(models.Model): | |
name = models.CharField(max_length=100) # for example phone, tv etc. | |
weight = models.CharField(max_length=100) # for example 50 kg | |
price = models.CharField(max_length=100) # for example 80 $ |
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
# django.core.mail using your base settings.py at your project | |
# You must add in to your settings.py email smtp configuration | |
# you can look my mail-sender-settings.py | |
# https://gist.github.com/dogancankilment/2ddf7f5363733bbef471dcaf15bdfc31#file-mail-sender-settings-py | |
from django.core.mail import send_mail | |
def mail_sender(): | |
send_mail('Subject here', | |
'Here is the 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
# django settings.py | |
... | |
MAIL_PASSWD = "Your-Mail-Passwd" | |
# Email setup | |
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | |
EMAIL_USE_TLS = True | |
EMAIL_HOST = 'smtp.gmail.com' | |
EMAIL_HOST_USER = '[email protected]' |
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.core.mail import EmailMultiAlternatives | |
from django.template import Context | |
from django.template.loader import render_to_string | |
from django.http import HttpResponse | |
from django.utils.translation import ugettext as _ | |
from .util_token_generator import activation_key_generator | |
def mail_sender(email, controll): |
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 base64 | |
import datetime | |
def activation_key_generator(email): | |
expire_date = datetime.datetime.today() + datetime.timedelta(3) | |
activation_key = base64.b64encode( | |
str(expire_date)) + base64.b64encode( | |
str(email)).split('=')[0] | |
return activation_key |
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 PIL import Image, ImageEnhance | |
def reduce_opacity(im, opacity): | |
"""Returns an image with reduced opacity.""" | |
assert opacity >= 0 and opacity <= 1 | |
if im.mode != 'RGBA': | |
im = im.convert('RGBA') | |
else: | |
im = im.copy() |
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 os | |
import PIL | |
from PIL import Image | |
def image_resizer(path): | |
img = Image.open(path) | |
basewidth = 700 |
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 ftplib | |
def ftp_upload(): | |
ftp = ftplib.FTP("yourdomain.com") | |
ftp.login("ftp_username", "ftp_password") | |
upload_file = "/full/path/your/file.txt" | |
ftp.storlines("STOR " + upload_file, open(upload_file)) |
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 ftplib | |
def directory_list(): | |
ftp = ftplib.FTP("yourdomain.com") | |
ftp.login("username", "password") | |
data = [] | |
ftp.dir(data.append) | |
ftp.quit() |
NewerOlder