@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
# based on: https://community.home-assistant.io/t/tuya-radiator-valve-ts0601-calibration-from-external-sensor-via-zigbee2mqtt/337991 | |
# alternative: https://community.home-assistant.io/t/sync-trv-with-external-tempature-sensor/298024 | |
blueprint: | |
name: Calibrate TRV temperature | |
description: Temperature calibration for Zigbee valve TS0601, according to external temperature sensor | |
domain: automation | |
input: | |
valve: | |
name: Valve |
function nonCoercible(val) { | |
if (val == null) { | |
throw TypeError('nonCoercible shouldn\'t be called with null or undefined'); | |
} | |
const res = Object(val); | |
res[Symbol.toPrimitive] = () => { | |
throw TypeError('Trying to coerce non-coercible object'); | |
} | |
return res; | |
}; |
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
#add script to .oh-my-zsh/lib/functions.zsh | |
function rm () { | |
local path | |
for path in "$@"; do | |
# ignore any arguments | |
if [[ "$path" = -* ]]; then : | |
else | |
local dst=${path##*/} | |
# append the time if necessary |
Locate the section for your github remote in the .git/config
file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
sh_stats () { | |
fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20 | |
} |
# Download and install XAMPP (Ubuntu 12.10) | |
# Depends on python-gtk2:i386 and python-glade2:i386 for the Control Panel | |
# If all else fails, XAMPP has step by step instructions at: http://www.apachefriends.org/en/xampp-linux.html | |
sudo add-apt-repository ppa:upubuntu-com/xampp; | |
sudo apt-get update; | |
sudo apt-get install xampp; | |
# Append the following if you're on a 64-bit system (~250MB) | |
sudo apt-get install ia32-libs |
#!/bin/bash | |
# Might as well ask for password up-front, right? | |
sudo -v | |
# Keep-alive: update existing sudo time stamp if set, otherwise do nothing. | |
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & | |
# Example: do stuff over the next 30+ mins that requires sudo here or there. | |
function wait() { |
In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.
For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.
// Simple ajax function to avoid using jQuery (°-°) | |
var ajax = function (url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.send(); | |
xhr.onreadystatechange = function (e) { | |
if (e.target.status === 200 && e.target.readyState === 4) { | |
callback(e.target.response); | |
} | |
}; |