Skip to content

Instantly share code, notes, and snippets.

View pecigonzalo's full-sized avatar
🌊

Gonzalo Peci pecigonzalo

🌊
View GitHub Profile
@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 / 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 / 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 / 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:
@pecigonzalo
pecigonzalo / sns_example.json
Created June 12, 2017 14:33
Example SNS event
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:us-east-1:123456789123:AutoScalingNotifications:00000000-0000-0000-0000-000000000000",
"Sns": {
"Type": "Notification",
"MessageId": "00000000-0000-0000-0000-000000000000",
"TopicArn": "arn:aws:sns:us-east-1:123456789:AutoScalingNotifications",
# initialization file (not found)
@pecigonzalo
pecigonzalo / ECSDynamicHostPort.go
Created August 10, 2017 16:05 — forked from IngmarStein/ECSDynamicHostPort.go
Get dynamically mapped host port from within ECS container
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
"os"
"bufio"
FROM ubuntu:bionic
LABEL version="0.1"
LABEL description="A simple PHP 7.2 Server"
# RUN apk update \
# && apk -y --no-install-recommends install php-memcached php7.3-mysql php-xdebug php7.3-gd \
# && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
ENV TERM=linux