Skip to content

Instantly share code, notes, and snippets.

View 0x80's full-sized avatar

Thijs Koerselman 0x80

View GitHub Profile
@0x80
0x80 / how-to-write-clean-typed-firestore-code.md
Last active February 3, 2025 20:56
How to use Firestore with Typescript in 2025

How to write clean, typed Firestore code

The article below was posted on Dev.to

Ever since I started using Firestore more than 7 years ago, I have been wanting to find a better way to type my code and reduce boilerplate. In this article I will explain how I finally found a way to write clean, strongly-typed code with abstractions that are easy to use and adopt in any Typescript project.

TL;DR

By defining typed reusable references for all database collections, we can let other functions infer their types from them, sparing us from having to import and apply types all over the place.

@0x80
0x80 / vite.config.ts
Last active October 1, 2024 05:42
Vite bundling for a modern Node.js target
import { builtinModules } from "node:module";
import { resolve } from "node:path";
import { defineConfig } from "vite";
import { dependencies, name } from "./package.json";
/**
* Core modules could be imported in two ways, with or without the `node:`
* specifier, so we create a list of all possible core modules.
*/
const allCoreModules = builtinModules.flatMap((moduleName) => [
/* ----------------------------------------------------------------------------------------------------
Super Form Reset
A couple of things to watch out for:
- IE8: If a text input doesn't have padding on all sides or none the text won't be centered.
- The default border sizes on text inputs in all UAs seem to be slightly different. You're better off using custom borders.
- You NEED to set the font-size and family on all form elements
- Search inputs need to have their appearance reset and the box-sizing set to content-box to match other UAs
@0x80
0x80 / mongo-autostart-osx.md
Created February 11, 2016 09:04 — forked from subfuzion/mongo-autostart-osx.md
mongo auto start on OS X

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

@0x80
0x80 / index.js
Last active August 29, 2015 14:25 — forked from royriojas/index.js
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var esformatter = require( 'esformatter' );
var esformatterJSX = require( 'esformatter-jsx' );
var collapser = require('esformatter-collapse-objects')
var throttle = require('lodash.throttle');
var testCode =
'/*\nHere are three es6 related issues with standard-format.\nOne can be solved by a setting I suppose. The others probably require a \nfix in esformatter\n*/\n' +
'class Foo extends React.Component {\n' +