Skip to content

Instantly share code, notes, and snippets.

View antfu's full-sized avatar

Anthony Fu antfu

View GitHub Profile
antfu / run.ts
Created January 12, 2023 19:51
Remove members with no team from GitHub's org
import 'dotenv/config'
import { Octokit } from '@octokit/core'
const org = process.env.SPONSORS_ORG!
const token = process.env.SPONSORS_TOKEN!
const octokit = new Octokit({ auth: token })
const allMembers = await fetchMembers(org)
const membersWithoutTeam = new Set( => m.login))
antfu /
Last active October 14, 2023 20:09
Doc Table in Markdown




// port form
// Create a safe reference to the getElementXpath object for use below.
const getElementXpath = function (el, callback) {
var err, result, nodes, i, n, segments, siblings, id_count;
try {
if (callback && (typeof callback !== "function")) {
throw new Error("Invalid callback supplied");
type Proxy = any[]
type Pop<T> = T extends [infer A, ...infer B] ? B : never
type Push<T> = T extends [...infer B] ? [any, ...B] : never
type Add<T extends Proxy, V extends Proxy> = [...T, ...V]
type Double<T extends Proxy> = [...T, ...T]
type Get<A extends Proxy> = A['length']
type AddOne<A extends Proxy> = Push<A>
type SubOne<A extends Proxy> = Pop<A>
import { UnionToIntersection } from 'utility-types';
type String<T> = T extends string ? T : any
type Keys<T, Field extends keyof T> =
T extends { [P in Field]: infer A }
? { [P in String<A>]: T }
: never
type LookupTable<Union, key extends keyof Union> = UnionToIntersection<Keys<Union, key>>
type Unexact<T> =
T extends null
? null
: T extends undefined
? undefined
: T extends number
? number
: T extends boolean
? boolean
: T extends string
type GetComponentProps<T> = T extends React.ComponentType<infer P>
? P
: T extends (props: any) => any
? Parameters<T>
: never;
class ClassComponent extends React.Component<{ a: number }> {
render() {
return <div />;
antfu /
Created July 16, 2020 03:03
Git remove files from all history
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch example.js'
antfu / html2pdf.js
Created May 5, 2020 18:06
import puppeteer from 'puppeteer'
import fs from 'fs'
async function buildPDF(htmlString) {
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage();
await page.setContent(htmlString, { waitUntil: 'networkidle0' })
const pdf = await page.pdf({
format: 'A4',
displayHeaderFooter: false,
antfu / resume.json
Last active November 28, 2023 17:15
"basics": {
"name": "Anthony Fu",
"picture": "",
"label": "Software Engineer",
"headline": "A ship in harbor is safe, but that is not what ships are built for.",
"summary": "My name is Anthony Fu, a master of computer science student and a freelance software engineer. My passion for software lies with dreaming up ideas and making them come true with elegant interfaces. I take great care in the experience, architecture, and code quality of the things I build.\n\nI am also an open-source enthusiast and maintainer. I love how collaboration and knowledge sharing happens through open-source and I am happy to see what I do could eventually feedback to the community and industry.",
"website": "",
"address": "",
"projects_url": "",