Skip to content

Instantly share code, notes, and snippets.


swyx sw-yx

View GitHub Profile
sw-yx / useLocalStorage.js
Last active Jul 2, 2021
SSR friendly version of useLocalStorage hook. you can also use this in a library
View useLocalStorage.js
// usage
function Comp() {
const [language, setLanguage] = useLocalStorage('mykey', 'typescript')
// definition
function useLocalStorage(key, initialValue) {
const [storedValue, setStoredValue] = React.useState(initialValue);
React.useEffect(() => {
// Get from local storage by key
View manual typography plugin since i got fed up with dark

this is what i use so far, its obviously not a 100% replica of the typography plugin but looks good enough on my site

  /* replace typography plugin */
  .prose {
    @apply text-gray-700 dark:text-gray-300
  .prose {
    & p {
sw-yx / Aprendiendoenpú
Created Nov 1, 2020
Aprendiendo en público - La forma más rápida de aprender. English:
View Aprendiendoenpú

Aprendiendo en público La forma más rápida de aprender

Si existiera una regla de oro sería esta, todas las demás reglas se derivan en mayor o menor medida de esta regla principal.

Está establecido que alguien nunca termina de aprender, sin embargo, la mayor parte de las personas “aprenden en privado” convirtiéndose en observadores pasivos. Consumen información sin generar ninguna. Mientras que este comportamiento no tiene nada de malo, aquí queremos llegar a estar entre el top de nuestra profesión y para conseguirlo es necesario tener el hábito de establecer sistemas para compartir nuestro aprendizaje:

• Crea blogs, tutoriales y cheat sheets.
• Realiza conferencias y meetups.

• Participa en foros como Stackoverflow o Reddit. Evita sitios privados como Slack o Discord.

vedam /
Last active Sep 12, 2022
links and ressources from the svelte-summit-2020 talks

You'll find the talks here

Morgan Williams @mrgnw

The Zen of Svelte

Approaching frontend as a backend developer, Svelte feels surprisingly pythonic. Let's take a quick look at what's familiar, what's foreign, and how to explore the gap.

sw-yx /
Last active Sep 28, 2021
Custom shortcode syntax for Elder.js

why you may need to customize shortcode syntax

  • elder.js self closing shortcodes look like this: {{foo bar="true"/}}. Note the / at the end is for Elder.js to parse both self closing and content wrapping shortcodes.
  • this clashes with other shortcode systems, eg., which uses shortcodes that look like this: {% youtube abc123 %}
  • in elder.config.js you can customize the start and end shortcode: {%foo bar="true"/%}
  • however that / there is non negotiable.
  • this is why you need to customize the shortcode syntax

the strategy is, if you use remark to process the text, to write a custom remark plugin to replace specifically this %} ending code of the shortcode to what Elder.js expects

View Open letter to the Gatsby

To the Gatsby Community,

We want to start by specifically thanking Nat Alison. We support her and commend her bravery in speaking out. It is not easy to stand alone. What she experienced at Gatsby was unacceptable and speaks to wider issues. We thank her for putting pressure on the company to fix them. We vow to double down on those efforts.

While we have worked hard to give feedback and help create a healthy work environment over the past few years, change has been far too slow and the consequences have been real. The previous weeks have intensified the need for rapid change by increasing employee communication and allowing us to collectively connect some dots. We are just as outraged. As a result, we have posed a series of hard questions to management as well as a list of concrete actions they need to take.

Kyle Mathews' public apologies to both Nat Alison and Kim Crayton are small actions swiftly taken that signal the possibility for change but don't speak to the systemic issues that must be addressed.

sw-yx / types for estree with JSX.ts
Last active Aug 7, 2020
types for estree with JSX - the default estree types ( dont come with JSX definitions so i made a short start on them. pls comment if you have more to add
View types for estree with JSX.ts
interface Location {
start: number;
end: number;
interface JSXOpeningElement extends Location {
type: 'JSXOpeningElement',
attributes: JSXAttribute[],
name: JSXIdentifier,
selfClosing: boolean
mlent / social-sharing-buttons.html
Last active Aug 21, 2022
Social sharing buttons
View social-sharing-buttons.html
<a href=" OF YOUR POST via @YOUR_USERNAME&url=HTTPS://YOUR_WEBSITE.COM" onclick=", 'twitter-share', 'width=550,height=235'); return false;">
Share on Twitter
<a href=" CONTENT" onclick=", 'hn-share', 'width=550,height=350'); return false;">
Share on Hacker News
tlakomy / Production Ready Serverless
Last active Jan 10, 2022
Notes from Production Ready Serverless course with theburningmonk
View Production Ready Serverless

Week 01

Lambda 101:

  • You can pin frequently used services to top bar in AWS Console
  • By default there's a limit of 1000 concurrent lambda executions, this can be raised with a support ticket. There are companies that have this limit raised up to tens of thousands concurrent lambda executions.
  • By default you get 75GB of code storage (so up to 10 React apps, lol) which can also be raised
  • Looking at Throttles graph is useful, we don't want our functions to be throttled
  • ConcurrentExecutions graph is useful as well - to understand if we're not approaching a limit
  • You can search for lambda functions using function name (adding prefixed help!) or using tags, which are really useful
  • It's possible to use custom runtimes for Lambda (apart from Node,.NET, Python etc.) so if you really want to use Haskell you can do that
sw-yx /
Last active Jan 16, 2022
svelte society day talks and resources -