Skip to content

Instantly share code, notes, and snippets.

View liuliangsir's full-sized avatar
💻
Coding

流浪大法师 liuliangsir

💻
Coding
View GitHub Profile
@breithbarbot
breithbarbot / uninstall_zsh.sh
Last active March 29, 2024 21:35
Uninstall Zsh + Oh My Zsh + Powerlevel10k theme (macOS & Linux)
#!/bin/sh
# Install Zsh + Oh My Zsh + Powerlevel10k theme (macOS & Linux)
# run: sh -c "$(curl -fsSL "$(echo "$(curl -s "https://api.github.com/gists/254e58bd87009963b3f58405d75cbe6c")" | grep -o '"raw_url": *"[^"]*"' | cut -d'"' -f4)")"
# Remove installations + configurations
rm -f ~/.p10k.zsh
rm -rf -- ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
sh ~/.oh-my-zsh/tools/uninstall.sh -y
sudo chsh -s $(which bash)

Emscripten as a linker for Zig and C

This shows how to build a nontrivial program using Zig+Emscripten or C+Emscripten. In both cases Emscripten is only used as a linker, that is the frontend is either zig or clang.

"Nontrivial" here means the program uses interesting Emscripten features:

  • Asyncify
  • Full GLES3 support
  • GLFW3 support
@onejar99
onejar99 / .p10k.zsh
Created June 26, 2021 14:52
My custom p10k config (~/.p10k.zsh)
# Generated by Powerlevel10k configuration wizard on 2021-06-26 at 20:58 CST.
# Based on romkatv/powerlevel10k/config/p10k-rainbow.zsh, checksum 25238.
# Wizard options: nerdfont-complete + powerline, small icons, rainbow, unicode,
# 24h time, angled separators, sharp heads, round tails, 2 lines, dotted, no frame,
# darkest-ornaments, sparse, many icons, concise, instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with powerline prompt style with colorful background.
# Type `p10k configure` to generate your own config based on it.
#
@royling
royling / background.js
Last active March 10, 2024 14:04
Click Chrome extension icon to execute scripts on active tab
chrome.action.onClicked.addListener((tab) => {
chrome.scripting.executeScript({
target: {
tabId: tab.id,
},
files: ["content.js"],
});
});
@sindresorhus
sindresorhus / esm-package.md
Last active April 19, 2024 10:56
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@rauschma
rauschma / impatient-js-es2021.md
Last active August 31, 2023 07:02
ES2021 edition of “JavaScript for impatient programmers”

What is new in the ES2021 edition of “JavaScript for impatient programmers”?

Free to read online: exploringjs.com/impatient-js/

  • The exercises now run as native ESM modules on Node.js. Previously, they were run via the esm package.
  • Material on new ES2021 features:
    • String.prototype.replaceAll()
    • Promise.any()
    • Logical assignment operators
  • Underscores (_) as separators in number literals and bigint literals
@customcommander
customcommander / jsdoc-cheat-sheet.md
Last active June 26, 2023 05:20
JSDoc Cheat Sheet
@MMnasrabadi
MMnasrabadi / gist:4b256d2ab2af7257210911a99cd77a9c
Last active January 18, 2024 21:30
GitKraken open Private Repository
Installing older version of Gitkraken is the only solution I guess to work on private repo if you want it for free and without student developer pack.
From the release notes, the last version to support private repo is v6.5.1.
@DeoluA
DeoluA / beforeUploadFunc.js
Last active March 22, 2024 12:24
Ant Design - Check the file type, file size and image dimensions before upload
// plugged in this answer from S.O. - https://stackoverflow.com/a/8904008/5172977
// import { Upload } from 'antd';
// function returns a promise
beforeUpload = (file) => {
return new Promise((resolve, reject) => {
// check the file type - you can specify the types you'd like here:
const isImg = file.type === 'image/jpeg' || file.type === 'image/jpg' || file.type === 'image/png' || file.type === 'image/gif';
if (!isImg) {
@pgmoir
pgmoir / PreviewImage.js
Last active March 9, 2023 09:23
Responsive resize of canvas to match inserted image and plot/tag points that stay in location during resize
import React, { useRef, useEffect } from 'react';
const scaleWidth = 500;
const scaleHeight = 500;
/*
topImage is an object
{
image: String, // name of image
imageUrl: String, // full url of remote hosted image