Skip to content

Instantly share code, notes, and snippets.

View tboulogne's full-sized avatar

Thierry BOULOGNE tboulogne

View GitHub Profile
@tboulogne
tboulogne / ecosystem.config.js
Created January 7, 2021 20:49 — forked from hoangmirs/ecosystem.config.js
Nuxt ecosystem.config.js
module.exports = {
apps: [
{
name: "API",
script: "yarn",
cwd: "/home/deploy/hoang_app/current",
error_file: "/home/deploy/hoang_app/logs/web.err.log",
out_file: "/home/deploy/hoang_app/logs/web.out.log",
// Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
args: "start",
@tboulogne
tboulogne / fabfile.py
Created November 24, 2020 08:57 — forked from fdcore/fabfile.py
backup files and sql from servers, use fabric python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# run: fab backup
__author__ = 'fdcore'
from fabric.api import env, run, get
from datetime import datetime
import os
env.hosts = [
@tboulogne
tboulogne / mysql-docker.sh
Created October 30, 2019 09:53 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@tboulogne
tboulogne / postgres_manager.py
Created October 29, 2019 12:07 — forked from valferon/postgres_manager.py
Python script to take care of postgres backup and restore of data
#!/usr/bin/python3
import argparse
import logging
import subprocess
import os
import tempfile
from tempfile import mkstemp
import configparser
import gzip
@tboulogne
tboulogne / fix_permissions.py
Created January 16, 2019 06:25 — forked from magopian/fix_permissions.py
Django admin command to "fix permissions" (create them properly for proxy models). This is needed because of the following bug in Django (not fixed as of 1.6): https://code.djangoproject.com/ticket/11154
# -*- coding: utf-8 -*-
"""Add permissions for proxy model.
This is needed because of the bug https://code.djangoproject.com/ticket/11154
in Django (as of 1.6, it's not fixed).
When a permission is created for a proxy model, it actually creates if for it's
base model app_label (eg: for "article" instead of "about", for the About proxy
model).
@tboulogne
tboulogne / cdn-baseurl.php
Created December 31, 2018 10:59 — forked from frankiejarrett/cdn-baseurl.php
Filter the media uploads baseurl to point to a CDN
<?php
// Turn ON: $ wp option update cdn_baseurl https://abc123.cloudfront.net/wp-content/uploads
// Turn OFF: $ wp option delete cdn_baseurl
$cdn_baseurl = get_option( 'cdn_baseurl' );
if ( ! $cdn_baseurl ) {
return;
@tboulogne
tboulogne / cdn77-uri-rewrite.php
Created December 30, 2018 23:54 — forked from ajbevau/cdn77-uri-rewrite.php
WordPress Must Use Plugin which rewrites asset URI's to CDN77.
<?php
/**
* WordPress Must Use Plugin which rewrites asset URI's to CDN77.
*
* This is largely inspired my Mark Jaquith's WP_Stack CDN plugin
* https://github.com/markjaquith/WP-Stack/blob/master/WordPress-Dropins/wp-stack-cdn.php
*
* Options that should be set in wp-config.php
* CDN77_ENABLE - Set to TRUE if the CDN should be enabled
* CDN77_DOMAIN - The domain name for the CDN77 subdomain in use
/**
* Change the URL for static files to use the CDN
*/
if (FIT_USE_CDN)
{
add_filter('theme_root_uri', 'fit_cdn_rewrite', 99, 1);
add_filter('wp_get_attachment_image_src', 'fit_cdn_image_rewrite', 99, 1);
add_filter('the_content', 'fit_cdn_content_rewrite', 99, 1);
}
@tboulogne
tboulogne / gist:d69d386cd9bf4a319c5bfde18ad7723d
Created November 25, 2018 08:30
Generate iCal in Django
from icalendar import Calendar, Event
def ical(request, course_id):
try:
# see if the course exists
c = course.objects.get(id=course_id)
except course.DoesNotExist:
# redirect to search page in future
raise Http404
postCalendarItems = c.post_set.all()
/* Woocommerce Styles */
/*
A couple things to note...
1. This code was written very specifically for my base child theme so it might not work out of the box with every theme.
I have it here mostly to share with anyone who might be looking to do the same thing I was.
2. I generally add my WooCommerce CSS overrides to a custom-woo.css file then use wp_enqueue_style() to call it
so that it enqueues after the default WooCommerce Stylesheets