Skip to content

Instantly share code, notes, and snippets.

@pmoranga
pmoranga / puppet-firewall-docker.pp
Created February 8, 2016 23:55
Make puppetlabs-firewall works with docker smoothly
class my_fw::pre {
# Disable due to selective purges of firewallchain
# resources { "firewall":
# purge => true
# }
# Avoid removing Docker rules:
firewallchain { 'FORWARD:filter:IPv4':
purge => true,
@pmoranga
pmoranga / .pre-commit-config.yaml
Last active February 28, 2024 11:14 — forked from skwashd/pre-commit
Git pre-commit hook that blocks commits for files that contain swear words.
## Example using https://pre-commit.com/
repos:
- repo: local
hooks:
- id: dontship
name: DONTSHIP check - Block words
entry: '\bdie\b'
language: pygrep # https://pre-commit.com/#pygrep
types: [php]
@pmoranga
pmoranga / Checking your Raspberry Pi's view of its power supply.md
Created August 16, 2023 22:44 — forked from Paraphraser/Checking your Raspberry Pi's view of its power supply.md
Checking your Raspberry Pi's view of its power supply (sometimes it's not the wall-wart)

Checking your Raspberry Pi's view of its power supply

Sometimes it seems like the first (and sometimes only) advice you get offered for almost any problem with a Raspberry Pi is "check your power supply". You think something like:

"hey, I'm using an official power supply sold as being matched with my Pi so how can there be any problem?"

You look up the specs then stick a controlled load across your supply and confirm that it can deliver the required number of Watts.

Yet your problems persist…

@pmoranga
pmoranga / extract_windows_certificate_from_installer.md
Created September 16, 2016 09:54
Get the (readable) certificate from a windows executable (PE)

Get the (readable) certificate from a windows executable (PE)

From: http://web.fournier.nl/2013/10/get-readable-certificate-from-windows.html

I searched high and low for a simple (linux) solution on how to extract the certificate of an authenticode signed windows binary. I don't want to use wine, nor mono. This is what I came up with:

  • Extract the certificate with 7zip: 7z e setup.exe CERTIFICATE
  • remove the first 8 bytes: dd if=CERTIFICATE bs=1 skip=8 of=setup.exe.pkcs7
  • Read it: openssl pkcs7 -in setup.exe.pkcs7 -inform DER -print_certs -text
@pmoranga
pmoranga / MongoDB3-group-by-timestamp.js
Created February 21, 2023 15:59
On a mongo 3.6, group items by month from field with timestamp value
db.getCollection('Flights').aggregate([
{ $match: {"airport_code" : "AMS"}}
,{"$group": {"_id":
{ $dateToString: {
date: {"$add": [new Date(0),
{"$multiply": ["$created_at",1000 ]}
] } ,
format: "%Y-%m"}
}
, "count": {"$sum": 1}}}
@pmoranga
pmoranga / datadog-snmp-synology.yaml
Created May 25, 2020 07:44
Datadog SNMP configuration to collect Synology statistics. Should be put into `conf.d` folder. SNMP User should be created / enabled on Synology (RO access)
init_config:
mibs_folder: /mibs
profiles:
generic:
definition_file: _generic-host-resources.yaml
instances:
- ip_address: $REPLACE_WITH_SYNOLOGY_IP_ADDRESS
community_string: public
snmp_version: 2
@pmoranga
pmoranga / 01-pre-install.sh
Created July 8, 2022 21:17 — forked from xenophonf/01-pre-install.sh
K3s on Ubuntu 20.04 with root on encrypted ZFS
#!/bin/sh
# Run as user `ubuntu` from the Ubuntu Desktop installer's live environment.
sudo apt-add-repository universe
sudo apt update
passwd ubuntu
sudo apt install --yes openssh-server screen vim
ip addr show scope global | grep inet
@pmoranga
pmoranga / aws-check-reserved-instances.py
Last active November 20, 2021 19:03
AWS Reserved Report
#!/usr/bin/env python3
import boto3
import warnings
warnings.filterwarnings('ignore', category=UnicodeWarning)
def get_count_reserved_by_family_base(instances,instance_type,platform):
item = {}
total = 0
@pmoranga
pmoranga / traefik_deployment.yaml
Created May 3, 2021 21:40 — forked from guyromb/traefik_deployment.yaml
Traefik - Streaming Access Logs with JWT decoder using Filebeat
apiVersion: apps/v1
kind: Deployment
spec:
template:
metadata:
annotations:
co.elastic.logs/enabled: "true"
co.elastic.logs/processors.0.decode_json_fields.fields: message
co.elastic.logs/processors.0.decode_json_fields.target: ""
co.elastic.logs/processors.1.dissect.field: request_Authorization
kubectl get nodes -o custom-columns='NAME:.metadata.name,InternalIP:.status.addresses[?(@.type=="InternalIP")].address'