Skip to content

Instantly share code, notes, and snippets.

View h4's full-sized avatar
💭
I may be slow to respond.

Mikhail Baranov h4

💭
I may be slow to respond.
View GitHub Profile
@h4
h4 / replaceNode.js
Last active September 29, 2017 09:48
const templateList = document.querySelectorAll(`template`);
const central = document.querySelector(`.central`);
const templateShow = function (templateNumber) {
const newNode = templateList[templateNumber].content.cloneNode(true);
central.innerHTML = ``;
central.replaceChild(newNode, oldNode);
};
'use strict';
(function () {
var WIZARD_NAMES = ['Иван', 'Хуан Себастьян', 'Мария', 'Кристоф', 'Виктор', 'Юлия', 'Люпита', 'Вашингтон'];
var WIZARD_LASTNAMES = ['да Марья', 'Верона', 'Мирабелла', 'Вальц', 'Онопко', 'Топольницкая', 'Нионго', 'Ирвинг'];
var WIZARD_COATCOLORS = ['rgb(101, 137, 164)', 'rgb(241, 43, 107)', 'rgb(146, 100, 161)', 'rgb(56, 159, 117)', 'rgb(215, 210, 55)', 'rgb(0, 0, 0)'];
var WIZARD_EYESCOLORS = ['black', 'red', 'blue', 'yellow', 'green'];
var FIREBALL_COLORS = ['#ee4830', '#30a8ee', '#5ce6c0', '#e848d5', '#e6e848'];
var setup = document.querySelector('.setup');
@h4
h4 / find_in_repos.sh
Created July 3, 2018 16:49
Find substring in git bare repos
#!/usr/bin/env bash
set -e
ROOT=$1
PATTERN=$2
walkdir() {
CUR_DIR=$1
pushd $CUR_DIR > /dev/null
# /etc/systemd/system/fleet.service
[Unit]
After=etcd.service etcd2.service etcd-member.service
Wants=network.target fleet.socket
Requires=etcd-member.service
Requires=skydns.service
[Service]
Type=simple
Restart=always
RestartSec=10s
@h4
h4 / aESPtemplate.cpp
Created April 7, 2019 07:13
ESP 8266 Template
// arduinoESP8266 wifi & eeprom setting template
// ----------------------------------- libs -----------------------------------
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include <EEPROM.h>
@h4
h4 / rename.py
Last active April 15, 2019 16:08
GIT rename bunch of files using python
#!/usr/bin/env python3
import subprocess
import time
from os import walk, path, chdir
import re
regex = re.compile(r'([0-9a-f]+)_(\w+)\.py')
date_re = re.compile(r'(\d+)-(\d+)-(\d+) (\d+):(\d+)')
chdir('/Users/h4/Projects/Arrival/components-catalogue/alembic/versions')
for root, dirs, files in walk('/Users/h4/Projects/Arrival/components-catalogue/alembic/versions'):
@h4
h4 / out
Last active May 11, 2019 22:38
[76, 89, 87, 83, 68, 48, 50]
[0, 0]
[1, 0, 255, 255]
[109, 105, 97, 111, 109, 105, 97, 111, 99, 101, 46, 99, 111, 109]
[76, 89, 87, 83, 68, 48, 50]
[70, 50, 48, 48, 70, 70, 70, 70, 48, 50, 52, 51, 53, 54, 57, 48, 53, 67]
[70, 50, 95, 87, 70]
[49, 46, 49, 46, 50, 95, 48, 48, 49, 57]
[48, 48, 49, 57]
[190, 112, 128, 200, 89, 63]
@h4
h4 / LYWSD02.txt
Created May 20, 2019 06:48
LYWSD02 sensor available characteristics
Service: 00001800-0000-1000-8000-00805f9b34fb
Characteristic: 00002a00-0000-1000-8000-00805f9b34fb
READ
b'LYWSD02'
Characteristic: 00002a01-0000-1000-8000-00805f9b34fb
READ
b'\x00\x00'
Service: 00001801-0000-1000-8000-00805f9b34fb
Characteristic: 00002a05-0000-1000-8000-00805f9b34fb
READ INDICATE
@h4
h4 / MJ_HT_V1.txt
Created May 21, 2019 14:04
MJ_HT_V1 sensor available characteristics
Service: 00001800-0000-1000-8000-00805f9b34fb
Characteristic: 00002a00-0000-1000-8000-00805f9b34fb
READ WRITE
b'MJ_HT_V1'
Characteristic: 00002a01-0000-1000-8000-00805f9b34fb
READ
b'\x00\x03'
Characteristic: 00002a04-0000-1000-8000-00805f9b34fb
READ
b'\x10\x00<\x00\x00\x00\x90\x01'
sensor:
- platform: template
sensors:
livingroom_battery:
friendly_name: "Humid Battery Level"
value_template: "{{ states.sensor.humidity_158d00020ec3e3.attributes.battery_level }}"
unit_of_measurement: '%'