Skip to content

Instantly share code, notes, and snippets.

SELECT c.*, p1.*
FROM customer c
JOIN purchase p1 ON (c.id = p1.customer_id)
LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND
(p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id))
WHERE p2.id IS NULL;
@wujku
wujku / traefik-auth.conf
Created March 6, 2021 12:56 — forked from acundari/traefik-auth.conf
Traefik fail2ban
# /etc/fail2ban/filter.d/traefik-auth.conf
[Definition]
failregex = ^<HOST> \- \S+ \[\] \"(GET|POST|HEAD) .+\" 401 .+$
@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:
@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:
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);
});
@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>
@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")
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 / 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 / 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