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 / create_user.sql
Last active August 30, 2016 16:45
Create mysql user for app access
create user <user>@localhost;
set password for <user>@localhost = PASSWORD("xxx");
grant all privileges on wordpress_<app>.* to <user>@localhost identified by "xxx";
flush privileges;
@andregoncalves
andregoncalves / keybindings.json
Created August 22, 2016 12:29
vscode keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+t",
"command": "workbench.action.quickOpen"
},
{
"key": "cmd+p",
"command": "workbench.action.showAllSymbols"
},
@andregoncalves
andregoncalves / settings.json
Created August 22, 2016 12:28
vscode settings.json
// Place your settings in this file to overwrite the default settings
{
"editor.insertSpaces": false,
"editor.fontFamily": "Menlo, Monaco, Menlo, 'Courier New', monospace",
"editor.fontSize": 14,
"workbench.editor.enablePreviewFromQuickOpen": false,
"editor.fontSize": 12,
"editor.rulers": [120],
}
@andregoncalves
andregoncalves / php.json
Last active September 13, 2016 08:23
vscode php user snippets
{
"comment block": {
"prefix": "comment",
"body": [
"/* ",
" * --------------------------------------------------------------------",
" * ${title}",
" * --------------------------------------------------------------------",
" * ${description}",
" *",
@andregoncalves
andregoncalves / html.json
Last active December 29, 2016 16:13
vscode html user snippets
{
"html boilerplate": {
"prefix": "html",
"body": [
"<doctype html>",
"<head>",
"\t<meta charset=\"utf-8\">",
"\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">",
"\t<meta name=\"author\" content=\"Andre Goncalves\" />",
"\t<meta name=\"viewport\" content=\"width=device-width,minimum-scale=1\">",
@andregoncalves
andregoncalves / css.json
Last active November 24, 2016 17:19
vscode css user snippets
{
"boot": {
"prefix": "css",
"body": [
"/**",
" *",
" * Copyright 2016 Andre Goncalves. All rights reserved.",
" *",
"*/",
"",
@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) !== '/')
@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 / 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 / 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;