Skip to content

Instantly share code, notes, and snippets.

View idwaker's full-sized avatar

Diwaker Ghimire idwaker

View GitHub Profile
"""
Logical deletion for Django models. Uses is_void flag
to hide discarded items from queries. Overrides delete
methods to set flag and soft-delete instead of removing
rows from the database.
"""
from django.apps import apps
from django.contrib.admin.utils import NestedObjects
from django.db import models
from django.db.models import signals
@idwaker
idwaker / install-comodo-ssl-cert-for-nginx.rst
Created February 12, 2016 10:59 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@idwaker
idwaker / imgresize.php
Last active September 5, 2015 08:24
image resize using php gd
<?php
function get_thumbnail($filename)
{
$upload_path = '.';
list($file, $ext) = explode('.', $filename);
$thumbnail = $file . '__thumb' . '.' . $ext;
$new_width = 500;
@idwaker
idwaker / cors_server.py
Last active August 29, 2015 14:26 — forked from enjalot/cors_server.py
Allow CORS with python simple http server
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)