Skip to content

Instantly share code, notes, and snippets.


Chad Dupuis chaddupuis

View GitHub Profile
chaddupuis /
Created December 21, 2022 19:26
Django Recaptcha fix for SSL:CERTIFICATE_VERIFY_FAILED unable to get local issuer
There are likely a few fixes for this but you are likely to see this error
if your app needs to reach out to an https server (in this case
and it cannot verify the ssl certificate.
The certifi package ( ) provides a
curated collection of Root Certificates that avoids this.
pip install certifi - then in your settings you just need to set
the environmental variable for REQUESTS_CA_BUNDLE and SSL_CERT_FILE.
chaddupuis / nginx-ansible-server.yaml
Created December 21, 2022 19:23
Ansible to build an nginx server with certbot
View nginx-ansible-server.yaml
# post base server setup
# nginx, pulls confs from git repo
# certbot setup and general firewall conf
- hosts: nginxweb
become: yes
my_ip_range: x.x.x.x/24
my_jump_ip: x.x.x.x
chaddupuis /
Created December 21, 2022 19:21
Lego (acme go client) bash script for renewals (with SAN lists)
# Likely in a cron job to handle cert renewals.
# The acme go client is here -
chaddupuis /
Created December 21, 2022 19:18
Django Full Text Search using Postgres SearchQuery with Faceted and Paginated Results
from django.db import models
from django.utils.text import slugify, Truncator
from django.db.models.functions import Lower
from django.db.models.signals import pre_save, post_save, post_delete, m2m_changed
from import SearchVectorField, SearchVector
from django.contrib.postgres.indexes import GinIndex
from django.db.models import Value
import re
chaddupuis / push-django-updates.yaml
Last active December 21, 2022 19:15
Ansible to push code updates for Django running with unicorn/nginx behind a cloudflare load balancer
View push-django-updates.yaml
- hosts: webservers
become: yes
my_ip_range: x.x.x.x/24
my_db: x.x.x.x
#following from
chaddupuis /
Created December 21, 2022 19:11
Django Image Scraping and Writing to S3 with NamedTemporaryFiles (no local copies)
from csv import DictReader
from django.core.files import File
import urllib.request
from urllib.request import urlopen
from tempfile import NamedTemporaryFile
from import BaseCommand
import time
from PIL import Image
from io import BytesIO
from django.core.files.base import ContentFile
chaddupuis /
Created December 21, 2022 19:08
Use Google Drive from Linux as a Virtual Drive (Gnome GIO Library)
# alias to provide readable directory listings when using mounted google drives on linux
alias lg='gio list -a "standard::display-name"'
chaddupuis / create-products-from-csv.php
Created December 21, 2022 19:07
Processwire CLI - Example Processing a CSV to Processwire Fields
View create-products-from-csv.php
<?php namespace ProcessWire;
// This is an example of the transfer of product data (could be anything)
// from a csv to their corresponding fields in a processwire template
// and creating the pages. This uses the processwire feature of instantiating
// an instance from a command line script to access global variables
// (
$st = new ProcessWire('/var/www/', '');
chaddupuis / apt-update-upgrade.yml
Created December 21, 2022 19:03
Basic Ansible - APT Upgrade
View apt-update-upgrade.yml
- hosts: mytargets
become: true
- name: update apt repo and cache
chaddupuis / processwire-google-merchant-csv.php
Created December 21, 2022 19:00
Google Merchant CSV Creation from Processwire - For Inclusion in Google Shopping
View processwire-google-merchant-csv.php
<?php namespace ProcessWire;
$st = new ProcessWire('/var/www/', '');
// gmerchant header
//id title description link condition price availability image link gtin mpn brand google product category
//product_to_google is a pw field - if 1 send it to google, if 0 do not send
$myGmerchantProducts = $st->pages->find("template=page-general-product|page-other-product, product_to_google=1, sort=title");
$howMany = 0;