Skip to content

Instantly share code, notes, and snippets.

View BrianHung's full-sized avatar
💻
LLMs + local-first apps = autocomplete

Brian Hung BrianHung

💻
LLMs + local-first apps = autocomplete
View GitHub Profile
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@benweet
benweet / developer guide.md
Created June 16, 2013 17:00
StackEdit - Developer guide

Developer guide


Architecture

@tedw
tedw / fancy-underline.scss
Last active January 2, 2020 20:59
Fancy Link Underlines ala Medium.com – https://medium.com/designing-medium/7c03a9274f9
// Requires Bourbon
@import "bourbon/bourbon";
// Use CSS gradient and text shadow to create line that breaks for descenders
// Inspired by https://medium.com/designing-medium/7c03a9274f9
@mixin fancyUnderline( $color: currentColor, $bgcolor: #fff ) {
@include background-image( linear-gradient( to bottom, $bgcolor 50%, $color 50% ) );
background-position: 0 89%;
background-repeat: repeat-x;
background-size: 1px 1px;
@joakin
joakin / git-find-me-the-fucking-deleted-file.sh
Last active May 16, 2025 08:08
finding a deleted file in a git repository
# If you don't remember the exact path/name, search the log for deleted files
git log --diff-filter=D --summary | grep delete
# Find the file you want to get from the ouput, and use the path
# Find the commits that involved that path
git log --all -- some/path/to/deleted.file
# Bring the file back to life to the current repo (sha commit of parent of commit that deleted)
git checkout shaofthecommitthatdeletedthefile^ -- some/path/to/deleted.file
@paulirish
paulirish / what-forces-layout.md
Last active May 16, 2025 17:21
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@inexorabletash
inexorabletash / @ Indexed DB URLs via Service Workers.md
Last active February 17, 2025 21:36
Indexed DB URLs via Service Workers

URLs into Indexed DB, via Service Workers

Let's say you're using Indexed DB for the offline data store for a catalog. One of the object stores contains product images. Wouldn't it be great if you could just have something like this in your catalog page?

<img src="indexeddb/database/store/id">
@IMcPwn
IMcPwn / delete-all-messages.js
Last active April 10, 2025 03:36 — forked from niahoo/delete-all-messages.js
Delete all messages in a Discord channel
// Turn on Developer Mode under User Settings > Appearance > Developer Mode (at the bottom)
// Then open the channel you wish to delete all of the messages (could be a DM) and click the three dots on the far right.
// Click "Copy ID" and paste that instead of LAST_MESSAGE_ID.
// Copy / paste the below script into the JavaScript console.
// If you're in a DM you will receive a 403 error for every message the other user sent (you don't have permission to delete their messages).
var before = 'LAST_MESSAGE_ID';
clearMessages = function(){
const authToken = document.body.appendChild(document.createElement`iframe`).contentWindow.localStorage.token.replace(/"/g, "");
const channel = window.location.href.split('/').pop();
@zats
zats / FindReplace.json
Last active May 5, 2025 17:54
Alternative spellings for some emojis according to /System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/Resources/en.lproj/FindReplace.strings
{
"💍":"diamond | engagement ring | diamond ring | diamond rings | diamonds | engagement rings",
"🆎":"blood type AB",
"❣":"heart",
"🇱🇨":"Saint Lucia | Saint Lucian flag",
"🇮🇪":"Ireland | Irish flag",
"🇨🇮":"Côte d’Ivoire | Ivory Coast | Ivorian flag",
"💎":"diamond | gem | gemstone | jewel | diamonds | gems | gemstones | jewels",
"☠️":"skull and crossbones | poison | poisonous",
"👩‍💻":"technology worker | tech worker | technologist | techie | IT worker | Apple genius | woman in technology | woman tech worker | woman technologist | woman IT worker | woman in IT | woman Apple genius",
@ryandabler
ryandabler / IndexedDB example.js
Created May 2, 2018 01:50
Working example of an IndexedDB implementation to handle transactions surrounding a fake invoice database
const request = window.indexedDB.open("database", 1);
// Create schema
request.onupgradeneeded = event => {
const db = event.target.result;
const invoiceStore = db.createObjectStore("invoices", { keyPath: "invoiceId" });
invoiceStore.createIndex("VendorIndex", "vendor");
const itemStore = db.createObjectStore("invoice-items", { keyPath: ["invoiceId", "row"] });
@ajayjapan
ajayjapan / regionMonitoring.swift
Last active November 13, 2024 09:55
Here App Region Monitoring and Notification Trigger Logic
// MARK: - Significant location change montioring logic
// Called at launch of application if permission is already granted
func startMonitoringSignificantLocationChanges() {
locationManager.startMonitoringSignificantLocationChanges()
}
// Called by location manager if there is a significant location change
func locationManager(_ manager: CLLocationManager,
didUpdateLocations locations: [CLLocation]) {