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
<?php | |
/** | |
* Find difference between two dates in days. PHP 5.2.x. | |
*/ | |
$d1 = date('Y-m-d', strtotime('2013-06-13 12:27:43')); | |
$d2 = date("Y-m-d"); | |
echo diff($d1, $d2); | |
function diff($date1, $date2) { |
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
# A list of possible reserved words | |
reserved_words = [ | |
# Companies | |
'amazon', 'apple', 'atlassian', 'canonical', 'facebook', 'github', | |
'google', 'htc', 'huawei', 'ibm', 'microsoft', 'mozilla', 'naughtydog', | |
'nintendo', 'nokia', 'rim', 'samsung', 'sony', 'toshiba', 'twitter', | |
'ubisoft', 'wikipedia', 'xref', 'yahoo', | |
# Operating systems |
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 django.db import models | |
class TimeStampedModel(models.Model): | |
""" | |
An abstract base class model that provides self-updating 'created' | |
and 'modified' fields. | |
""" | |
created = models.DateTimeField(auto_now_add=True) | |
modified = models.DateTimeField(auto_now=True) |
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
using System; | |
using System.Text; | |
using System.Security.Cryptography; | |
static class Hash | |
{ | |
public static string SHA1(string text) | |
{ | |
byte[] buffer = Encoding.UTF8.GetBytes(text); | |
var sha1 = new SHA1CryptoServiceProvider(); |
NewerOlder