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 send_mail | |
import os | |
def sendMyAppEmail(toList, template, toType=None, subject="", templateDict={}): | |
# Load the image you want to send at bytes | |
img_data = open(os.path.join(settings.MEDIA_ROOT, 'bumblebee.jpeg'), 'rb').read() | |
# Create a "related" message container that will hold the HTML |
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 | |
""" | |
Recipe for creating and updating security groups programmatically. | |
""" | |
import collections | |
import boto |
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
MessageDigest digest; | |
byte[] hash; | |
String name = "http://test.com/d0d5689be9f9c8b5.jpg"; | |
try { | |
digest = java.security.MessageDigest.getInstance("MD5"); | |
digest.update(name.getBytes("UTF-8")); | |
hash = digest.digest(); | |
BigInteger bigInt = new BigInteger(1, hash); | |
String hashtext = bigInt.toString(16); | |
while(hashtext.length() < 32 ){ |
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 hashlib | |
m = hashlib.md5() | |
m.update("http://test.com/d0d5689be9f9c8b5.jpg") | |
print m.hexdigest() |
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
# urls.py | |
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap | |
info_dict = { | |
'queryset': Entry.objects.all(), | |
'date_field': 'pub_date', | |
} | |
sitemaps = { |
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 zipfile | |
zf = zipfile.ZipFile("myzipfile.zip", "w") | |
for dirname, subdirs, files in os.walk("mydirectory"): | |
zf.write(dirname) | |
for filename in files: | |
zf.write(os.path.join(dirname, filename)) | |
zf.close() |
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
$.post('/faq/next/', | |
{'zmienna':'wartosc'}, | |
function(data) { | |
alert(data.question); | |
}, | |
"json" | |
); | |
$.ajax({ | |
type: "POST", |
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
// basic | |
$(document).ready(function() { | |
$('#contact').ajaxForm(function() { | |
alert("Thank you for your comment!"); | |
}); | |
}); | |
<form action="/" method="post" id="contact"> | |
</form> |
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
#application: | |
<VirtualHost *:80>user | |
DocumentRoot "/home/user/WorkspacePHP/zftemplate/public" | |
ServerAdmin user@post.pl | |
ServerName zftemplate.desktop | |
# This should be omitted in the production environment | |
SetEnv APPLICATION_ENV development | |
<Directory "/home/user/WorkspacePHP/zftemplate/public"> |
OlderNewer