Use Markdown for note creation in lazy-blog
In lazy-blog, every page is a Markdown file. Notes are written and recorded using standard Markdown and Markdown extended syntax.
website·Indexed 30 days ago
https://lazydd.github.io/lazy-blog/A collection of technical tutorials and notes covering a wide range of development topics, including Docker deployments for Nginx, Redis, MySQL, and Verdaccio; web frameworks like Vue, React, and Flutter; programming languages such as Rust, Java, and JavaScript; and embedded systems programming for C51 and STM32 microcontrollers.
# Log in to the private registry
npm login
# Publish the package
npm publishWebSocket connection to a server and send the encoded PCM DataView directly. Handle the onmessage event to receive incoming audio Blobs for playback.const initWs = (wsUrl) => {
ws = new WebSocket(wsUrl);
ws.onopen = () => { isConnected = true; };
ws.onclose = () => {
if (recorder) recorder.disconnect();
isConnected = false;
};
ws.onmessage = (e) => {
if (e.data instanceof Blob) {
listen(e.data);
}
};
};
const sendData = () => {
if (size !== 0) {
const pcmData = encodePCM();
if (pcmData && isConnected) {
ws.send(pcmData);
}
}
};0x80 to a value sets the cursor position for the first row. If using Port 0 (P0) for data, external pull-up resistors are required.#include <reg52.h>
#define LCD_Data P0
sbit LCD_RS = P2 ^ 0;
sbit LCD_RW = P2 ^ 1;
sbit LCD_E = P2 ^ 2;
void delay(unsigned int t) {
while (t--);
}
void LCD_Init() {
LCD_Write_Cmd(0x01); // Clear screen
LCD_Write_Cmd(0x06); // Entry mode: AC increment, no shift
LCD_Write_Cmd(0x0c); // Display on, cursor off, blink off
LCD_Write_Cmd(0x38); // 8-bit interface, 2-line display, 5x7 dots
LCD_Write_Cmd(0x80); // Set cursor to row 1, col 1
}
void main() {
unsigned char code Data[] = " I Love You ";
unsigned char i;
LCD_Init();
LCD_Write_Cmd(0x00 + 0x80); // Set cursor to first row, first column
for (i = 0; i < 16; i++) {
LCD_Write_Data(Data[i]);
}
while (1);
}font-spider font compression tool globally using the npm package manager.npm install font-spider -gTo compress fonts using font-spider, follow these steps:
index.html file. Inside the <body>, place the text content that requires the compressed font within a div. In the <style> section, define a @font-face rule where the font-family matches your target font and the src points to your font files.fonts in the root directory. The tool will output the compressed font files into this directory.font-spider command pointing to your HTML file.font-spider index.html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<style>
@font-face {
font-family: 'Lato-Medium';
src: url('./fonts/Lato-Medium.eot');
src: url('./fonts/Lato-Medium.eot?#font-spider') format('embedded-opentype'), url('./fonts/Lato-Medium.woff')
format('woff'), url('./fonts/Lato-Medium.ttf') format('truetype'), url('./fonts/Lato-Medium.svg')
format('svg');
font-weight: normal;
font-style: normal;
}
</style>
</head>
<body>
<div>123456789</div>
</body>
</html>dart pub global activate fvmaedes and net modules to create a local MQTT broker. This implementation includes a custom authentication function to validate usernames and passwords, and event listeners to log client connections and disconnections.npm install aedes mqtt// index.js
const aedes = require('aedes')();
const mqttServer = require('net').createServer(aedes.handle);
const port = 1883;
mqttServer.listen(port, function () {
console.log('mqtt server started and listening on port ', port);
});
// Authentication: callback(error, successful)
aedes.authenticate = function (_client, username, password, callback) {
callback(null, username === 'user' && password.toString() === '123456');
};
// Client connection event
aedes.on('client', function (client) {
console.log(
'Client Connected: \x1b[33m' + (client ? client.id : client) + '\x1b[0m',
'to broker',
aedes.id
);
});
// Client disconnection event
aedes.on('clientDisconnect', function (client) {
console.log(
'Client Disconnected: \x1b[31m' + (client ? client.id : client) + '\x1b[0m',
'to broker',
aedes.id
);
});To add GitHub comments to your blog, follow these steps:
giscus app in your GitHub repository.Discussions in your GitHub repository's Settings.Announcements.#include <reg52.h>
sbit BEEP = P0 ^ 0;
unsigned char code SONG_TONE[] = {212, 212, 190, 212, 159, 169, 212, 212, 190, 212, 142, 159, 212, 212, 106, 126, 129, 169, 190, 119, 119, 126, 159, 142, 159, 0};
unsigned char code SONG_LONG[] = {9, 3, 12, 12, 12, 24, 9, 3, 12, 12, 12, 24, 9, 3, 12, 12, 12, 12, 12, 9, 3, 12, 12, 12, 24, 0};
void PlayMusic() {
unsigned int i = 0, j, k;
while (SONG_LONG[i] != 0 || SONG_TONE[i] != 0) {
for (j = 0; j < SONG_LONG[i] * 30; j++) {
BEEP = ~BEEP;
for (k = 0; k < SONG_TONE[i] / 3; k++);
}
delay(100);
i++;
}
}STM32f10x Startup Files: https://github.com/Lazydd/startup%5Fstm32/tree/main/startup%5Fstm32f10x
Official ST Website: https://www.st.com.cn/zh/embedded-software/stm32-standard-peripheral-libraries.html