Skip to content

Instantly share code, notes, and snippets.

View pecigonzalo's full-sized avatar
🌊

Gonzalo Peci pecigonzalo

🌊
View GitHub Profile
@pecigonzalo
pecigonzalo / backup.ps1
Created April 11, 2017 14:37
Trigger action on external disk connected
# The targetpartition to backup to, obtain it with:
# Get-WmiObject Win32_LogicalDisk | Select-Object DeviceID, VolumeSerialNumber
$TargetPartition = ''
# Notification settings
$NotifyFrom = ''
$NotifyTo = ''
$SmtpServer = ''
$SmtpPort = '587'
$SmtpPass = ''
@pecigonzalo
pecigonzalo / gitlog.sh
Created February 15, 2017 09:24
Git Log Nice
git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
@pecigonzalo
pecigonzalo / docker-swarm-cluster.sh
Last active June 24, 2019 12:04
Docker swarm creation script
#!/bin/bash
MANAGER=${1:-2}
WORKER=${2:-3}
#=========================
# Creating cluster members
#=========================
echo "### Creating $MANAGER managers"
echo "### Creating $WORKER workers"
@pecigonzalo
pecigonzalo / statistics.sql
Created September 12, 2016 13:08 — forked from ruckus/statistics.sql
Postgres statistics queries
** Find commmonly accessed tables and their use of indexes:
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct;
Returns output like:
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct
----------------------+--------------+---------------+------------------------
schema_migrations | 817 | 0 | 0.00000000000000000000
user_device_photos | 349 | 0 | 0.00000000000000000000
# initialization file (not found)
@pecigonzalo
pecigonzalo / ssh-copy-id.sh
Created December 14, 2015 03:53
Copy SSH IDs to remote host
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
if [ "-i" = "$1" ]; then
@pecigonzalo
pecigonzalo / tomcat.sh
Created December 14, 2015 03:42
Tomcat Init Script (Centos/RHEL/Fedora)
#!/bin/bash
#
# tomcatd Start Tomcat server
#
# chkconfig: - 80 20
# description: Tomcat Web Application Server
#
# processname: tomcat
# pidfile: /var/run/tomcat.pid