Skip to content

Instantly share code, notes, and snippets.

View xantiagoma's full-sized avatar

Santiago Montoya A. xantiagoma

View GitHub Profile
type IsId<T extends string = string> = T extends `${infer U}${infer V}`
? Includes<IdAlphabet, U> extends true
? V extends ""
? U
: IsId<V> extends never
? never
: `${U}${IsId<V>}`
: never
: never;
blueprint:
name: Zigbee2MQTT - Sonoff SNZB-01 Zigbee Wireless Switch
description: Automate your Sonoff SNZB-01 Zigbee Wireless Switch via Zigbee2MQTT.
domain: automation
input:
switch:
name: Sonoff SNZB-01 Zigbee Wireless Switch
description: Sonoff SNZB-01 Zigbee Wireless Switch to use
selector:
entity:
git reset $(git merge-base master $(git branch --show-current))
@xantiagoma
xantiagoma / key-value.ts
Last active February 5, 2025 05:24
Typescript Key and Value types of object
export const ECOMM_STEPS = {
HOME_DETAILS: 'home-details',
LOADER_SERVICE_SCREEN: 'service-loading-screen',
NO_SERVICE_SCREEN: 'no-service-screen',
FRANCHISE_SCREEN: 'franchise-screen',
ORKIN_GREEN: 'orkin-green',
SERVICE_SELECTION: 'service-selection',
PEST_SELECTION: 'pest-selection',
PEST_DETAILS: 'pest-details',
LOADER_PEST_RETURN: 'pest-return',
@xantiagoma
xantiagoma / file.css
Created March 3, 2021 04:36
Prevent Superscripts and Subscripts from Affecting Line-Height
sup, sub {
vertical-align: baseline;
position: relative;
top: -0.4em;
}
sub {
top: 0.4em;
}
L.Polyline = L.Polyline.include({
getDistance: function(system) {
// distance in meters
var mDistanse = 0,
length = this._latlngs.length;
for (var i = 1; i < length; i++) {
mDistanse += this._latlngs[i].distanceTo(this._latlngs[i - 1]);
}
// optional
if (system === 'imperial') {
@xantiagoma
xantiagoma / bitmap_helper.dart
Created August 28, 2020 05:26
SVG asset to BitmapDescriptor
Future<BitmapDescriptor> getBitmapDescriptorFromSVGAsset(
BuildContext context,
String svgAssetLink, {
Size size = const Size(30, 30),
}) async {
String svgString = await DefaultAssetBundle.of(context).loadString(
svgAssetLink,
);
final drawableRoot = await svg.fromSvgString(
svgString,
@xantiagoma
xantiagoma / rubber_animation.dart
Created August 19, 2020 03:03
Rubber Hooks Flutter
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
/// Creates an animation controller.
///
/// * [value] is the initial value of the animation. If defaults to the lower
/// bound.
///
/// * [duration] is the length of time this animation should last.
///
@xantiagoma
xantiagoma / latlng_extensions.dart
Last active August 14, 2020 03:59
LatLng methods
import 'package:latlong/latlong.dart';
import 'dart:math' as math;
LatLng getCenter(LatLng p1, LatLng p2) {
double dLon = degToRadian(p2.longitude - p1.longitude);
final lat1 = degToRadian(p1.latitude);
final lat2 = degToRadian(p2.latitude);
final lon1 = degToRadian(p1.longitude);
double dx = math.cos(lat2) * math.cos(dLon);
double dy = math.cos(lat2) * math.sin(dLon);
<!doctype html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-64554054-15"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}