Skip to content

Instantly share code, notes, and snippets.

View fabiomontefuscolo's full-sized avatar

Fabio Montefuscolo fabiomontefuscolo

View GitHub Profile
@fabiomontefuscolo
fabiomontefuscolo / search_inspect.js
Last active June 15, 2020 22:59
Search and inspect helper
Object.defineProperty(
Object.prototype, 'inspect_walk', {
enumerable: false,
value: function (compare, callback) {
var visited = [];
var stack = [{
'path' : [],
'key' : '',
'value' : this
@fabiomontefuscolo
fabiomontefuscolo / backup-uploads.sh
Last active November 14, 2016 19:52
Small script to backup wordpress uploads. It creates a full tar in monday and incremental tars until the end of week.
#!/bin/bash
set -e
BACKUP_FOLDER='/srv/backups/uploads'
SOURCE_FOLDER='/var/www/awesomesite/wp-content/uploads'
PREFIX_NAME='awesomesite'
# -----------------------------------------------------
woy=`date +%W` # muda toda segunda-feira
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=php_cache:100m inactive=1d;
fastcgi_cache_key "$scheme://$host$request_uri";
server {
listen 80;
server_name montefuscolo.com.br www.montefuscolo.com.br;
return 301 https://montefuscolo.com.br$request_uri;
}
server {
#!/bin/bash
S3CMD='/opt/s3cmd/bin/s3cmd'
BUCKET='bucketname'
PREFIX='/any-placeholder'
BACKUP_FOLDER=/var/backup/mysql
BACKUP_FILE_NAME="`date +%Y%m%d`-%s.sql"
BACKUP_EXPIRY_DAYS=180
MYSQL_USR='root'
@fabiomontefuscolo
fabiomontefuscolo / backup-postgis.sh
Created July 5, 2016 12:20
Cron to backup Postgres databases from docker
#!/bin/bash
BACKUP_FOLDER=/data/sql-backup
BACKUP_FILE_NAME="`date +%Y%m%d`.sql.gz"
EXEC="docker exec -u postgres -i postgis"
databases=$(
$EXEC psql -l -A -t | awk -F\| '!/^(postgres|template)/{ print $1 }'
)
Object.defineProperty(Element.prototype, 'outerHeight', {
'get': function(){
var height = this.clientHeight;
var computedStyle = window.getComputedStyle(this);
height += parseInt(computedStyle.marginTop, 10);
height += parseInt(computedStyle.marginBottom, 10);
height += parseInt(computedStyle.borderTopWidth, 10);
height += parseInt(computedStyle.borderBottomWidth, 10);
return height;
}
(function ($) {
$.shuffle = function shuffle(array) {
if(!array) {
if ($.isArray(this)) {
array = this
} else {
array = $(this);
}
}
@fabiomontefuscolo
fabiomontefuscolo / utils.php
Last active October 30, 2016 05:12
Some functions to help on development
<?php
/**
* Given some parameters, return the first valid one
* Ex.:
* echo first_of(false, 0, null, 'is valid', 'me too');
* >> is_valid
*
* @param type|mixed any param
* @return type|mixed the first valid param
*/
@fabiomontefuscolo
fabiomontefuscolo / git-pull-webhook.sh
Created December 3, 2015 09:36
Script that update git repositories and run make build when someone access port 1500
#!/bin/bash
PORT=1500
PROGRAM=$(readlink -f $0)
GIT=$(which git)
NCAT=$(which ncat)
MAKE=$(which make)
SLACK_URL="https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX"
SLACK_BOT_NAME="Tripa-Seca"
@fabiomontefuscolo
fabiomontefuscolo / wordpress.conf
Last active September 25, 2015 03:28
Simple nginx conf to Wordpress
server {
listen 80;
server_name example.com;
root /srv/www/wordpress-ms;
gzip on;
gzip_disable "msie6";
gzip_min_length 1100;
gzip_buffers 16 8k;