This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/** | |
* Create top contributors list for a GitHub organization. | |
* Usage: ./gh-org-top-contributors.ts <org-name> | |
*/ | |
const accessToken = process.env.GITHUB_TOKEN || process.env.GH_TOKEN || 'your-token' | |
const headers = { | |
Authorization: `token ${accessToken}`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a copy of: | |
# https://gist.github.com/wojtekmaj/6defa1f358daae28bd52b7b6dbeb7ab6 | |
# read the comments | |
# Also: npx codemod jest/vitest | |
# Ensure we're working on the latest version of the main branch | |
# git switch develop | |
# git fetch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('node:fs') | |
const path = require('node:path') | |
const glob = require('glob') | |
// Find all Vue files | |
const vueFiles = glob.sync(path.join(__dirname, '../**/*.vue')) | |
vueFiles.forEach(filePath => { | |
let content = fs.readFileSync(filePath, 'utf8') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A class for storing and retrieve compressed objects into local storage. | |
*/ | |
export class CompressedStorage { | |
async get(key: string) { | |
const base64 = localStorage.getItem(key); | |
if (base64 === null) { | |
return null; | |
} | |
const blob = await this.fromBase64Url(base64); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple way to store binary data inside a js/ts file with a density of 1 char per byte. | |
// Even though each char takes 2 bytes. | |
const b256enc = (buff: Uint8Array) => [...buff].map(i => String.fromCodePoint(i + 192)).join(''); | |
const b256dec = (str: string) => str.split('').map(c => c.charCodeAt(0) - 192); | |
// Example 1: Basic usage | |
const data = new Uint8Array([ 127, 127, 168, 226, 120, 62, 44, 146, 82, 213, 0, 30 ]); | |
const encoded = b256enc(data); | |
console.log(encoded); // 'ĿĿŨƢĸþìŒĒƕÀÞ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function packUUID(uuid: string): string { | |
let v; | |
let bytes = ''; | |
// Parse ########-....-....-....-............ | |
bytes += String.fromCharCode((v = parseInt(uuid.slice(0, 8), 16)) >>> 24); | |
bytes += String.fromCharCode((v >>> 16) & 0xff); | |
bytes += String.fromCharCode((v >>> 8) & 0xff); | |
bytes += String.fromCharCode(v & 0xff); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="loader"></div> | |
<style> | |
.loader { | |
--size: 5rem; | |
--weight: .5rem; | |
--background: rgba(127, 127, 127, .1); | |
--color: rgba(127, 127, 127, .9); | |
--duration: 1s; | |
position: fixed; | |
top: calc(50% - var(--size) / 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Unsubscribe from all "orgName" repositories in https://github.com/watching | |
* | |
* https://github.com/isaacs/github/issues/641 | |
* @param string orgName | |
*/ | |
function unwatchOrgRepos(orgName) { | |
if (!window.location.href.startsWith('https://github.com/watching')) { | |
throw new Error('This script is intended to be run in "https://github.com/watching"') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Locale strings | |
* You can get it from https://github.com/iamkun/dayjs/blob/dev/src/locale/ | |
*/ | |
const loc = { | |
future: 'in %s', | |
past: '%s ago', | |
s: 'a few seconds', | |
m: 'a minute', |
NewerOlder