Skip to content

Instantly share code, notes, and snippets.

View mithi's full-sized avatar

Mithi Sevilla mithi

View GitHub Profile
@Lure5134
Lure5134 / VirtualList.svelte
Last active June 23, 2025 07:00
A virtual list for svelte 5.
<script lang="ts" generics="T">
import { onMount, tick, type Snippet } from "svelte";
const {
items,
height,
itemHeight,
children,
getKey,
}: {
@AnastasiaDunbar
AnastasiaDunbar / furigana syntax to HTML ruby markup.js
Created October 16, 2022 02:24
`[kanji]{kana}` furigana syntax to HTML <ruby> markup, would've been nice as a Markdown extension.
(string=>{
string=string.replace(/(\[[^\]]+\]{[^{]+})+/g,x=>"<ruby>"+x+"</ruby>");
var multiReplace=(s,o)=>{
for(var key in o){ //What if there were collisions (replacing what's already been replaced)?
s=s.replace(key,o[key]);
}
return s;
},matches=[...string.matchAll(/\[[^\]]+\]{[^{]+}/g)],iShift=0;
for(var i=0;i<matches.length;i++){
var index=matches[i].index,length=matches[i][0].length,
@plembo
plembo / ghpwithnamecheap.md
Last active June 24, 2025 21:12
GitHub Pages with Namecheap custom domain

Using GitHub Pages with a custom domain: Namecheap Edition

As often happens, I found the official documentation and forum answers to be "close, but no cigar", and so had to experiment a little to get things working.

The main problem for me was a lack of concrete configuration examples. That's not entirely GitHub's fault: having migrated from Google Domains to Namecheap in the middle of this project, I was once again reminded of how many different ways there are to do things in the name service universe [1].

Although you'd think the simplest setup would be to merely configure for the subdomain case (https://www.example.com), in my experience using the apex domain (https://example.com) instead resulted in fewer complications.

Procedure

So here's my recipe for using a custom domain with GitHub pages where Namecheap is the DNS provider:

@didacus
didacus / useWindowSize.js
Created January 29, 2021 16:12
React hook to capture window size (Debounced).
import { useState, useEffect } from "react"
// Debounce function
function debounce(func, wait, immediate) {
var timeout
return function () {
var context = this,
args = arguments
var later = function () {
timeout = null
@Ciantic
Ciantic / example-typeorm-jest.test.ts
Created April 16, 2019 17:50
Example of testing TypeOrm with Jest and Sqlite in-memory database
import { createConnection, getConnection, Entity, getRepository } from "typeorm";
import { PrimaryGeneratedColumn, Column } from "typeorm";
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn()
id?: number;
@Column()
name?: string;
@techniq
techniq / axis.d.ts
Created December 30, 2018 15:45
@vx typings
declare module '@vx/axis' {
import React from 'react';
import { ScaleTime } from 'd3-scale';
interface Point {
x: number;
y: number;
}
interface AxisProps {
function fullSync(page = 1) {
let open = indexedDB.open("books", 1);
// Set up the database schema
open.onsuccess = evt => {
let db = open.result;
fullSyncPage(db, 1);
};
}
@indiesquidge
indiesquidge / advanced-react-notes.md
Last active January 19, 2024 15:57
Personal notes while working through Advanced React: https://courses.reacttraining.com/p/advanced-react

Advanced React by React Training

Personal notes while working through Advanced React: https://courses.reacttraining.com/p/advanced-react

Granted this is a contrived example, but it's still something I took notice to: in those "Advanced React" videos I've been watching, Ryan Florence codes very slowly, and does not make one quick change and jump back to the browser to see what changed.

He stops and thinks. He asks himself (or the viewer) questions. He wonders what

@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 28, 2025 20:00
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux