Skip to content

Instantly share code, notes, and snippets.

View oprietop's full-sized avatar
🤘
Forking

Oscar Prieto oprietop

🤘
Forking
  • NERV
  • Court Of The Crimson King
View GitHub Profile
@oprietop
oprietop / tcpdump_docker.md
Last active February 16, 2022 14:47
run tcdump on a docker container

Replace 6dc76f8e2cb1 with target container to sniff

docker run -it --rm --net container:6dc76f8e2cb1 nicolaka/netshoot tcpdump -s0 -qA
@oprietop
oprietop / isp_atmega32u4_flashing.md
Last active February 3, 2022 18:21
Example commands for preparing fuses, flashing a bootlooader and firmware for promicro using another promicro as an ISP.
@oprietop
oprietop / arch_inst.sh
Last active December 22, 2022 11:22
Arch Linux Installation script (UEFI, LVM, LUKS)
#!/usr/bin/bash
# This script is meant to be used with the Arch Linux ISO under a network connection.
set -e
set -u
LUKS_PASS=luks_pass
DISK=sda
TIMEZONE=Europe/Madrid
PACKAGES="base linux linux-firmware mkinitcpio lvm2 grub efibootmgr intel-ucode dhcpcd openssh inetutils docker zsh vim tmux git atop mc"
@oprietop
oprietop / wget.sh
Created July 22, 2021 19:16 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@oprietop
oprietop / env.go
Created July 8, 2021 12:41
Copy CI variables between projects on the same gitlab instance
package main
import (
"net/http"
"net/url"
"fmt"
"os"
"log"
"time"
"encoding/json"
@oprietop
oprietop / collectd-apachelog_centos8.sh
Last active June 16, 2021 13:26
Compiling an old collectd version with the apachelog plugin and other patches
#!/usr/bin/bash
# Used inside a centos:8 container:
# docker run -it --rm -v $(pwd):/mnt -w /mnt centos:8 bash
set -e
set -x
# Fix locales
dnf install -y glibc-langpack-en
# Install dev tools
dnf group install -y "Development Tools"
@oprietop
oprietop / Dockerfile
Last active February 17, 2021 18:32
wetty with sudo Dockerfile
FROM node:current-alpine as builder
RUN apk add --no-cache build-base python git && \
git clone https://github.com/butlerx/wetty /usr/src/app
WORKDIR /usr/src/app
RUN yarn && \
yarn build && \
yarn install --production --ignore-scripts --prefer-offline
@oprietop
oprietop / grafana_sqlite_to_mysql.md
Last active February 5, 2021 07:21
Notes for cleaning and moving a sqlite database to mysql

Notes for converting grafana database from sqlite to mysql

Oneliner to count the size of each table

for t in `sqlite3 grafana.db ".tables"`; do echo -n "$t "; echo "select count(*) from $t" | sqlite3 grafana.db ;done

Database Cleaning

echo 'delete from dashboard_version; vacuum;' | sqlite3 grafana.db
echo 'delete from user_auth_token; vacuum;' | sqlite3 grafana.db
echo 'delete from annotation; vacuum;' | sqlite3 grafana.db
@oprietop
oprietop / kapacitor.sh
Created December 14, 2020 06:46
Playing with the kapacipor API via curl.
#!/bin/bash
# https://docs.influxdata.com/kapacitor/v1.5/working/api/
KAPACITOR_URL=${KAPACITOR_URL-http://localhost:9092}
read -r -d '' MLIST <<'EOF'
container_cpu_usage_seconds_total
container_fs_limit_bytes
container_fs_reads_bytes_total
container_fs_reads_total
@oprietop
oprietop / jenkins_run.sh
Created November 25, 2020 16:33
Run arbitrary code on a jenkis worker and get the result via console.
#!/bin/sh
JENKINS_ROOT=https://jenkins
JENKINS_USER=xxxxx
JENKINS_PASS=xxxxx
PROXY=proxy:8080
SCRIPT=$(cat <<'EOF'
args='''
hostname
id