Skip to content

Instantly share code, notes, and snippets.

View nnaumenko's full-sized avatar

Nick Naumenko nnaumenko

  • Tuusula, Finland
View GitHub Profile
@nnaumenko
nnaumenko / simulate_geolocation.md
Last active August 7, 2019 07:06
Testing: Quickly simulating geolocation position in Firefox

Sometimes one needs to quickly test web page or web app by changing the geolocation coordinates and look at the result.

Type about::config in the URL bar, then type geo.wifi.uri under search.

Set the parameter value as follows: data: application/json,{"location": {"lat": 64.1483407, "lng": -21.9403197}, "accuracy": 1200.0}, and now you are in downtown Reykjavik, Iceland.

Maniputate the latitude (decimal degrees [-90 .. 90], North is positive and South is negative), longitude (decimal degrees [-180 .. 180], East is positive and West is negative) and accuracy (in meters) to quickly simulate the desired position.

When testing is finished, do not forget to reset the parameter to default value!

@nnaumenko
nnaumenko / variant_index.cpp
Created July 1, 2019 22:01
Get numeric index for std::variant alternative with known type (at compile time) in C++17
#include <variant>
/// Get a numeric index for particular type included in variant type at compile time.
/// @tparam V Variant type to search for index.
/// @tparam T Type, index of which must be returned.
/// @return Index of type T in variant V; or variant size if V does not include an alternative for T.
template<typename V, typename T, size_t I = 0>
constexpr size_t variant_index() {
if constexpr (I >= std::variant_size_v<V>) {
return (std::variant_size_v<V>);
@nnaumenko
nnaumenko / mc7.md
Last active February 13, 2024 17:19
Simatic MC7 code