Skip to content

Instantly share code, notes, and snippets.

View chrisdev's full-sized avatar

Christopher Clarke chrisdev

View GitHub Profile
@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)
@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
@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):
@chrisdev
chrisdev / email_address_extractor.py
Last active August 29, 2015 14:22
Extract email addresses from email messages via IMAPP
import imaplib, email
import getpass, imaplib, email, sets
def split_addrs(s):
#split an address list into list of tuples of (name,address)
if not(s): return []
outQ = True
cut = -1
res = []
@chrisdev
chrisdev / gist:46bf51de3919ab56b8a0
Created May 21, 2015 14:43
sent email with on mandrill with python
# install
# -------
pip install mandrill
# sending the email
# ----------
import mandrill
API_KEY = 'valid_api_key'
@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 / Color-Palette---Flexbox-Friday-Demo-2.markdown
Created February 13, 2015 16:53
Color Palette - Flexbox Friday Demo 2