Skip to content

Instantly share code, notes, and snippets.

View jpclipffel's full-sized avatar

JP. Clipffel jpclipffel

  • Switzerland
View GitHub Profile
@jpclipffel
jpclipffel / bash_flock.sh
Last active January 25, 2024 05:07
Bash flock example
#!/bin/bash
#
# Bash `flock` example.
# Works on: Linux, BSD
# Doesn't work on: MacOS
# The file which represent the lock.
LOCKFILE="`basename $0`.lock"
# Timeout in seconds.

ELK - Remote clusters example

How to setup an Elasticsearch remote clusters lab.

Docker compose

Notes:

  • Adapt the volumes definition
  • Run with docker-compose up
@jpclipffel
jpclipffel / delete_stale_pvc.sh
Last active February 4, 2021 15:31
Delete stale PVC
for pvc in $(kubectl get pvc | tail -n+2 | awk '{print $1}'); do
kubectl patch pvc ${pvc} -p '{"metadata":{"finalizers": []}}' --type=merge
kubectl delete pvc ${pvc}
done
@jpclipffel
jpclipffel / appstore.py
Created August 21, 2020 11:25
A simple App Store scrapper example
import sys
import requests
from lxml import etree
def get_app_info(app_id, app_name, country='lu', lang='fr-fr'):
'''Fetches an application page and returns a set of contextual information.
:param str app_id: Application ID
:param str app_name: Application name
@jpclipffel
jpclipffel / Ansible - Helm management.md
Created July 21, 2020 09:21
Manage Helm with Ansible

Ansible - Helm management

Get releases list

- name: Get all Helm releases
  shell: >
    helm list -o yaml
  register: _helm_releases

Python - argparse for Git-like CLI

Git uses a really nice command-oriented command line interface (doesn't know a better name). Bellow a script showing how this can be reproduced in Python using argparse.

Usage

Tested on Python3+.
The following commands and sub-commands are implemented:

  • foo
  • bar
  • complex
@jpclipffel
jpclipffel / README.md
Created November 19, 2019 12:44
Python and Brew on MacOS Catalina

Python and Brew on MacOS Catalina

Installation

  • Install Brew's OpenSSL: brew install openssl
  • Install Brew's Python3: brew install python3

Configure

Add the following configuration to a ~/.bashrc or ~/.zshrc:

Python - Multiprocessing managers with class

Demonstrate how to create a multiprocessing's manager server exposing a class.

Proxies

from multiprocessing.managers import BaseProxy


class GeneratorProxy(BaseProxy):
    """Manager's proxy for generators.
@jpclipffel
jpclipffel / Splunk - Office365 parsing.md
Created March 11, 2019 08:09
Splunk - Office365 parsing

Splunk - Office365 parsing

How to re-parse Office365 logs collected from the application splunk_ta_o365.

Context

The add-on splunk_ta_o365 may sometimes produces multi-lines JSON events (ie. an event with several JSON objects separated by a new line). The following modification change the line breaker configuration.

Edit the line breaker configuration

Edit the file $SPLUNK_HOME/etc/apps/splunk_ta_o365/local/props.conf (create it if it doesn't exists) and add the following lines:

Splunk - Swift SAA JSON logs

How to ingest Swift SAA (Swift Alliance Access) logs in Splunk

SAA confguration

The SAA must be configured to:

  • forwards its logs through syslog
  • use the JSON (not formatted) format