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 [email protected] | |
ServerName zftemplate.desktop | |
# This should be omitted in the production environment | |
SetEnv APPLICATION_ENV development | |
<Directory "/home/user/WorkspacePHP/zftemplate/public"> |
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
# send to rabbitmq (celery task) | |
import pika | |
import simplejson | |
credentials = pika.credentials.PlainCredentials('user', 'pass') | |
connection = pika.BlockingConnection( | |
pika.ConnectionParameters( | |
host='localhost', | |
virtual_host='/vhost_name', | |
credentials=credentials |
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 Crypto.Cipher import DES | |
crypt_key = 'secret' | |
def crypt(what): | |
k = DES.new(crypt_key, DES.MODE_ECB) | |
return k.encrypt(what.zfill(32)) | |
def decrypt(what): |
OlderNewer