Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active December 8, 2025 09:19
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 December 1, 2025 11:31
The introduction to Reactive Programming you've been missing

Richard Garriott 談談為什麼「大部分的遊戲設計師都很爛」

Tyler Wilde at 07:27 on 20 March 2013

http://media.pcgamer.com/files/2013/03/richard-garriott-ultima.jpg

當 Ultima 作者 Richard Garriott 向我展示他那剛剛在 Kickstarter 上募資超過百萬美金的新 RPG , Shroud of the Avatar 時,他也帶了些有故事的東西來。首先是個散裝著橫線紙的資料夾 -- Ultima 世界的第一筆紀錄,記載著 Sasaria 、 Lord British 和邪惡的 Mondain 。「天啊!」我想,「這些東西應該擺在博物館裡。」

「這是 Ultima 的創始文件,甚至比 Ultima I 更早,」 Garriott 這樣說。「那時是 1976 ,在我還沒寫任何一行程式碼之前。這是一個有關 Sosaria 世界的月之城, Lord British 跟邪惡巫師 Mondain 的故事,讓我在英文課上拿到個罕見的「A」,通常我都不及格。這甚至早在個人電腦出現之前。」

@jonathantneal
jonathantneal / README.md
Last active November 9, 2023 21:10
createElement.js // a 300 byte DOM Element creator

createElement.js

createElement.js lets document.createElement use CSS selectors.

This is a pretty useful library for building out DOM elements. The whole thing runs on one regex and a for loop, so it’s plenty fast. The script is 300 bytes when compressed and gzipped. For 524 bytes (advanced), it includes nesting support and can generate entire DOM hierarchies, including text nodes.

Usage

document.createElement(); // generates <div />
@rxaviers
rxaviers / gist:7360908
Last active December 15, 2025 06:00
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@metatoaster
metatoaster / app.py
Last active May 10, 2024 01:45
Flask Principal Permission override demo
from flask import Flask, request, abort, g, current_app
from flask.ext.principal import Principal
from flask.ext.principal import Identity, identity_changed, identity_loaded
from flask.ext.principal import Permission, Need, RoleNeed, ItemNeed
app = Flask(__name__)
app.config['SECRET_KEY'] = 'test_secret_key'
app.config['TESTING'] = True

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@darktable
darktable / MiniJSON.cs
Created November 30, 2011 23:08
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@href
href / dict_namedtuple.py
Created October 27, 2011 12:00
Convert any dictionary to a named tuple
from collections import namedtuple
def convert(dictionary):
return namedtuple('GenericDict', dictionary.keys())(**dictionary)
"""
>>> d = dictionary(a=1, b='b', c=[3])
>>> named = convert(d)
>>> named.a == d.a
True
>>> named.b == d.b