Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View chrisdev's full-sized avatar

Christopher Clarke chrisdev

View GitHub Profile
@chrisdev
chrisdev / gist:b12bb316692cf5f0f004
Created May 19, 2015 15:56
Wagtail Adding Child pages
class TestStaticSitePaths(TestCase):
def setUp(self):
self.root_page = Page.objects.get(id=1)
# For simple tests
self.home_page = self.root_page.add_child(instance=SimplePage(title="Homepage", slug="home"))
self.about_page = self.home_page.add_child(instance=SimplePage(title="About us", slug="about"))
self.contact_page = self.home_page.add_child(instance=SimplePage(title="Contact", slug="contact"))
# For custom tests
@chrisdev
chrisdev / postgres-cheatsheet.md
Created February 3, 2018 20:54 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
  • Update CHANGES.rst
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python setup.py develop
  • Run the tests:
python setup.py test
@chrisdev
chrisdev / play.yml
Created May 23, 2016 18:59
Sudo setting in Ansible Old vs New Playbook
Ansible 2.0 has been nagging me about this for a while
#Old Way with sudo and user
- name: apply common configruation to all nodes
hosts: all
sudo: yes
user: root
roles:
- common
from django.db import models
class M1(models.Model):
title = models.CharField(max_length=100)
img1 = models.ImageField(upload_to="static/")
def __unicode__(self):
return self.title
@chrisdev
chrisdev / django_project_notebook.py
Created November 20, 2012 16:57
IPython notebook extension for Django project
def setup_django_env(path):
import imp
import sys
from os.path import join
from django.core.management import setup_environ
f, filename, desc = imp.find_module('settings', [path])
project = imp.load_module('settings', f, filename, desc)
setup_environ(project)
@chrisdev
chrisdev / gist:b6b2a150a1d51454b9a0
Created June 21, 2015 17:00
Highlight a given file and copy it as RTF
!/bin/zsh
#
# Highlight a given file and copy it as RTF.
#
## Simon Olofsson <simon@olofsson.de>
#
#
set -o errexit
set -o nounset
@chrisdev
chrisdev / my_static_site
Last active August 29, 2015 14:22
Nginx static conf
server {
listen 80;
server_name www.mysite.org;
return 301 $scheme://mysite.org;
}
server {
listen 80;
root /home/myorg/static/myour_static_site;
@chrisdev
chrisdev / ssl_site
Created June 6, 2015 07:42
SSL site
server {
listen [::]:443 default_server;
server_name mysite.org;
ssl on;
ssl_certificate_key /svr/ssl/cert/mysite_org.pem;
ssl_certificate /svr/ssl/cert/ca-bundle.pem;
# sending the email
# ----------
import sys
import mandrill
API_KEY = 'API_KEY_HERE'
def send_mail(template_name, file_name, batch_size=2, starting_pos=0):