Skip to content

Instantly share code, notes, and snippets.

View pecigonzalo's full-sized avatar
🌊

Gonzalo Peci pecigonzalo

🌊
View GitHub Profile
@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
@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
# initialization file (not found)
@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
@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 / 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 / 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 / jessie-base.preseed
Created April 21, 2017 11:49 — forked from pgaskin/jessie-base.preseed
A preseed file for a minimal Debian Jessie installation
# How to run
# In the folder with these files
# sudo python -m SimpleHTTPServer 80
#
# Update the ip at the bottom of this file to the output of
# hostname -I
# This is your ip
#
# Start debian cd
# Press esc on menu
@pecigonzalo
pecigonzalo / bastion
Last active November 13, 2019 18:02
SSH bastion lookup
#!/usr/bin/env bash
set -e # exit on command errors
set -o nounset # abort on unbound variable
set -o pipefail # capture fail exit codes in piped commands
# set -x
# Config:
# ~/.ssh/config
# Host i-*
@pecigonzalo
pecigonzalo / ecs-run
Created April 28, 2017 10:59 — forked from vcastellm/ecs-run
Run task and wait for result in AWS ECS
#!/usr/bin/env bash
set -e
function usage() {
set -e
cat <<EOM
##### ecs-run #####
Simple script for running tasks on Amazon Elastic Container Service
One of the following is required:
Required arguments: