Skip to content

Instantly share code, notes, and snippets.

View sanfx's full-sized avatar

Sanjeev Kumar sanfx

  • London
  • 16:34 (UTC +01:00)
View GitHub Profile
sanfx /
Last active September 18, 2022 13:28 — forked from syndbg/
A small Python script, that fetches a YouTube playlist's videos titles and writes them to a file playlist.txt in the same directory. Usage? A legal backup against video deletion. You could always find the song if you know the song title before it got removed
# Dependencies:
# - Python==3.10
# - gdata-python3==2.0.18
# - google-api-python-client==1.2
sanfx /
Created February 19, 2022 15:20
mysql db back script this script is called periodically from jenkins, though you can just set cron job.
# in case the mysql db is located in docker container.
# For taking backup
datestamp=$(date +%d-%m-%y-%H-%M)
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
sanfx / gist:a928ad7c27ee1eb69c450cec282fc936
Created November 22, 2020 23:02
nextcloud error on try to logining in
This file has been truncated, but you can view the full file.
{"reqId":"yY249L9bBmlx6xeJ6rmV","level":3,"time":"2020-11-22T22:53:47+00:00","remoteAddr":"","user":"skumar","app":"PHP","method":"GET","url":"/nextcloud/index.php/apps/dashboard/","message":{"Exception":"Error","Message":"file_put_contents(/media/storage/data/appdata_ocr2fw9pzn5a/css/icons/icons-vars.css): failed to open stream: No such file or directory at /var/www/html/nextcloud/lib/private/Files/Storage/Local.php#277","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"file_put_contents(/media/storage/data/appdata_ocr2fw9pzn5a/css/icons/icons-vars.css): failed to open stream: No such file or directory","/var/www/html/nextcloud/lib/private/Files/Storage/Local.php",277,{"path":"appdata_ocr2fw9pzn5a/css/icons/icons-vars.css","data":":root {\n--icon-confirm-fade-000: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdib3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2IiB2ZXJzaW9uPSIxLjEiIGhlaWdodD0iMTYiPjxwYXRoIG9wYWNpdHk9Ii41IiBkPSJtOC41I
sanfx / gist:d47a7d70f882174416e057d6646af79a
Last active May 19, 2024 17:49
Installing prometheus
Enter the following to create Prometheus user accounts to be used as a service user accounts for security and
administration purposes. These accounts will not be used for logging into the system.
Use the following commands in Terminal to create the service user accounts.
$ sudo useradd --no-create-home --shell /bin/false prome
$ sudo useradd --no-create-home --shell /bin/false node_exporter
Create Prometheus Directories
$ sudo mkdir /etc/prometheus
sanfx / docker.cadvisor.service
Created August 6, 2020 17:53 — forked from pa-re/docker.cadvisor.service
sudo docker create \
-v /:/rootfs:ro \
-v /var/run:/var/run:rw \
-v /sys:/sys:ro \
-v /var/lib/docker/:/var/lib/docker:ro \
-p 49876:8080 \
--name=cadvisor \
sudo echo "[Unit]
sanfx / vncserver@:1.service
Created July 31, 2020 15:17 — forked from spinxz/vncserver@:1.service
systemd service file for running a vncserver (e.g. tightvncserver)
# Vncserver service file for Debian or Ubuntu with systemd
# Install vncserver and tools
# e.g. apt-get install tightvncserver autocutsel gksu
# 1. Copy this file to /etc/systemd/system/vncserver@:1.service
# 2. Edit User=
# e.g "User=paul"
# 3. Edit the vncserver parameters appropriately in the ExecStart= line!
# e.g. the -localhost option only allows connections from localhost (or via ssh tunnels)
sanfx / cpp
Created May 25, 2020 15:06
function returns nearby visible wifi hotspots
String* getWifiHotspots() {
// String* arr = new String[];
String arr[100];
Serial.print("Scan start ... ");
int n = WiFi.scanNetworks();
for (int i = 0; i < n; i++)
arr[i] = WiFi.SSID(i).c_str();
return arr;
sanfx / lcd-i2c.ino
Last active April 25, 2020 18:26
Particle.publish("NTP clock is: ", hhmmss(now.seconds) + "." + String::format("%03i",now.millis));
Particle.publish("System clock is: ", hhmmss((( % 86400) / 3600)));
if (isDSTactive()){
Particle.publish("DST Active Hour: ", String::format("%3i", Time.hour()));
Particle.publish("DST InActive Hour: ", String::format("%3i", Time.hour()));
Particle.publish("Response Status: ", String::format("%3i", response.status));
Particle.publish("Request body: ", response.body);
sanfx / bedroom_panel.json
Last active April 25, 2020 19:57
Panel in grafana I made that reads data from mysql server and computes dew point and heat index using sql query using in grafana.
"annotations": {
"list": [
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",