Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sanfx's full-sized avatar
🎯
Focusing

Sanjeev Kumar sanfx

🎯
Focusing
  • London
  • 15:06 (UTC +01:00)
View GitHub Profile
@sanfx
sanfx / fetch.py
Last active September 18, 2022 13:28 — forked from syndbg/fetch.py
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
import gdata.youtube
import gdata.youtube.service
# Dependencies:
# - Python==3.10
# - gdata-python3==2.0.18
# - google-api-python-client==1.2
@sanfx
sanfx / dbbackup.sh
Created February 19, 2022 15:20
mysql db back script this script is called periodically from jenkins, though you can just set cron job.
#!/bin/bash
# in case the mysql db is located in docker container.
append_cli=$4
# For taking backup
backup_dir=/media/storage/backup/db_backup/
datestamp=$(date +%d-%m-%y-%H-%M)
db_user=backup
db_port=$2
db_pass=$3
global
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
daemon
@sanfx
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":"10.8.0.4","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
sanfx / gist:d47a7d70f882174416e057d6646af79a
Last active December 2, 2023 12:56
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
sanfx / docker.cadvisor.service
Created August 6, 2020 17:53 — forked from pa-re/docker.cadvisor.service
/etc/systemd/system/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 \
google/cadvisor:latest
sudo echo "[Unit]
@sanfx
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
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
sanfx / lcd-i2c.ino
Last active April 25, 2020 18:26
snippet
Particle.publish("NTP clock is: ", hhmmss(now.seconds) + "." + String::format("%03i",now.millis));
Particle.publish("System clock is: ", hhmmss(((Time.now() % 86400) / 3600)));
if (isDSTactive()){
Particle.publish("DST Active Hour: ", String::format("%3i", Time.hour()));
}
else{
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
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",