Skip to content

Instantly share code, notes, and snippets.

View chaddupuis's full-sized avatar

Chad Dupuis chaddupuis

View GitHub Profile
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Postgres Database
gem 'pg'
# Twitter API
gem 'twitter'
@chaddupuis
chaddupuis / woo-to-processwire-urls.php
Created December 21, 2022 18:44
Woocommerce WP REST Api Transfer to Processwire Site
<?php namespace ProcessWire;
// Using the Woocommerce/WP REST API and bootstrapping a processwire site from the script,
// build a csv (to be imported into a processwire link rewrite/redirect module) to ensure
// no dead links after site migrations from woocommerce to processwire.
require('/yourpwinstall/wire/core/ProcessWire.php');
$st = new ProcessWire('/your/site/location/', 'https://yoururl.yours');
@chaddupuis
chaddupuis / wordpress-xml-migration-to-processwire.php
Created December 21, 2022 18:48
Wordpress XML Dump w/Images and WP Rest Api - Content Migration to Processwire
<?php namespace ProcessWire;
// Uses a bootstrapped processwire site from a php script to read in
// both an xml export with images and talk to existing live wp site
// via Rest API (json output) to move all content and images over to new site.
require('/your/location/wire/core/ProcessWire.php');
$bl = new ProcessWire('/your/location/', 'https://your-site.com/');
// Read WP XML Export (with images from plugin)
$myposts = simplexml_load_file('your-wp-xml-dump.xml');
@chaddupuis
chaddupuis / processwire-shippingeasy-foxycart-api-integration.php
Created December 21, 2022 18:54
Processwire and Foxycart Integration with ShippingEasy Labels and Status Management
<?php namespace ProcessWire {
// Processwire Store Management with Foxycart (from JSON webhook) and ShippingEasy (API).
// Manages order status and sends customer data to shipping easy for label printing via dashboard.
require_once('/your/pw-site.com/wire/core/ProcessWire.php');
$st = new ProcessWire('/your/pw-site.com/', 'https://pw-site.com/');
} // END PW namespace
@chaddupuis
chaddupuis / backup-borg-to-hetzner-storage.sh
Created December 21, 2022 18:58
Borg Backup Bash Script to Hetzner Storage Box
#!/bin/bash
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
## Backup websites and related files along with databases with borg to a storage box on hetzner.
## borg variables
## Must use borg >1.1 on deb 9 $ apt -t stretch-backports install borg-backup
export BORG_RSH="ssh -i /your/key"
export BORG_PASSPHRASE="yourpassphrase"
LOG="/var/log/borg/backup.log"
BACKUP_USER="hetzneruser"
@chaddupuis
chaddupuis / processwire-google-merchant-csv.php
Created December 21, 2022 19:00
Google Merchant CSV Creation from Processwire - For Inclusion in Google Shopping
<?php namespace ProcessWire;
require('/var/www/yourpw.com/wire/core/ProcessWire.php');
$st = new ProcessWire('/var/www/yourpw.com/', 'https://yourpw.com/');
// 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;
@chaddupuis
chaddupuis / apt-update-upgrade.yml
Created December 21, 2022 19:03
Basic Ansible - APT Upgrade
---
- hosts: mytargets
become: true
tasks:
- name: update apt repo and cache
apt:
upgrade=dist
update_cache=yes
force_apt_get=yes
cache_valid_time=3600
@chaddupuis
chaddupuis / create-products-from-csv.php
Created December 21, 2022 19:07
Processwire CLI - Example Processing a CSV to Processwire Fields
<?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
// (https://processwire.com/blog/posts/multi-instance-pw3/).
require('/var/www/dev.dev.com/wire/core/ProcessWire.php');
$st = new ProcessWire('/var/www/dev.dev.com/', 'https://dev.dev.com/');
@chaddupuis
chaddupuis / bash_profile.sh
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
chaddupuis / load_remote_images.py
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 django.core.management.base import BaseCommand
import time
from PIL import Image
from io import BytesIO
from django.core.files.base import ContentFile