This file contains 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
# extracted from http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip | |
# under public domain terms | |
country_bounding_boxes = { | |
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)), | |
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)), | |
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)), | |
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)), | |
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)), | |
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)), |
This file contains 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
/* Copy of the CSS at https://piccalil.li/blog/a-more-modern-css-reset/ */ | |
/* Box sizing rules */ | |
*, | |
*::before, | |
*::after { | |
box-sizing: border-box; | |
} | |
/* Prevent font size inflation */ |
This file contains 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
// This will remove the grant, i.e. as if the user never registered with the app. | |
// They will have to go trough the consent screen again | |
await ky | |
.delete(`https://api.github.com/applications/${event.locals.env.AUTH_GITHUB_ID}/grant`, { | |
headers: { | |
Accept: 'application/vnd.github+json', | |
Authorization: `Basic ${btoa(`${event.locals.env.AUTH_GITHUB_ID}:${event.locals.env.AUTH_GITHUB_SECRET}`)}`, | |
'X-GitHub-Api-Version': '2022-11-28', | |
}, | |
json: { |
This file contains 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
/** | |
* Debounce the input value change event | |
* | |
* Copied from https://github.com/svelte-seoul/svelte-debounce/blob/master/index.js and added types | |
* | |
* Example: run console.log after 750ms of the last input event, no matter how many input events are fired | |
* | |
* ```svelte | |
* <input use:debounce={{callback: console.log}} /> | |
* ``` |
This file contains 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
import {fromString, type TypeID} from 'typeid-js' | |
import * as v from 'valibot' | |
/** | |
* Create a Valibot schema for a TypeID with a given prefix | |
* | |
* Example: | |
* | |
* ```ts | |
* const PigIdSchema = TypeIDSchema('pig') |
This file contains 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
import {CascaderOptionType, FilledFieldNamesType} from 'antd/lib/cascader' | |
export const caseInsensitiveFilter = (inputValue: string, path: CascaderOptionType[], names: FilledFieldNamesType) => | |
path.some((option) => option[names.label].toLowerCase().includes(inputValue.toLowerCase())) |
This file contains 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
validate_and_squash_this_branch () { | |
BRANCH=`git branch --show-current` | |
yarn validate && \ | |
git checkout master && \ | |
git merge --squash $BRANCH && \ | |
git commit -v -a | |
} |
This file contains 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
|
This file contains 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
async function fetchOnceAndSaveToDiskWithBuffer(url, filename) { | |
return new Promise(resolve => { | |
if (fs.existsSync(filename)) { | |
resolve(readFile(filename)); | |
return; | |
} | |
const file = fs.createWriteStream(filename); | |
NewerOlder