Skip to content

Instantly share code, notes, and snippets.

View webrgp's full-sized avatar
💻
Turning coffee into code

Rodrigo Passos webrgp

💻
Turning coffee into code
View GitHub Profile
@webrgp
webrgp / error_log_var_dump.php
Created August 15, 2012 14:16
PHP Error Log var_dump
ob_start();
var_dump($x);
$contents = ob_get_contents();
ob_end_clean();
error_log($contents);
@webrgp
webrgp / .htaccess
Last active December 10, 2015 05:38
.htaccess file
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache config if possible
# httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
chore: add Oyster build script
docs: explain hat wobble
feat: add beta sequence
fix: remove broken confirmation message
refactor: share logic between 4d3d3d3 and flarhgunnstow
style: convert tabs to spaces
test: ensure Tayne retains clothing
@webrgp
webrgp / trace.py
Last active August 29, 2015 14:27
import sys
import subprocess
import re
# REGULAR EXPRESSIONS
# (?=foo) Lookahead
# (?<=foo) Lookbehind
# (?!foo) Negative Lookahead
# (?<!foo) Negative Lookbehind
# ------------------------------------------------------------
# Many techniques here are taken from html5 boilerplate
# https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess
# ------------------------------------------------------------
# ------------------------------------------------------------
# MANAGE UPDATES & SITE OFFLINE
# Update and uncomment these rules when we need to work on the site
# while serving an offline message to visitors. Add permitted IPs as needed.
@webrgp
webrgp / pre-commit
Created September 20, 2017 16:20
Add DB dump to git's pre-commit hook
#!/bin/bash
DBUSER="root"
DBPASS="root"
DB="DB_NAME"
SCHEMAPATH="DBSchema"
/Applications/MAMP/Library/bin/mysqldump -u $DBUSER -p$DBPASS $DB > $SCHEMAPATH/$DB.sql
git add $SCHEMAPATH/$DB.sql
exit 0
@webrgp
webrgp / amp_db_dump.sh
Created October 16, 2017 15:39
Dump databases from MAMP
# based on https://gist.github.com/salcode/9142815
for I in $(/Applications/MAMP/Library/bin/mysql -u root -proot -e 'show databases' -s --skip-column-names); do /Applications/MAMP/Library/bin/mysqldump -u root -proot $I > "$I.sql"; done
@webrgp
webrgp / DOUbuntuCraftSetup.sh
Created October 25, 2017 20:32
CraftCMS server setup script with Digital Ocean / Laravel Forge
#!/bin/bash
##############################################################
# #
# Digital Ocean / Forge Recipe for CraftCMS websites #
# #
#============================================================#
# #
# Assumptions: #
# #
# - Ubuntu 16.04 Digital Ocean droplet, created by Forge #
@webrgp
webrgp / Nginx.conf
Created June 26, 2019 18:09
NGINX Security configs
add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload;";
add_header Feature-Policy "midi none;notifications none;push none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;";
<?php
use craft\test\TestSetup;
ini_set('date.timezone', 'UTC');
// Use the current installation of Craft
define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage');
define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates');
define('CRAFT_CONFIG_PATH', __DIR__ . '/_craft/config');