Skip to content

Instantly share code, notes, and snippets.

blueprint:
name: Low Power Detection
description: >
Send a notification when low power is detected for a certain amount of time.
Useful for sending notifications when the washing machine or drying machine
is finished, for example.
domain: automation
input:
power_consumption:
name: Power Consumption
blueprint:
name: Motion Light
description: >
Turn on a light when motion is detected, and the luminance in the room is
below the specified value. Keeps the light on for a specified amount of
time, before dimming it, and eventually turning it off.
domain: automation
input:
motion_sensor:
name: Motion Sensor
@Mrtenz
Mrtenz / dev.sh
Last active March 23, 2022 09:18
A zsh script which clones a GitHub repository and sets it up for development
#!/usr/bin/env zsh
# To create an alias for the script, use:
# alias dev="source /path/to/dev.sh"
#
# Then you can use it as follows:
# dev user/repo
# dev https://github.com/user/repo
# dev https://github.com/user/repo/pull/123
@Mrtenz
Mrtenz / contract.ts
Created May 29, 2021 14:29
Strictly typed contract interface from a standard JSON ABI interface, without code generation
import type { ERC20 } from './erc-20';
import type { InputTypeMap, OutputTypeMap, TypeMapper } from './types';
/**
* This creates an interface with all ERC-20 functions, strictly typed with TypeScript types. It does not require any
* code generation or pre-formatting of the ERC-20 ABI, simply pass in the standard ERC-20 as type, and it will work.
*
* For example:
*/
type ERC20Contract = Contract<ERC20>;
// SPDX-License-Identifier: MIT
pragma solidity 0.7.0;
contract SignatureVerifier {
/**
* @notice Recovers the address for an ECDSA signature and message hash, note that the hash is automatically prefixed with "\x19Ethereum Signed Message:\n32"
* @return address The address that was used to sign the message
*/
function recoverAddress (bytes32 hash, uint8 v, bytes32 r, bytes32 s) public pure returns (address) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
pragma solidity ^0.7.0;
contract ERC1271 {
bytes4 constant internal MAGICVALUE = 0x1626ba7e;
function isValidSignature(
bytes32 _hash,
bytes memory _signature
) public view returns (bytes4 magicValue);
}
{
"title": "Asset Metadata",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this NFT represents"
},
"description": {
"type": "string",
pragma solidity ^0.5.7;
interface ERC777TokensSender {
function tokensToSend(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata operatorData
pragma solidity ^0.5.7;
interface ERC777TokensRecipient {
function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata data,
bytes calldata operatorData
pragma solidity ^0.5.7;
interface ERC777 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function totalSupply() external view returns (uint256);
function granularity() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function send(address to, uint256 amount, bytes calldata data) external;