Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 05:24
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
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@benwattsjones
benwattsjones / gmail_mbox_parser.py
Last active April 23, 2024 18:31
Quick python code to parse mbox files, specifically those used by GMail. Extracts sender, date, plain text contents etc., ignores base64 attachments.
#! /usr/bin/env python3
# ~*~ utf-8 ~*~
import mailbox
import bs4
def get_html_text(html):
try:
return bs4.BeautifulSoup(html, 'lxml').body.get_text(' ', strip=True)
except AttributeError: # message contents empty
@agnoster
agnoster / README.md
Last active April 6, 2024 22:35
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@mstevenson
mstevenson / SaveFBX.cs
Created August 5, 2013 20:05
ASCII FBX file exporter for Unity. Extracted from Michal Mandrysz's Unity Summer of Code 2009 external lightmapping project.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
/*
@nicdaCosta
nicdaCosta / Grep.js
Last active March 9, 2024 13:39
Basic function that searches / filters any object or function and returns matched properties.
/*
Grep.js
Author : Nic da Costa ( @nic_daCosta )
Created : 2012/11/14
Version : 0.2
(c) Nic da Costa
License : MIT, GPL licenses
Overview:
Basic function that searches / filters any object or function and returns matched properties.
@jasonm23
jasonm23 / xterm-256color.svg
Last active February 11, 2024 12:33
Xterm 256color mode color chart, organised into sections. (used on Wikipedia/xterm)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylebarrow
kylebarrow / example.html
Created June 23, 2011 06:30
Prevent links in standalone web apps opening Mobile Safari
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@ebidel
ebidel / mo_vs.proxy.js
Last active December 31, 2023 12:24
MutationObserver vs. Proxy to detect .textContent changes
<!--
This demo shows two ways to detect changes to a DOM node `.textContent`, one
using a `MutationObserver` and the other using an ES2015 `Proxy`.
From testing, a `Proxy` appears to be 6-8x faster than using a MO in Chrome 50.
**Update**: removing the `Proxy` altogether speeds up the MO to be inline with the Proxy.
This has something to do with how the browser queues/prioritizes Proxies over MO.
@AlbertoEAF
AlbertoEAF / gmail_mbox_parser.py
Last active September 29, 2023 18:27 — forked from benwattsjones/gmail_mbox_parser.py
Extension of gmail_mbox_parser.py to parse GMail's Google Takeout exports in .mbox format and do clustering analysis of senders so you can quickly triage which kind of information sources might no longer be relevant. It also adds command line arguments and exports the sender's statistics in a .csv file.
#! /usr/bin/env python3
# ~*~ utf-8 ~*~
# About: Extension of gmail_mbox_parser.py to parse GMail's Google Takeout exports in .mbox format and do clustering analysis of senders so you can quickly triage which kind of information sources might no longer be relevant. It also adds command line arguments and exports the sender's statistics in a .csv file.
# Based on https://gist.github.com/benwattsjones/060ad83efd2b3afc8b229d41f9b246c4 but expanded to add command line arguments, do clustering of senders and export a .csv with those statistics.
import re
import argparse
import mailbox
from collections import Counter