Skip to content

Instantly share code, notes, and snippets.

@radinsky
radinsky / zigbee2mqtt_aqara_wireless_switch.yaml
Created July 13, 2021 19:14 — forked from rhl2401/zigbee2mqtt_aqara_wireless_switch.yaml
Aqara Wireless Switch (single, double, hold)
blueprint:
name: Aqara Wireless Switch (single, double, hold)
description: 'Control anything using Aqara Wireless Switch.
Customizable actions for each press.
This version of the blueprint is for buttons supporting single, double and hold actions.
'
domain: automation
@radinsky
radinsky / wifi-on-ubuntu-server-18.md
Last active April 3, 2020 09:34 — forked from austinjp/wifi-on-ubuntu-server-18.md
Enabling wifi on Ubuntu server 18

Wifi on Ubuntu 18 server

TLDR

  1. Install wpasupplicant 1. Turn on wifi radios: sudo nmcli radio wifi on
  2. Check your devices are recognised even if they're not "managed": sudo iwconfig (not must, will require wireless-tools instalation)
  3. Check your wifi (here called "wlp2s0") is capable of detecting nearby routers: sudo iwlist wlp3s0 scan
  4. Configure netplan by dropping a file called 01-netcfg.yaml into /etc/netplan/ or edit existing file there. See example below.
  5. netplan try, netplan generate, netplan apply.
@radinsky
radinsky / relative-time.php
Created November 29, 2018 14:56 — forked from mtttmpl/relative-time.php
Get Relative Time in PHP (e.g. '1 hour ago', 'yesterday', 'tomorrow', 'in 2 weeks')
<?php
function time2str($ts) {
if(!ctype_digit($ts)) {
$ts = strtotime($ts);
}
$diff = time() - $ts;
if($diff == 0) {
return 'now';
} elseif($diff > 0) {
$day_diff = floor($diff / 86400);