Skip to content

Instantly share code, notes, and snippets.

View johnDorian's full-sized avatar

John Dorian johnDorian

View GitHub Profile
@johnDorian
johnDorian / README.md
Last active April 10, 2021 14:06
Node exporter on roborock v1

Running node-exporter on the roborock v1 vacuum.

  1. Save the nodeexporter.conf upstart script to /etc/init/nodeexporter.conf
  2. Grab the armv7 node exporter binary from https://github.com/prometheus/node_exporter/releases
  3. Add the node_exporter binary to /usr/local/bin/node_exporter
  4. Reboot or start the service service nodeexporter start.
@johnDorian
johnDorian / README.md
Created October 20, 2020 13:51
Tailscale for Valetudo

Tailscle on a roborock for Valetudo

Tailscale provides a simple to setup and use private network. I've just starting using this on my home network for home assistant and valetudo. Here are the instructions for setting up Tailsclae on the roborock vacuum.

For official tailscale installation see here: https://tailscale.com/download/linux/static

Download

@johnDorian
johnDorian / README.md
Last active August 14, 2022 06:01
Rockrobo restore map (gen1)

This gist is an example of how to use home assistant to reload the map of the vacuum

Setup the vacuum

How to setup the vacuum side of things

  1. You will need to copy the recovery_map.shto /mnt/data/valetudo/recovery_map.sh on the vacuum
  2. Create the backup folder mkdir -p /mnt/data/rockrobo/backup/
  3. Run a complete clean or manually steer the vacuum around the entire house. After finishing the tour, return the vacumm to the dock.
  4. Copy the base map to the backup folder cp /mnt/data/rockrobo/last_map /mnt/data/rockrobo/backup/ and the charger pos cp /mnt/data/rockrobo/ChargerPos.data /mnt/data/rockrobo/backup/

Setup Home assistant

"""
Programming task
================
The following is an implementation of a simple Named Entity Recognition (NER).
NER is concerned with identifying place names, people names or other special
identifiers in text.
Here we make a very simple definition of a named entity: A sequence of
at least two consecutive capitalized words. E.g. "Los Angeles" is a named
"""
Programming task
================
Implement the method iter_sample below to make the Unit test pass. iter_sample
is supposed to peek at the first n elements of an iterator, and determine the
minimum and maximum values (using their comparison operators) found in that
sample. To make it more interesting, the method is supposed to return an
iterator which will return the same exact elements that the original one would
have yielded, i.e. the first n elements can't be missing.
@johnDorian
johnDorian / example.r
Last active August 29, 2015 14:17
A fast (Rcpp) version of the Nash–Sutcliffe model efficiency coefficient
# Load the libraries
library(Rcpp)
library(hydroGOF)
# Load the source cpp file with a few gof values.
sourceCpp("gof.cpp")
# Create some data to test and compare the two functions.
obs <- rnorm(10)
sim <- rnorm(10)
# Compare the two functions
NSE_fast(sim,obs)
@johnDorian
johnDorian / qsu_standard_conversions.r
Created March 9, 2015 12:57
QSU - Fdom conversions
## The limits of the instrument (milivolts) and the sensor (QSU)
mv_conv <- data.frame(mv_limits = c(10.85, 4965),qsu_limits = c(0,200))
## Plot the raw data to get an idea of what is hapenning
plot(qsu_limits~mv_limits, mv_conv, xlab="mV (datalogger)",
ylab = "Sensor limits (QSU)")
## Fit a model of the relationship
mv_conv_mod <- lm(qsu_limits~mv_limits, mv_conv)
## Add the trend model to the plot
abline(mv_conv_mod)
## An example to estimate the mV (Should be close to 100 QSU.)
@johnDorian
johnDorian / load_and_save_multiple.r
Created February 2, 2015 09:42
An example to create, load, manipulate and save multiple csv files with R
### create some fictional data
dir.create("tmp")
setwd("tmp")
for(i in 1:10){
tmp_file <- data.frame(x=1:100, y=rnorm(100), z = rnorm(100))
tmp_file_name <- paste0(paste(letters[sample(1:24, 10)], collapse= ""), ".csv")
write.csv(tmp_file, tmp_file_name, row.names= FALSE)
}
@johnDorian
johnDorian / rolling_mean.r
Last active August 29, 2015 14:14
Example of aggregating a variable through time.
set.seed(1082)
# Create two weeks of 15 minute data
library(lubridate)
dates <- seq.POSIXt(dmy_hm("01-01-2013 00:00"), dmy_hm("31-12-2013 11:45"), by = "15 mins")
# Add a column with a random variable with mean = 10
temp <- data.frame(date = dates, temp = rnorm(length(dates))+10)
plot(temp, type='l')
# aggreagate the data to daily by converting the POSIX date to date format (i.e drop the timestamp)
daily_temp <- aggregate(temp$temp, list(date=as.Date(temp$date)), mean)
# fix the names up
@johnDorian
johnDorian / modify_hour.r
Created January 19, 2015 13:46
modify hour of a subset using lubridate
library(lubridate)
## A synthetic data set.
doc <- data.frame(date=ymd_hm("2014-01-01 14:00") + (1:360)* 24*3600)
# Find all the dates before a certain time period.
index <- doc$date < ymd("2014-06-01")
## use the hour function to extract the hour of each day e.g
hour(doc$date)
## Now using the index from above you can subtract an hour from each of the times
# using the index vector and reassiging the modified hour back to the time stamp.
hour(doc$date[index]) <- hour(doc$date[index]) - 1