Skip to content

Instantly share code, notes, and snippets.

@DTailor
DTailor / backup_restore.sh
Last active September 15, 2019 18:13
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 (https://keybase.io/dtailor) on keybase.
  • I have a public key ASBiHLMc6dEiRpClfT9utqBxnAv5eBM_HaogyBvjorC5vQo

To claim this, I am signing this object:

@DTailor
DTailor / sniffer.py
Created May 8, 2012 20:16
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
DTailor / gist:3955355
Created October 25, 2012 20:58
Get all objects added today from midnight
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 )