Skip to content

Instantly share code, notes, and snippets.

Christopher Clarke chrisdev

Block or report user

Report or block chrisdev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chrisdev
chrisdev / postgres-cheatsheet.md
Created Feb 3, 2018 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

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
Sudo setting in Ansible Old vs New Playbook
View play.yml
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 Jun 21, 2015
Highlight a given file and copy it as RTF
View gist:b6b2a150a1d51454b9a0
!/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 Aug 29, 2015
Nginx static conf
View my_static_site
server {
listen 80;
server_name www.mysite.org;
return 301 $scheme://mysite.org;
}
server {
listen 80;
root /home/myorg/static/myour_static_site;
View 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;
View mandril_send_mails.py
# 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 Aug 29, 2015
Extract email addresses from email messages via IMAPP
View email_address_extractor.py
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
sent email with on mandrill with python
View gist:46bf51de3919ab56b8a0
# install
# -------
pip install mandrill
# sending the email
# ----------
import mandrill
API_KEY = 'valid_api_key'
@chrisdev
chrisdev / gist:b12bb316692cf5f0f004
Created May 19, 2015
Wagtail Adding Child pages
View gist:b12bb316692cf5f0f004
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
View Color-Palette---Flexbox-Friday-Demo-2.markdown
You can’t perform that action at this time.