Getting Started with Node.js WeChat Official Account Development

Setting up a server: WeChat Official Account development requires a server to receive and process messages. I recommend applying for a free cloud server from Tencent Cloud, click here to apply, available at 9:30 AM daily. I chose Ubuntu as the server image. For how to set up a Node environment on the server, refer to my other blog post Using Linux for Web Frontend Development. The principle of Official Account development is to set up a receiving interface; once developer mode is enabled, WeChat’s server will forward messages to this interface.

Read more

The Vanishing 1px Border

I previously wrote an article about the 1px border issue: From line-height to 0.5px. The scaling approach works, but when using rem or percentage units, the 1px border often disappears on certain devices. The border-image approach doesn’t have this disappearing issue. This article explores why the 1px border disappears and why the latter renders correctly.

Read more

Web Frontend Development on Linux

Why use Linux? While Mac has countless advantages, its relatively high price puts many students off. When I started my internship last year, I was using Windows 7, and the command-line experience was truly painful—especially for web frontend development where countless tools run in the terminal, such as numerous Node.js tools. Switching to Linux made everything much smoother.

Read more

Node.js Morgan Module and Cluster Module

I’ve been tinkering with Node.js recently, following along with “Node.js in Action” to implement the Microblog project. Since the book was written in 2012, and Node has since been updated to v5.9.0 with Express also having undergone significant changes, much of the code in the book no longer works with current versions. For the implementation details, you can refer to this article: “Node.js Development Guide” Microblog Example with Express 4.x. BTW, the Express startup command has changed to npm start, which executes the www file in the bin directory, equivalent to running node ./bin/www directly. This post briefly covers the logging and multi-core CPU optimization topics mentioned in Chapter 6, along with an introduction to a debug tool. The complete Microblog code is available on GitHub: Click here

Read more

Node.js Development Guide - Book Notes

Chapter 3

  1. Single Loading:

    require does not load modules repeatedly. No matter how many times require is called, the module obtained is always the same one.

  2. Overriding exports:

    When encapsulating an object into a module, using exports.Hello = Hello requires require(‘./singleobject’).Hello to obtain the object. This can be simplified as follows: module.exports = Hello; Then you can directly obtain the object: var Hello = require(‘./hello’); hello = new Hello();

  3. Creating Global Links:

    npm link express; This allows you to use the globally installed express in the current directory.

  4. Use npm init to interactively initialize a standard package.json;
    Publish a package: npm publish;
    After modifying the version field in the json file, republish to update the version;
    Unpublish: npm unpublish;

Read more

Internship Summary

Continuing from “Don’t Call Me a Programmer, I’m a Front-End Development Engineer” – so I went to Wacai for my internship, fast forward through ten thousand words, and I successfully converted to a full-time position, then returned to school to write my graduation thesis.

Read more

From line-height to 0.5px

A few days ago, I noticed a piece of code where the line-height (1.7rem) equaled the height (1.7rem), and the font-size was 1.1rem. On iOS devices, the text was vertically centered, but on Android devices, the top and bottom gaps differed by 1px (I couldn’t actually tell if it was exactly one pixel – I was guessing).

Read more

Schema and Download Bar

Since our company had a website without a corresponding mobile version, we needed to display a download bar at the bottom when the website is accessed from a mobile device. Clicking the download bar needed to meet the following two requirements:

  1. If the app is already installed on the device, attempt to open the corresponding app;
  2. If the app is not installed on the device, redirect to the download page for the corresponding operating system.
Read more

HTML5 Screenshot

Implement a QQ-screenshot-like tool: click the load button to load an image, long-press on the image to bring up a cropping box, resize the cropping box from its bottom-right corner, and display a real-time preview in the preview area on the right.

Read more