Skip to content

Instantly share code, notes, and snippets.

View swyxio's full-sized avatar
🎯
Focusing

swyx.io swyxio

🎯
Focusing
View GitHub Profile
@swyxio
swyxio / Tailwindcssunreset.scss
Last active February 14, 2024 01:19
Tailwind CSS Un-Reset - un-reset Tailwind's Preflight CSS Reset so that autogenerated HTML looks consistent with the rest of your Tailwind site. - https://www.swyx.io/writing/tailwind-unreset
.unreset {
a {
@apply text-blue-700 underline;
}
p {
@apply my-4;
}
blockquote,
figure {
@swyxio
swyxio / chatscroller.jsx
Last active November 15, 2020 21:55
Handy Scroll window manager component for building a Slack-like Chat experience - when you want your chat window to autoscroll down when new messages appear, BUT not while you're scrolling up. Also useful for feedlike or log display components. from ryan florence workshop chat example (course at https://courses.reacttraining.com/courses/517181/…
function ChatScroller(props) {
const ref = useRef()
const shouldScrollRef = useRef(true)
useEffect(()=> {
if (shouldScrollRef.current) {
const node = ref.current
node.scrollTop = node.scrollheight
}
})
const handleScroll = () => {
import React, { useEffect } from "react"
import { META_DESCRIPTION } from "../../util"
export const Page: React.FC<{
title?: string
metaDescription?: string
}> = props => {
useEffect(() => {
document.title = props.title ?? "Execute Program"
@dabit3
dabit3 / datastore.md
Last active December 10, 2023 03:52
Building offline apps with Amplify DataStore

Building offline apps with Amplify DataStore

To view and deploy the app covered in this chapter, check out this repo.

So far in this book we've worked with both REST APIs and GraphQL APIs. When working with the GraphQL APIs so far, we've used the API class to directly call mutations and queries against the API.

Amplify also supports another type of API for interacting with AppSync, Amplify DataStore. DataStore has a different approach than a traditional GraphQL API.

Instead of interacting with the GraphQL API itself using queries and mutations, DataStore introduces a client-side SDK that persists the data locally using the local storage engine of the platform you are working with (i.e. IndexDB for web, SQLLite for native iOS and Android). DataStore then automatically syncs the local data to the GraphQL backend for you as updates are made both locally and remotely.

@Disturbing
Disturbing / kinto-compose-proposal.md
Last active April 1, 2020 04:12
Kinto Compose Proposal

KintoCompose Proposal

One of the earliest goals of Kinto team was to make every Git repository deployable to the cloud and compatible with any other repository. KintoCompose will aim to do this as an open source initiative.

  • Kinto is inspired by the kinto'un which is the magic cloud that Son Goku rides in Dragon Ball Z, or Wu Kong in the journey to the west.
  • Compose inspired by docker-compose and go modules through combining git repositories and their configuration to be served into any cloud via kubernetes.

KintoCompose Goals

  • Serve any Git repository into a public and private endpoint with ease.
@swyxio
swyxio / react-router-dom-v6.d.ts
Last active October 4, 2022 00:36
react router dom v6 types - i have not tested this in all cases, nor have i ensured this covers the full api, - this should just be a nice drop in single .d.ts file that covers basic usecases detailed in https://dev.to/emreloper/react-router-v6-in-two-minutes-2i96, including inlining the necessary types for history and react-router
// // with thanks
// https://dev.to/emreloper/react-router-v6-in-two-minutes-2i96
// https://github.com/ReactTraining/react-router/blob/dev/docs/installation/getting-started.md
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/9d29adedf662de685356f711951ef8b9e8342865/types/react-router/index.d.ts#L1
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/9d29adedf662de685356f711951ef8b9e8342865/types/react-router-dom/index.d.ts#L1
// // release notes
// https://github.com/ReactTraining/react-router/releases/tag/v6.0.0-alpha.3
declare module "react-router-dom" {
@swyxio
swyxio / cloudos.md
Last active May 3, 2023 12:23
Cloud Operating Systems and Reconstituting the Monolith. tweet responses: https://twitter.com/swyx/status/1226257539886669825?s=20
@nileshtrivedi
nileshtrivedi / composable_web.md
Last active January 10, 2022 04:31
My thoughts on making the Web more composable like UNIX

The Composable Web Proposal

Serverless infrastructure like AWS Lambda and Google Cloud Functions have made it much cheaper for developers to offer server-side code for public consumption without keeping a server always running.

If these functions could be declared as stateless or deterministic, costs can be brought down even more because only the first invocation needs to be executed. Cached response could be returned for future invocations with the same input arguments.

All modern browsers support URL lengths of thousands of characters, even on mobile. A lot of data can be embedded and passed around directly in the URLs (instead of passing identifiers which requires a look-up which costs server time).

So here's a thought:

Reach UI Philosophy

Reach UI is an accessible foundation for React applications and design systems.

The three equally important goals are to be:

  • Accessible
  • Composable
  • Stylable
OSZAR »