Skip to content

Instantly share code, notes, and snippets.

@opichals
opichals / mdns.js
Last active November 24, 2021 11:24
Espruino experimental mDNS module
function init(hostname, ip) {
const dgram = require('dgram');
const srv = dgram.createSocket({ type: 'udp4', reuseAddr: true, recvBufferSize: 2000 });
srv.addMembership('224.0.0.251', ip); // Bounjour link-local multicast IP
const socket = srv.bind(5353, function(bound) {
function onDatagram(msg, rinfo) {
//console.log('>MEM', JSON.stringify(process.memory()));
//console.log('MSG', msg.length, rinfo.address, rinfo.port);
try {
@marcgeld
marcgeld / psCompress.ps1
Last active April 11, 2023 09:11
Powershell: Compress and decompress byte array
# Compress and decompress byte array
function Get-CompressedByteArray {
[CmdletBinding()]
Param (
[Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[byte[]] $byteArray = $(Throw("-byteArray is required"))
)
Process {