Skip to content

Instantly share code, notes, and snippets.

View ishahid's full-sized avatar

Imran Shahid ishahid

View GitHub Profile
@ishahid
ishahid / date_diff.php
Created January 15, 2014 02:16
Find difference between two dates in days. PHP 5.2.x.
<?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) {
@ishahid
ishahid / reserved_words.py
Last active February 27, 2017 23:47
Reserved words to exclude when creating usernames (or any other resource).
# 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
@ishahid
ishahid / timestampedmodel.py
Last active December 24, 2015 06:49
An abstract base class model for Django that provides self-updating 'created' and 'modified' fields.
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)
@ishahid
ishahid / Hash.cs
Last active December 13, 2015 17:38 — forked from inogo/Hashes.cs
MD5 and SHA1 hash calculation tool.
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();