Skip to content

Instantly share code, notes, and snippets.

@Jaid
Jaid / migratingRules.md
Last active February 21, 2024 10:48
ESLint rules for migrating projects from CommonJS to ESM

ESLint rules

The ESM standard is considered stable in NodeJS and well supported by a lot of modern JavaScript tools.

ESLint does a good job validating and fixing ESM code (as long as you don't use top-level await, coming in ESLint v8). Make sure to enable the latest ECMA features in the ESLint config.

  • .eslint.json
{
@socrateslee
socrateslee / jd_union_api.py
Last active November 1, 2023 03:31
京东联盟开放平台API的一个通用的Client封装
'''
京东联盟开放平台API的一个通用的Client封装。
京东联盟开放平台的文档详见 https://union.jd.com/openplatform
涉及到签名方法的文档见 https://union.jd.com/helpcenter/13246-13247-46301
Example:
client = JdApiClient("<YOUR_APP_KEY>", "<YOUR_SECRET_KEY>")
resp = client.call("jd.union.open.goods.promotiongoodsinfo.query",
{'skuIds':'12072066'})
print(resp.json())
@xhsdnn
xhsdnn / TextEllipsis.vue
Created August 9, 2019 08:35
单/多行文本截断的vue组件
<template>
<div class="text-ellipsis" :style="{height: textHeight,lineHeight: lineHeight}">
<div class="ellipsis-before" :style="{height: textHeight}"></div>
<div class="ellipsis-content">
<template v-if="$slots.default">
<slot></slot>
</template>
<template v-else>{{text}}</template>
</div>
<div class="ellipsis-after" :style="{top: '-'+lineHeight, height: lineHeight}">...</div>
@w1th0utnam3
w1th0utnam3 / rust_electron.md
Last active January 29, 2024 23:17
Building a Rust/Electron app
@andywer
andywer / _readme.md
Last active March 7, 2024 05:52
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

@thw0rted
thw0rted / relativeOrientation.ts
Created May 4, 2018 12:25
Cesium function to transform relative heading-pitch-roll to absolute rotation Quaternion
import {
Cartesian3,
HeadingPitchRoll,
Matrix3,
Matrix4,
Quaternion,
Transforms,
} from "cesium";
/**
@giansalex
giansalex / docker-php-ext-install.md
Last active October 3, 2023 10:02
docker-php-ext-install Reference
RUN apt update
RUN apt upgrade -y
RUN apt install -y apt-utils
RUN a2enmod rewrite
RUN apt install -y libmcrypt-dev
RUN apt install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 18, 2024 09:22
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@nikhita
nikhita / update-golang.md
Last active May 15, 2024 08:27
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@lpar
lpar / README.md
Last active January 29, 2023 14:09
How to make Hugo (0.20+) generate an Atom feed instead of RSS

The Hugo static site generator sadly still uses the obsolete and badly standardized RSS format.

Here's how to set it up to generate an Atom feed instead. Pretty much all feed readers which understand RSS also understand Atom, except iTunes, and Atom is a better format.

  1. Define an appropriate media type and corresponding output format in config.toml: