# su - postgre
$ createuser youruser
$ psql
postgres=# ALTER USER youruser WITH PASSWORD 'yoursecretpassword';
postgres=# CREATE DATABASE yourdb owner youruser;
This file contains 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
#!/bin/bash | |
for file in `ls -1`; do | |
echo $file; | |
convert -background white -gravity center $file -resize 1080x1080 -extent 1080x1080 i-$file | |
convert $file -crop 2x1@ i-$file | |
done |
This file contains 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 dramatiq.brokers.stub import StubBroker | |
class EagerBroker(StubBroker): | |
"""Used by tests to simulate CELERY_ALWAYS_EAGER behavior. | |
https://github.com/Bogdanp/dramatiq/issues/195 | |
Modified by @dnmellen to support pipelines and groups | |
""" | |
def process_message(self, message): |
This file contains 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
import uuid | |
import boto3 | |
from decimal import Decimal | |
from functools import partial | |
from django.db import models | |
from django.conf import settings | |
class UUIDModel(models.Model): | |
""" |
This file contains 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
import json | |
import boto3 | |
import paramiko | |
def worker_handler(event, context): | |
ALLOWED_HOSTS = [ | |
'host1', | |
'host2, |
This file contains 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 import template | |
register = template.Library() | |
@register.filter | |
def cool_number(value, num_decimals=2): | |
""" | |
Django template filter to convert regular numbers to a | |
cool format (ie: 2K, 434.4K, 33M...) |
This file contains 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 datetime import datetime, timedelta | |
print (datetime(*(datetime.now() + timedelta(days=1)).timetuple()[:3]) - datetime.now()).seconds |
This file contains 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
import threading | |
import logging | |
from functools import wraps | |
logger = logging.getLogger(__name__) | |
def timeout(secs=None): | |
def my_decorator(target, *args, **kwargs): |
This file contains 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
import asyncio | |
import redis | |
@asyncio.coroutine | |
def listener(redis_conn, channels): | |
pubsub = redis_conn.pubsub() | |
pubsub.subscribe(channels) | |
print('Listening redis...') |
This file contains 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
#!/usr/bin/python -tt | |
""" | |
Takes an screenshot (the user draws a rectangle to select the interesting area), scans the resulting image and copy the text to clipboard | |
- scrot (http://en.wikipedia.org/wiki/Scrot) | |
- readbot (`pip install readbot`) | |
- pyperclip (`pip install pyperclip`) | |
""" |
NewerOlder