Skip to content

Instantly share code, notes, and snippets.

View bactisme's full-sized avatar

Baptiste M. bactisme

View GitHub Profile
@bactisme
bactisme / extractMetaFAQ.gs
Last active June 7, 2023 12:41
Google Sheet formula to extract a page FAQ description
// ADD CHEERIO LIBRARY
// Script ID : 1ReeQ6WO8kKNxoaA_O0XEQ589cIrRvEBA9qcWpNqdOP17i47u6N9M5Xh0
function extractMetaFAQ(url) {
// Récupérez le flux RSS
var response = UrlFetchApp.fetch(url);
var html = response.getContentText();
const $ = Cheerio.load(html);
@bactisme
bactisme / shelly-control.py
Last active December 2, 2022 21:16
Control Shelly Plug via a simple script
#!usr/bin/python
import ShellyPy
import sys
from pprint import pprint
if len(sys.argv) != 3:
print("Syntax: [IP] [on/off]\nExample : python3.9 main.py 192.168.1.100 on")
sys.exit(0)
IP = sys.argv[1]
@bactisme
bactisme / google-sheet-to-google-sheet-apps-script.gs
Created October 20, 2022 07:25
Configure the first function. Create a sketch of a button > right click > assign a script > copyPnL in the box > Enjoy
function copyPnL(){
var uri = "https://docs.google.com/spreadsheets/d/1pNObB_ETC";
var sheetname = "Sheet 1";
var range = "A1:BS500";
var offsetx = 1;
var offsety = 1;
COPYSHEET(uri, sheetname, range, offsetx, offsety);
}
@bactisme
bactisme / GA4-to-Google-Sheet.gs
Last active October 7, 2022 08:40
GA4 to Google Sheet - Apps script. Configurable Reports
/**
== How to use ==
0/
Paste this code in Extensions > Apps Script
In Services, search and add "AnalyticsData" and "AnalyticsReportin"
1/ Create a sheet called "Reports configuration"
* Paste in A1 the following lines :
Configuration Options
@bactisme
bactisme / plausible_url_call.gs
Last active April 25, 2022 15:18
Fetch data from plausible instance for an URL in Google Sheet
function PLAUSIBLE(url, period, fields) {
/**
* This function call plausible API, and can be use from Google Sheet
* url : The full url to the page
* period : control the period. Possible value : "day" (today, default), "6mo", "12mo", "30d", "7d", or "custom&date=2022-04-22,2022-04-22".
* fields : by default "visitors,visits,pageviews". A coma separated list of field returned. Can also be bounce_rate, visit_duration
*
* full doc : https://plausible.io/docs/stats-api#filtering
*/
/**
* Unpivot a pivot table of any size.
* All credit to https://gist.github.com/philippchistyakov/57390ec98dcaea4502fabc5a32242b3a
*
* @param {A1:D30} data The pivot table.
* @param {1} fixColumns Number of columns, after which pivoted values begin. Default 1.
* @param {1} fixRows Number of rows (1 or 2), after which pivoted values begin. Default 1.
* @param {"city"} titlePivot The title of horizontal pivot values. Default "column".
* @param {"distance"[,...]} titleValue The title of pivot table values. Default "value".
@bactisme
bactisme / docker-compose-statsd-grafana-graphite
Created July 3, 2020 15:18
Don't forget to edit schema file
version: '2'
services:
grafana_graphite:
build: .
image: kamon/grafana_graphite
container_name: kamon-grafana-dashboard
ports:
- '80:80'
- '81:81'
- '8125:8125/udp'
@bactisme
bactisme / QuickTopNGNIXRequest.py
Last active April 7, 2022 04:11
Show a sorted table with path count, like ngxtop. Usage tail -f /var/log/nginx/access.log | /root/mynginx.py
#!/usr/bin/python
# charset: utf8
import sys
import re
import curses
from threading import Thread
import operator
table_count = {}
@bactisme
bactisme / capture-es-traffic.sh
Created March 3, 2017 10:40
Capture X seconds of elasticsearch traffic
#!/bin/bash
SECONDS=20
OUTPUT=/root/es_traffic.txt
timeout $SECONDS tcpdump -A -nn -s 0 'tcp dst port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo > $OUTPUT
@bactisme
bactisme / mount-all-promox-thinlvm-disks.sh
Last active February 10, 2017 15:44
On a proxmox 4.x environnement, this script look for vm and mount their disk on a host mount point
#!/bin/bash
# On proxmox 4.x, with a thinlvm setup, mount all running vm disk
BASE=/mnt
LVM_BASE=/dev/pve
#VMS=$(pct list|grep "running"|cut -d' ' -f1)
VMS=$(pct list|grep -v "VMID"|cut -d' ' -f1)