Skip to content

Instantly share code, notes, and snippets.

@wujku
wujku / default.vcl
Created March 20, 2024 08:24
Advanced VCL with Varnish sharding example (Magento 2)
# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
vcl 4.0;
import directors;
import std;
# The minimal Varnish version is 6.0
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'
# Define probe used for heartbeat
@wujku
wujku / add-gitlab-deploy-key-to-group-projects.sh
Last active November 28, 2023 10:06
Add a deploy key to projects from a specific group, taking into account that the API returns results with a limit of 100 elements per page
#!/bin/bash
# Zmienne
GITLAB_API="https://gitlab.com/api/v4" # Zmień na adres swojego GitLab
GROUP_ID="19" # Zmień na ID grupy, z której chcesz wyciągnąć projekty
DEPLOY_KEY_ID=$1 # Zmień na ID klucza deploy
# Print helpFunction in case parameters are empty
if [ -z "$DEPLOY_KEY_ID" ]
then
@wujku
wujku / pimcore_previously_opened_tab_with_object.js
Last active November 24, 2022 08:45
Check if object from grid row was already opened as other tab
if (pimcore.globalmanager.exists("object_" + this.getStore().getAt(index).data.id)) {
// Your implementation
}
@wujku
wujku / daily_power_consumption
Last active November 1, 2022 18:24
InfluxDB – Power consumption
from(bucket: "home_assistant")
|> range(start: -30d)
|> filter(fn: (r) => r._measurement == "imp" and r._field == "value")
|> aggregateWindow(every: 1d, fn: spread, createEmpty: false)
|> map(fn: (r) => ({r with _value: r._value / 1000.0 }))
|> yield(name: "daily total")
@wujku
wujku / index.html
Created October 5, 2022 16:05
Smart home dashboard controller UI
<div class="dashboard">
<header>
<div class="f fe">
<div class="icon icon-w"></div>
<div class="heading">
<h5 class="date">1 Feb 2019</h5>
<h2 class="title">Cloudy</h2>
</div>
</div>
var panel = new Ext.form.FormPanel({
title: 'Example',
width: 350,
items: [],
listeners: {
add: function(me, component, index) {
component.on('change', function(f,n,o) {
alert('detected! '+f.label+' value changed from '+o+' to '+n);
console.log(component.startValue);
});
binary_sensor:
- platform: template
sensors:
pc_relay_cwu_pump:
friendly_name: "Pompa CWU"
value_template: "{{ state_attr('sensor.heat_pump', 'relay_cwu_pump') }}"
device_class: power
pc_relay_co_pump:
friendly_name: "Pompa CO"
value_template: "{{ state_attr('sensor.heat_pump', 'relay_co_pump') }}"
@wujku
wujku / 4button_scene_switch_zha.yaml
Last active February 18, 2024 15:14
Blueprint for 4-Button Scene Switch (TS0044) – Home Assistant – Improved version of https://community.home-assistant.io/t/zha-tuya-4-button-scene-switch-ts0044/265099
blueprint:
name: ZHA - 4-Button Scene Switch
description: Automate your 4-Button Scene Switch via ZHA events.
domain: automation
input:
4button_scene_switch:
name: 4-Button Scene Switch
description: 4-Button Scene Switch to use
selector:
device:
@wujku
wujku / docker-compose.yml
Last active January 5, 2022 10:20
Simple local FTP by pure-ftpd
version: '3'
# Run after run container:
# Create user wujku which runs as the FTP system user. By default, the user will be chrooted to /home/ftpuser.
# $ docker exec -it pure-ftpd pure-pw useradd wujku -u ftpuser -d /home/ftpuser -m
# Update the database using the command
# $ docker exec -it pure-ftpd pure-pw mkdb
services:
ftpd_server:
@wujku
wujku / data_collector.yaml
Created October 6, 2021 09:47
ESPHome example with ADC
esphome:
name: data-collector
platform: ESP32
board: esp-wrover-kit
# Enable logging
logger:
# Enable Home Assistant API
api: