Skip to content

Instantly share code, notes, and snippets.

View swyxio's full-sized avatar
🎯
Focusing

swyx.io swyxio

🎯
Focusing
View GitHub Profile

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 {
@swyxio
swyxio / svelte.md
Last active November 20, 2020 14:45
Svelte micro-RFC: configurable event modifiers

This is a micro RFC because i'm just jotting down an idea that I would love to have for Svelte, but I'm not sure if it belongs as an official RFC yet. the official RFC process offers no room for lightweight proposals so i am writing a gist.

see also Twitter discussion


The Problem

Svelte offers very useful event modifiers like preventDefault and once.

@swyxio
swyxio / Newton-1.29.vb
Last active July 10, 2022 08:34
Newton - my VBA utility library for doing matrix multiplication and other useful automations during my finance days https://twitter.com/swyx/status/1327041894853922816
Attribute VB_Name = "Newton"
'Newton Utilities, written by swyx
'Project initiated Jan 1 2012
'V1 released Feb 5 2012
'V1.1 added and renamed functions, updated helpfiles Apr 8 2012
'V1.2 spline interp extraction from surface, n_RandomWalk. released Jun 15 2012
'V1.21 n_Corr, n_TangencyPortfolio, n_CovMat subsumed into n_Cov, fixed n_GetTimeSeries, n_AutoCorr, n_Lag, n_Pval, added PValues to n_Regress, n_Payback, n_ChartMakeScatter
'V1.22 n_Granger, pval for n_Corr, n_Divide, n_Curve, n_PriceIRS, upgraded n_BuildCurve
'V1.23 n_PriceFwd/Rate, n_AutoRegress/n_Remove_AutoRegress (needs work), augmented n_PriceOption for pricing FXO, digitals, and returning greeks
'V1.24 n_FXOVolCurve, n_FormatAsPercent linked to ctrl+shift+5, n_FormatInc/DecreaseDecimalPlace
@swyxio
swyxio / Aprendiendoenpúblico.md
Created November 1, 2020 21:03
Aprendiendo en público - La forma más rápida de aprender. English: http://swyx.io/learn-in-public

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.

@swyxio
swyxio / diversity in tech.md
Created October 6, 2020 12:01
diversity in tech resources and organizations. done as part of research for learninpublic.org

US Centric (but often Worldwide)

Don't forget there are many state and city level organizations that can help you too.

Women

  • US centric/Global:
    • Wonder Women Tech - We highlight, celebrate, and educate Women and the Underrepresented in Science, Technology, Engineering, the Arts, Math (STEAM) and Innovation. We nourish the global life cycle of the pipeline through equity, access, and opportunity.
    • FWD: For Women & Diversity Collective - We are a community dedicated to professional inclusion. We host summits & workshops featuring women, P.O.C., and under-represented groups for the experts that we are rather than the boxes that we check.
@swyxio
swyxio / elderjs-shortcode-motivation.md
Last active September 28, 2021 03:10
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. dev.to, 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 dev.to shortcode to what Elder.js expects

import React from "react";
export type ColorScheme = "light" | "dark";
export default function useColorSchemePreference(
defaultColorScheme: ColorScheme = "light"
) {
let darkQuery = "(prefers-color-scheme: dark)";
let [colorScheme, setColorScheme] = React.useState<ColorScheme>(
typeof window === "object" && window.matchMedia
@swyxio
swyxio / types for estree with JSX.ts
Last active August 7, 2020 01:56
types for estree with JSX - the default estree types (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/estree/index.d.ts) dont come with JSX definitions so i made a short start on them. pls comment if you have more to add
interface Location {
start: number;
end: number;
};
interface JSXOpeningElement extends Location {
type: 'JSXOpeningElement',
attributes: JSXAttribute[],
name: JSXIdentifier,
selfClosing: boolean
@swyxio
swyxio / mobilenav.svelte
Created June 30, 2020 21:13
my mobile responsive nav
<script>
import { clickOutside } from "./actions.js";
let activeNav = "Home";
let isMobile;
let isMobileAndNavActive = false;
// $: console.log({ isMobile, isMobileAndNavActive });
function handleClickOutside() {
if (isMobile && isMobileAndNavActive) {
isMobileAndNavActive = !isMobileAndNavActive;
@swyxio
swyxio / stringify.ts
Created June 6, 2020 00:55
JSON stringify replacer (no circular deps) pretty printer
import parse5 from 'parse5'
var src = `
{#if name}
<script>
console.log('not top level')
</script>
{/if}
<ul>
{#each cats as cat}