Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Sanjeev Kumar sanfx

🎯
Focusing
View GitHub Profile
@sanfx
sanfx / gist:a928ad7c27ee1eb69c450cec282fc936
Created Nov 22, 2020
nextcloud error on try to logining in
View gist:a928ad7c27ee1eb69c450cec282fc936
This file has been truncated, but you can view the full file.
View gist:d47a7d70f882174416e057d6646af79a
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 Aug 6, 2020 — forked from pa-re/docker.cadvisor.service
/etc/systemd/system/docker.cadvisor.service
View 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 Jul 31, 2020 — forked from spinxz/vncserver@:1.service
systemd service file for running a vncserver (e.g. tightvncserver)
View vncserver@:1.service
# 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
function returns nearby visible wifi hotspots
View cpp
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;
View lcd-i2c.ino
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 Apr 25, 2020
Panel in grafana I made that reads data from mysql server and computes dew point and heat index using sql query using in grafana.
View bedroom_panel.json
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@sanfx
sanfx / query.sql
Created Nov 3, 2019
SQL query used in Grafana to get temperature and humidity form MySQL server and computer dew point and heat index and display in panel.
View query.sql
SELECT
dt_created AS "time",
temp AS "Temperature",
humidity AS "Humidity",
(temp - ((100 - humidity)/5)) AS "Dew Point",
((temp* 1.8) + 32) AS temp_f,
(((-42.379 + 2.04901523*@temp_f + 10.14333127*humidity - .22475541*@temp_f*humidity - .00683783*@temp_f*@temp_f - .05481717*humidity*humidity + .00122874*@temp_f*@temp_f*humidity + .00085282*@temp_f*humidity*humidity - .00000199*@temp_f*@temp_f*humidity*humidity) - 32)*.5556)
AS "Feels Like"
FROM particle_photon
ORDER BY dt_created;
@sanfx
sanfx / TempSensor.h
Created Oct 26, 2019 — forked from dmiddlecamp/TempSensor.h
OneWire Temp - Multiple Sensors
View TempSensor.h
#include "application.h"
class TempSensor {
public:
char *id ;
uint8_t rom[8];
float value ;
int updated ;
};
@sanfx
sanfx / tricks.py
Last active May 3, 2019
callable object class and magic methods __call__, __getitem__
View tricks.py
class BaseClass(object):
def __init__(self):
"""Initialise newly created object.
"""
super(BaseClass, self).__init__()
print "Constructor called."
def __call__(self, storage):
"""Implements function call operator.
"""
You can’t perform that action at this time.