Skip to content

Instantly share code, notes, and snippets.


DTailor DTailor

View GitHub Profile
DTailor /
Last active Sep 15, 2019
Backup/Restore PostgreSQL Database
# List all databases
sudo -u postgres psql --list
# Create backup file
sudo -u postgres pg_dump [database_name] > dumpl.sql
# Drop the database
sudo -u prostgres dropdb [database_name]
# Create a new database

Keybase proof

I hereby claim:

  • I am dtailor on github.
  • I am dtailor ( on keybase.
  • I have a public key ASBiHLMc6dEiRpClfT9utqBxnAv5eBM_HaogyBvjorC5vQo

To claim this, I am signing this object:

DTailor /
Created May 8, 2012
Raw Socket Sniffer
import socket
from struct import *
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
while True:
pack = s.recvfrom(20000)
#Get the single element from the tuple
DTailor / gist:3955355
Created Oct 25, 2012
Get all objects added today from midnight
View gist:3955355
import datetime
from django.utils.timezone.utcnow().replace(tzinfo=utc)
now = datetime.datetime.utcnow().replace(tzinfo=utc)
midnight = now.replace(hour=0,minute=0,second=0,microsecond=0)
queries = YourModel.objects.filter(time__gte = midnight )