Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

swyx sw-yx

🎯
Focusing
View GitHub Profile
@sw-yx
sw-yx / cloudos.md
Last active February 3, 2023 19:41
Cloud Operating Systems and Reconstituting the Monolith. tweet responses: https://twitter.com/swyx/status/1226257539886669825?s=20
View cloudos.md
@sw-yx
sw-yx / 1.md
Last active February 2, 2023 07:17
Learn In Public - 7 opinions for your tech career
View 1.md

2019 update: this essay has been updated on my personal site, together with a followup on how to get started

2020 update: I'm now writing a book with updated versions of all these essays and 35 other chapters!!!!

1. Learn in public

If there's a golden rule, it's this one, so I put it first. All the other rules are more or less elaborations of this rule #1.

You already know that you will never be done learning. But most people "learn in private", and lurk. They consume content without creating any themselves. Again, that's fine, but we're here to talk about being in the top quintile. What you do here is to have a habit of creating learning exhaust. Write blogs and tutorials and cheatsheets. Speak at meetups and conferences. Ask and answer things on Stackoverflow or Reddit. (Avoid the walled gardens like Slack and Discourse, they're not public). Make Youtube videos

@sw-yx
sw-yx / flexbox-cheat-sheet.md
Last active January 19, 2023 07:35
cheat sheet from flexbox.io
View flexbox-cheat-sheet.md
@sw-yx
sw-yx / createCtx-noNullCheck.tsx
Last active January 17, 2023 15:32
better createContext APIs with setters, and no default values, in Typescript. this is documented in https://github.com/typescript-cheatsheets/react-typescript-cheatsheet/blob/master/README.md#context
View createCtx-noNullCheck.tsx
// create context with no upfront defaultValue
// without having to do undefined check all the time
function createCtx<A>() {
const ctx = React.createContext<A | undefined>(undefined)
function useCtx() {
const c = React.useContext(ctx)
if (!c) throw new Error("useCtx must be inside a Provider with a value")
return c
}
return [useCtx, ctx.Provider] as const
@sw-yx
sw-yx / Tailwindcssunreset.scss
Last active January 13, 2023 07:50
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
View Tailwindcssunreset.scss
.unreset {
a {
@apply text-blue-700 underline;
}
p {
@apply my-4;
}
blockquote,
figure {
View .gitignore_global
# run git config --global core.excludesfile ~/.gitignore_global
.DS_Store
._.DS_Store
**/.DS_Store
**/._.DS_Store
.vscode
.idea
Thumbs.db
@sw-yx
sw-yx / scrape.js
Created November 1, 2022 06:10
how to scrape folder start dates from git
View scrape.js
const { exec } = require('child_process');
// exec(`
// git log --reverse -- /Users/swyx/Desktop/Work/airbyte/airbyte-integrations/connectors/destination-amazon-sqs | awk 'NR>1 {print last} {last=$0}; /^commit/ && ++c==2{exit}'
// `, (err, stdout, stderr) => {
// if (err) {
// // node couldn't execute the command
// return;
@sw-yx
sw-yx / gist:135136c1217b038e4b897415845e8150
Last active October 20, 2022 18:01
prompts used for Airbyte Data Nets article https://airbyte.com/blog/data-nets
View gist:135136c1217b038e4b897415845e8150
1. Introduction
2. What are Data Nets?
3. Data Nets vs. Data Mesh
4. Data Nets vs. Data Contract
5. When do you need a Data Net?
@sw-yx
sw-yx / openaiscript.py
Last active October 18, 2022 05:05
web scraping + gpt3. given a company name we scrape google for relevant urls and then scrape those urls for info. persisting each step in case google blocks, so we can switch IP and carry on. once we accumulated our corpus, feed into openai to generate company categories and descriptions.
View openaiscript.py
# https://beta.openai.com/docs/libraries
import os
import openai
import yaml
# Load your API key from an environment variable or secret management service
openai.api_key = os.getenv("OPENAI_API_KEY")