Skip to content

Instantly share code, notes, and snippets.

View guillaumemolter's full-sized avatar

Guillaume Molter guillaumemolter

View GitHub Profile
@guillaumemolter
guillaumemolter / nginx.default.conf
Last active November 6, 2018 20:32 — forked from sumardi/nginx.default.conf
Install PHP-FPM and Nginx on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
# Install Nginx and PHP-FPM
sudo yum install -y nginx php-fpm
# Install PHP extensions
sudo yum install -y php-mysql php-pdo \
php-mbstring php-cli \
php-imap php-gd php-xml php-openssl php-tokenizer
homestead $ vagrant destroy
==> homestead-7: Running triggers before destroy ...
==> homestead-7: Running trigger...
==> homestead-7: Backing up mysql database socket_wrench...
homestead-7: Running: inline script
==> homestead-7: Running trigger...
==> homestead-7: Backing up postgres database socket_wrench...
homestead-7: Running: inline script
==> homestead-7: Running trigger...
==> homestead-7: Backing up mysql database labpoint...
vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
==> homestead-7: Matching MAC address for NAT networking...
==> homestead-7: Checking if box 'laravel/homestead' version '7.0.0' is up to date...
==> homestead-7: Setting the name of the VM: homestead-7
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: hostonly
@guillaumemolter
guillaumemolter / tagging_topics_post_types.php
Last active February 24, 2019 13:33
Adding multisite taxonomy support to custom post types.
<?php
add_filter( 'hsph_plugin_tagging_topics_post_types', 'cchange_register_cpt_for_tagging' );
add_filter( 'hsph_plugin_tagging_cchange_issues_post_types', 'cchange_register_cpt_for_tagging' );
add_filter( 'hsph_plugin_tagging_cchange_subtopics_post_types', 'cchange_register_cpt_for_tagging' );
function cchange_register_cpt_for_tagging( $post_types = array() ) {
// Array of custom post types.
$cutom_post_types = array( 'cchange_article', 'cchange_issue', 'cchange_subtopic', 'cchange_bio', 'cchange_class', 'cchange_event' );
// Merging default post types and custom post types.
$post_types = array_merge( $post_types, $cutom_post_types );
@guillaumemolter
guillaumemolter / composer.json
Created August 5, 2019 18:32
WordPress management Composer workflow
{
"name": "",
"description": "",
"type": "project",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
@guillaumemolter
guillaumemolter / stats.php
Created July 15, 2019 18:07
WordPress multisite content freshness report
<?php
// To run it, place into web root and then `wp eval-file stats.php > ~/stats.csv`
global $wpdb;
$sites = $wpdb->get_results( "SELECT blog_id,domain,path,last_updated FROM {$wpdb->prefix}blogs",'ARRAY_A' );
foreach( $sites as &$site){
if($site['blog_id'] === '1'){
$post_table = $wpdb->prefix . 'posts';
} else {
$post_table = $wpdb->prefix . absint($site['blog_id']) . '_posts';
}
@guillaumemolter
guillaumemolter / git-cheat-sheet.md
Last active November 19, 2019 20:09
Git cheat sheet

Updated version: https://hsph.me/git

https://hsph.me/gitpr

Guillaume's Git cheat sheet

Because sometimes reseting the stach on the orgin of the local branch is confusing me :-)

Update local branch without loosing local commits and to prevent merge commits ( Merge branch 'master' into )

git pull --rebase origin master

@guillaumemolter
guillaumemolter / plugin.php
Last active January 30, 2020 16:04
ACF JSON Example
<?php
define( 'HSPH_PLUGIN_ASSETS_PATH', plugin_dir_path( __FILE__ ) . 'assets/' );
/**
* Saving ACF fields to assets folder.
*
* @return String The path where to save ACF json fields.
*/
add_filter(
@guillaumemolter
guillaumemolter / saml-response.cfm
Created August 10, 2015 14:24
Reading, decoding and inflating a SAML XML respone with Coldfusion
<!---
Reading, decoding and inflating a SAML XML respone with Coldfusion
This script is heavily inspired by the following posts:
- Ciarán Archer : https://flydillonfly.wordpress.com/2011/06/28/using-coldfusion-to-unzip-a-gzip-base64-string/
- Ryan Loda : http://www.coderanch.com/t/545270/java/java/Decode-SAML-Request
- Ben Nadel : http://www.bennadel.com/blog/1343-converting-a-base64-value-back-into-a-string-using-coldfusion.htm
--->