Skip to content

Instantly share code, notes, and snippets.

@lyonzy
lyonzy / tuya_mcu_alt.h
Last active May 10, 2024 00:42
ESPHome custom Climate for "alternate" Tuya MCUs
/*
ESPHome custom component for Arlec Grid Connect Smart Panel Heater.
This heater contains an MCU that's not the standard "tuya" integration in ESPHome.
Probably works for similar panel heaters e.g. Devola, Kogan.
Not implemented:
- the Wifi icon on the panel (but this would be a simple improvement given the info in the sources below)
- the timer, for the same reasoning as Neon Ninja (Home Assistant is more powerful anyway)
Doesn't seem to have any issues being booted from the USB-Serial adapter (outside the heater) as mentioned on the Tasmota page, but YMMV.
@Obydux
Obydux / Fabric-Quilt-Server-Optimization.md
Last active May 10, 2024 00:42
Fabric/Quilt Server Optimization

Fabric/Quilt Server Optimization

This has updated for 1.20.4, all of the optimization mods mentioned here are compatible with each other and don't affect vanilla behaviour by default.

Mods

Lithium - A mod designed to drastically improve the general performance of Minecraft without breaking things.

VMP - A mod designed to improve general server performance at high playercount.

@jordansinger
jordansinger / iPod.swift
Created July 27, 2020 21:19
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
@veteran29
veteran29 / arma-launcher-script.js
Last active May 10, 2024 00:34
Arma Launcher HMTL Modlist to JS
function getWorkshopIdFromUrl(url) {
return url.split('id=')[1];
};
function getNodeType(node) {
return node.getAttribute('data-type')
};
function getNodeDataValue(node) {
switch(getNodeType(node)) {
@veteran29
veteran29 / array_functions.js
Last active May 10, 2024 00:34
ES2015 Snippets
const createRange = (start, amount) =>
Array.from(Array(amount), (_, idx) => start + idx);
/**
* @param {array} array
*/
const uniqueArray = array => [...new Set(array)];
/**
* @param {array} array
@nijikokun
nijikokun / doc.md
Last active May 10, 2024 00:33
Building Javascript Frontend / Backend Applications

Document for the best design choices you can make for your software.

Terminology

  • DDD - [Domain Driven Design][ddd-wikipedia]
  • FF or FTF - Function First Design, or File-type First Design is structuring your application by it's function before the files such as a directory named components containing all component files.

File Structure

Structuring applications is hard, here are a few resources to help.

@vova-learn
vova-learn / debounce.js
Created April 10, 2023 09:02
Функция debounce для устранения дребезга
// Функция взята из интернета и доработана
// Источник - https://www.freecodecamp.org/news/javascript-debounce-example
function debounce (callback, timeoutDelay = 500) {
// Используем замыкания, чтобы id таймаута у нас навсегда приклеился
// к возвращаемой функции с setTimeout, тогда мы его сможем перезаписывать
let timeoutId;
return (...rest) => {
// Перед каждым новым вызовом удаляем предыдущий таймаут,
@vova-learn
vova-learn / script.js
Last active May 10, 2024 00:32
Ctrl+keyCode (ctrl+F)
document.addEventListener(`keydown`, (evt) => {
const keyCodeF = 70;
const isEnterAndCtrl = evt.keyCode === keyCodeF && evt.ctrlKey;
if (isEnterAndCtrl) {
evt.preventDefault();
console.log(evt.keyCode);
}
});
@vova-learn
vova-learn / utm-parse.js
Created June 9, 2020 07:08
Парсинг UTM-меток
const getParameterByName = (name) => {
const utmName = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
const regex = new RegExp("[\\?&]" + utmName + "=([^&#]*)");
const result = regex.exec(location.search);
return result === null ? "" : decodeURIComponent(result[1].replace(/\+/g, " "));
}
getParameterByName('utm_term');