Skip to content

Instantly share code, notes, and snippets.

@rduque1
rduque1 / connect-docker-socket.sh
Created February 22, 2022 10:17
connect to docker socket api over tcp
# https://serverfault.com/questions/843296/how-to-expose-the-docker-api-over-tcp
ncat -lknvp 2375 -c "ncat -U /var/run/docker.sock"
@rduque1
rduque1 / data.sh
Created January 31, 2022 12:39
Download influxdb data per day in csv
start=$(date -d "-10 day" +%Y%m%d);
end=$(date -d"-1 day" +%Y%m%d);
while [[ $start -le $end ]];
do
tmpEnd=$(date -d"$start + 1 day" +"%Y%m%d");
echo $(date -d $start +%Y-%m-%d) $(date -d $tmpEnd +%Y-%m-%d);
docker run -it --rm \
--network asrm-202201_default \
influxdb:2.0-alpine influx query \
--host http://influxdb:8086 --token $TOKEN --org $ORG \
@rduque1
rduque1 / keynase.md
Created August 18, 2021 14:03
keybase.md

Keybase proof

I hereby claim:

  • I am rduque1 on github.
  • I am rduque (https://keybase.io/rduque) on keybase.
  • I have a public key ASDg8ZS6be0hPAukKONJvnaF-nUbVO3ICr7R_EQeqtUUvQo

To claim this, I am signing this object:

@rduque1
rduque1 / pearson-correlation.js
Created June 9, 2021 16:06 — forked from matt-west/pearson-correlation.js
Pearson Correlation (JavaScript)
/**
* @fileoverview Pearson correlation score algorithm.
* @author matt.west@kojilabs.com (Matt West)
* @license Copyright 2013 Matt West.
* Licensed under MIT (http://opensource.org/licenses/MIT).
*/
/**
* Calculate the person correlation score between two items in a dataset.
@rduque1
rduque1 / split_vcf.sh
Last active May 21, 2021 09:28
Split VCF by sample using AWK (assumes sample name contains numbers and ends with ".CEL"!!!)
#!/usr/bin/env bash
set -x
ls -l $1
filename=$1
if [ "$filename" == "*.vcf.gz" ]; then
gunzip $1
filename=${filename/'.gz'/''}
fi
if [ ! -f $filename ]; then
@rduque1
rduque1 / docker-healthcheck.md
Created March 16, 2021 13:27 — forked from shotgunner/docker-healthcheck.md
How to view docker healthcheck logs?

How to see healthcheck Logs ?

Use docker inspect is different in swarm mode and normal mode if you wnat to use it in swarm mode:

  • Manager nodes: use this command for services. (but if you want to see healthceck logs of specific container see worker nodes section):

    • docker inspect --format "{{json .Spec.TaskTemplate.ContainerSpec.Healthcheck }}" hinava_dashboard |jq
  • Worker nodes: you should use complete name of the container that completed with <tab> key

  • docker inspect hinava_filebeat.1.umvobmm9wrjdz1b08y5jibvl2 | grep -B 10 -A 10 "health"
@rduque1
rduque1 / delete-s3-bucket.sh
Created March 13, 2021 10:07
AWS s3 delete bucket
aws s3 rb s3://bucket-name --force
@rduque1
rduque1 / iptables.sh
Created February 23, 2021 12:50 — forked from Tristor/iptables.sh
Simple IPtables script for an OpenVPN server
#!/bin/bash
# Flushing all rules
iptables -F FORWARD
iptables -F INPUT
iptables -F OUTPUT
iptables -X
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
@rduque1
rduque1 / vcf-to-23andme.sh
Last active December 3, 2020 10:27
vcf file to 23andme format
// https://stackoverflow.com/questions/8009664/how-to-split-a-delimited-string-into-an-array-in-awk
awk '
BEGIN {
split("X,Y,MT", parts, ",");
for (i in parts) chrs[parts[i]]=""
}
{
gt=-1;
split($10, a, ":");
split($5, alts, ",");
@rduque1
rduque1 / create_loop_delete.sh
Last active October 4, 2020 15:19 — forked from nashjain/delete_all_aws_s3_object_versions.sh
Let's assume you backup a file every hour on AWS S3 and you want to clean up versions that are older than a week. However for the older versions, you want to leave one version per day just in case if you need them. Following script does that for you.
for id in `(cat toDel.txt)`; do echo "aws --profile wasabi s3 --endpoint-url=<endpoint> rm --recursive s3://<bucket>/id_$id/"; done