Skip to content

Instantly share code, notes, and snippets.

View aztack's full-sized avatar
🎯
Focusing

Wang Weihua aztack

🎯
Focusing
View GitHub Profile
@aztack
aztack / index.md
Created November 24, 2024 11:24 — forked from cdrini/index.md
Adding lodash type hinting to monaco using addExtraLib

Well that was a headache! This is certainly not an elegant solution, but it works. Hopefully someone can use these notes to save themselves a bunch of time.

Known issues:

  • This does not scale easily to any other library
  • Requires some internal knowledge of lodash's types library which might break on a lodash update

Add raw-loader and @types/lodash

npm install --save-dev @types/lodash raw-loader
#!/bin/sh
#
# 'tig-pick' is a wrapper script that uses 'tig' to pick a Git commit from the
# history. On success, the script prints the ID of the commit to standard
# output, so that it can be used as a parameter for subsequent commands, e.g.,
# 'git rebase -i $(tig-pick)'
#
# All parameters passed to the script will be forwarded to 'tig'.
#
#!/bin/sh
#
# 'tig-pick' is a wrapper script that uses 'tig' to pick a Git commit from the
# history. On success, the script prints the ID of the commit to standard
# output, so that it can be used as a parameter for subsequent commands, e.g.,
# 'git rebase -i $(tig-pick)'
#
# All parameters passed to the script will be forwarded to 'tig'.
#
@aztack
aztack / gist:4e1b46f5051e035b15378972f0558b17
Created September 25, 2024 06:35
extract-possible-values-of-classname-lepusCls
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable curly */
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable max-lines-per-function */
/* eslint-disable no-param-reassign */
/* eslint-disable prefer-template */
/* eslint-disable array-callback-return */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import 'colors';
@aztack
aztack / extract-tgz-in-browser.js
Created September 23, 2024 07:11
Extract tgz in browser
import pako from 'pako';
import { TarReader } from '@gera2ld/tarjs';
// Function to extract files from a .tgz file (Uint8Array)
async function extractTgz(tgzData) {
try {
// Step 1: Decompress the gzip using pako
const decompressedData = pako.ungzip(tgzData);
// Step 2: Create a Blob from the decompressed data
// Function to generate Mermaid graph code from package.json files
async function generateGraph(files: string[]) {
let graph = "graph TD;\n";
for (const file of files) {
const packageJson = JSON.parse(fs.readFileSync(file, 'utf-8'));
const packageName = await hashId(packageJson.name, packageJson.version);
if (packageJson.dependencies) {
for (const dependency in packageJson.dependencies) {
if (excludePkgs.find(p => dependency === p)) {
continue;
@aztack
aztack / AE CubicBezier.jsx
Created July 23, 2024 12:05 — forked from grishka/AE CubicBezier.jsx
After Effects cubic-bezier exporter
// Source: https://community.adobe.com/t5/after-effects-discussions/convert-ae-keyframes-info-to-cubicbezier-points/m-p/6139286#M135604
// Usage: select a layer, then File -> Scripts -> Run Script File... -> select this script
var curItem = app.project.activeItem;
var selectedLayers = curItem.selectedLayers;
var selectedProperties = curItem.selectedProperties;
var output="";
if (selectedLayers == 0) {
output="Please Select at least one Layer";
@aztack
aztack / AE CubicBezier.jsx
Created July 23, 2024 12:05 — forked from grishka/AE CubicBezier.jsx
After Effects cubic-bezier exporter
// Source: https://community.adobe.com/t5/after-effects-discussions/convert-ae-keyframes-info-to-cubicbezier-points/m-p/6139286#M135604
// Usage: select a layer, then File -> Scripts -> Run Script File... -> select this script
var curItem = app.project.activeItem;
var selectedLayers = curItem.selectedLayers;
var selectedProperties = curItem.selectedProperties;
var output="";
if (selectedLayers == 0) {
output="Please Select at least one Layer";
@aztack
aztack / getLayerType.jsx
Created May 29, 2024 04:48 — forked from zlovatt/getLayerType.jsx
ExtendScript: Get AE Layer Type
(function getSelectedLayerType() {
/**
* Gets the type of a given layer
*
* @param {Layer} layer Layer to check
* @return {string} Layer type
*/
function getLayerType(layer) {
switch (layer.matchName) {
case "ADBE Vector Layer":
@aztack
aztack / readable.ts
Last active May 8, 2024 07:35
Wrap promise for React Suspense
export function readable<R, E = unknown>(
promise: Promise<R>,
onSuccess?: (result: R) => void,
onError?: (error: E) => void)
{
let status = 'pending';
let result: R;
const suspender = promise.then(result => {
status = 'fulfilled';
onSuccess && onSuccess(result);