Skip to content

Instantly share code, notes, and snippets.

@scruel
scruel / fix-ms-input-pinyin-phrase.py
Last active May 9, 2024 10:14
修正微软拼音输入法无法添加多个格式化自定义短语的问题,默认添加 sj 和 rq 两个自定义短语
"""
修正微软拼音输入法无法添加多个格式化自定义短语的问题
Author: Scruel Tao
"""
import os
import re
import pathlib
import traceback
from pathlib import Path
@chessmango
chessmango / README.md
Last active May 9, 2024 10:13
Simple Bash add-apt-repository drop-in

Things are awkward in the apt world while apt-key is deprecated and things like Launchpad and general PPA usage are in flux.

This snippet attempts to replicate add-apt-repository functionality for sanity, probably quite badly. There's no error checking or anything advanced, but at least the script is easy to understand.

Syntax: [sudo] addaptrepo.sh <repo-string> <gpg-key-fingerprint>

Then follow up with [sudo] apt-get update. I'm not making that call for you :P

You can find the gpg key fingerprint for a Launchpad repo by expanding Technical details about this PPA.

Async and Await: Here be dragons

Overview

  • Background
  • Basics
  • Concepts
  • Examples

In the Beginning …

@wojteklu
wojteklu / clean_code.md
Last active May 9, 2024 10:09
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active May 9, 2024 10:01
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

@Kartones
Kartones / postgres-cheatsheet.md
Last active May 9, 2024 10:07
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@CaptainLeon445
CaptainLeon445 / install-docker.md
Created May 9, 2024 09:55 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@bn-l
bn-l / recursive-file-lister-generator.js
Created May 9, 2024 09:54
Very cool snippet showing the use of a JS generator to walk a directory recursively. Yields the path of files found.
/**
* @param {string} rootPath
* @returns {Generator<string>}
*/
function* walk(rootPath) {
for (const entry of fs.readdirSync(rootPath, { withFileTypes: true })) {
const filePath = path.join(rootPath, entry.name);
if (entry.isDirectory()) yield* walk(filePath);
else yield filePath;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Apatrid
Apatrid / lightbox-modal.html
Created November 24, 2020 09:29
Alpine.js + TailwindCSS Lightbox Modal
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alpine.js-TailwindCSS-Lightbox-Modal</title>
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
</head>
<body>