Skip to content

Instantly share code, notes, and snippets.

@rafpro
rafpro / README.md
Created July 22, 2020 03:43 — forked from mosquito/README.md
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/[email protected]. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
Requires=docker.service
After=docker.service
@rafpro
rafpro / deploy.sh
Created July 2, 2020 02:30 — forked from BenSampo/deploy.sh
Laravel deploy script
# Change to the project directory
cd /home/forge/domain.com
# Turn on maintenance mode
php artisan down
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin master
@rafpro
rafpro / Inflect.php
Last active April 3, 2020 13:54 — forked from tbrianjones/Inflect.php
A PHP Class for converting English words between Singular and Plural.
<?php
// original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/
// more irregular uncountable nouns: http://ieltsliz.com/uncountable-nouns-word-list/
/*
The MIT License (MIT)
Copyright (c) 2015
@rafpro
rafpro / README.md
Created March 18, 2020 10:29 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
@rafpro
rafpro / lamp.sh
Created March 17, 2020 10:58 — forked from aamnah/lamp.sh
Bash script to install Apache, MySQL and PHP as well as PHPMyAdmin and some tweaks. For Debian and Ubuntu. To run, copy the script to the server and run ``bash lamp.sh``
#!/bin/sh
#######################################
# Bash script to install an AMP stack and PHPMyAdmin plus tweaks. For Debian based systems.
# Written by @AamnahAkram from http://aamnah.com
# In case of any errors (e.g. MySQL) just re-run the script. Nothing will be re-installed except for the packages with errors.
#######################################
#COLORS
@rafpro
rafpro / gist:1341db760d094713793bf660ed73c022
Created March 6, 2020 14:53 — forked from crypticsoft/gist:3932aebf97414824ebd2
WP backup shell script using wp-cli and aws-cli
#!/bin/bash -e
export THEDATE=`date +%d%m%y%H%M`
export THETHEME=`wp --allow-root theme list --status=active --field=name`
export THESITE=`wp --allow-root option get siteurl | awk -F/ '{print $3}'`
export THEBACKUPS="/usr/share/nginx/backups"
export THEBASEPATH="/usr/share/nginx/www"
export THEBUCKET="bucket-name-goes-here"
# backup the db
wp --allow-root db export - | gzip > ${THEBACKUPS}/dbbackup_${THEDATE}.sql.gz
/**
* nearby.js
* http://www.codrops.com
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2018, Codrops
* http://www.codrops.com
*/
@rafpro
rafpro / fold_ideas.md
Created January 25, 2020 10:53 — forked from CMCDragonkai/fold_ideas.md
Haskell: Foldl vs Foldr

Foldl vs Foldr

I like to call foldr as "fold from the right", while foldl is "fold from the left".

<?php
/**
* Plugin Name: EDD Heartbeat API test plugin
* Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard
*/
// Load the heartbeat JS
function edd_heartbeat_enqueue( $hook_suffix ) {
// Make sure the JS part of the Heartbeat API is loaded.
wp_enqueue_script( 'heartbeat' );
@rafpro
rafpro / _subscriptions.md
Created January 17, 2020 06:15 — forked from thenbrent/_subscriptions.md
WooCommerce Subscriptions REST API Endpoint Documentation (fork of https://gist.github.com/mattallan/fd52629eae293540c6d8)

Subscriptions

This section lists all API that can be used to create, edit or otherwise manipulate subscriptions.

Subscription Properties

Attribute Type Description
id integer Subscription ID (post ID) read-only
order_number integer Order number read-only