Skip to content

Instantly share code, notes, and snippets.

View andregoncalves's full-sized avatar
🏠
Working from home

Andre Goncalves andregoncalves

🏠
Working from home
View GitHub Profile
@andregoncalves
andregoncalves / form-submit-tracking-1.js
Created October 26, 2012 18:09
Analytics form submit tracking 1
$("form").on('submit', function(e) {
if (_gaq)
_gaq.push(['_trackEvent', 'my category', 'my action']);
return true;
});
@andregoncalves
andregoncalves / form-submit-tracking-1.js
Created October 27, 2012 10:35
Analytics form submit tracking 2
$("form").on('submit', function(e) {
var form = this;
if (_gaq) {
e.preventDefault();
_gaq.push(['_trackEvent', 'my category', 'my action']);
setTimeout(function() { form.submit(); }, 100);
return false;
}
#!/usr/bin/env bash
sudo rm -rf ~/chef
mkdir ~/chef
cd ~/chef
chef_binary=/usr/local/bin/chef-solo
# Are we on a vanilla system?
if ! test -f "$chef_binary"; then
export DEBIAN_FRONTEND=noninteractive
# Upgrade headlessly (this is only safe-ish on vanilla systems)
Can you please answer the following questions so we can assess the project,
and judge if we would be a good match?
1. Is this a new project, or is this for an existing website or application?
- This is a project for a completely new site or application
- This is a project to update an existing site or application
2. Which of the following areas do you need help with?
Hi Bob,
Just wanted to inform you that we have not yet received payment of
invoice ####-##.
I'm sure you must have mistakenly overlooked this. I've included
a copy of the invoice for your convenience.
If payment has already been sent, please disregard this email. Do
not hesitate to contact me if you have any questions.
@andregoncalves
andregoncalves / router.php
Created June 23, 2014 18:22
Wordpress router.php for standalone server
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
set_include_path(get_include_path().':'.__DIR__);
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
$path = rtrim($path,'/').'/index.php';
if(strpos($path,'.php') === false) return false;
@andregoncalves
andregoncalves / check_disk_space.sh
Created May 19, 2016 14:36
Cron free disk space monitoring and alert
#!/bin/bash
# simple cron script to check disk space and send notifications
#cd $(dirname $0) && pwd
if [ "$(cd $(dirname $0) && pwd)" != "/etc/cron.hourly" ]; then
echo "Warning: script should be located in /etc/cron.hourly for periodic checks"
fi
CONFIG_FILE=/etc/check-disk-space.conf
@andregoncalves
andregoncalves / mail_error_log.sh
Last active May 19, 2016 14:38
Cron script to email apache/nginx daily error logs
#/bin/bash
# parse error logs on your server and send you daily updates to email
# configure options
EMAIL=<...>
WORKDIR="/root"
TAIL=5 # number of entries to send
IGNORE="/backup" # path to ignore
LOG_FILENAME = "error.log"
@andregoncalves
andregoncalves / router.php
Created May 19, 2016 14:41
.htaccess like router file for php dev web server
<?php
// php -S localhost:3000 router.php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
set_include_path(get_include_path().':'.__DIR__);
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')