Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / what-forces-layout.md
Last active Oct 30, 2020
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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
@ImJasonH
ImJasonH / markdown.css
Last active Oct 19, 2020
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
View markdown.css
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@ericclemmons
ericclemmons / example.md
Last active Oct 8, 2020
HTML5 <details> in GitHub
View example.md

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 <summary>Summary Goes Here</summary>
@bxt
bxt / proxy.py
Last active Aug 30, 2020
A very basic caching python HTTP proxy server.
View proxy.py
# Originally from http://sharebear.co.uk/blog/2009/09/17/very-simple-python-caching-proxy/
#
# Usage:
# A call to http://localhost:80000/example.com/foo.html will cache the file
# at http://example.com/foo.html on disc and not redownload it again.
# To clear the cache simply do a `rm *.cached`. To stop the server simply
# send SIGINT (Ctrl-C). It does not handle any headers or post data.
import BaseHTTPServer
import hashlib
@mmerickel
mmerickel / cors.py
Last active Apr 24, 2020
cors in pyramid
View cors.py
from pyramid.security import NO_PERMISSION_REQUIRED
def includeme(config):
config.add_directive(
'add_cors_preflight_handler', add_cors_preflight_handler)
config.add_route_predicate('cors_preflight', CorsPreflightPredicate)
config.add_subscriber(add_cors_to_response, 'pyramid.events.NewResponse')
class CorsPreflightPredicate(object):
@gosko
gosko / dt
Created Mar 24, 2020
dt - display current date/time in various time zones
View dt
#!/bin/bash
#
# dt: display useful date/time info incl current time in various time zones
#
# any optional extra args are passed along to date, e.g. '--date "2 weeks ago"'
#
echo
/usr/bin/cal -3
echo
@vincent-zurczak
vincent-zurczak / Validator.java
Last active Jan 17, 2020
HTML 5 validation in Java (based on the Nu HTML Checker)
View Validator.java
/**
* Verifies that a HTML content is valid.
* @param htmlContent the HTML content
* @return true if it is valid, false otherwise
* @throws Exception
*/
public boolean validateHtml( String htmlContent ) throws Exception {
InputStream in = new ByteArrayInputStream( htmlContent.getBytes( "UTF-8" ));
ByteArrayOutputStream out = new ByteArrayOutputStream();
@tylor
tylor / Procfile
Created Dec 7, 2012
Quick node.js HTTP proxy on Heroku
View Procfile
web: node index.js
View rules.md

Room Rules


1. Speak English!

2. Don't be a dick!

@henare
henare / mw-to-gollum.rb
Created Mar 10, 2011
Imports a MediaWiki XML export into a Gollum wiki
View mw-to-gollum.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'gollum'
wiki = Gollum::Wiki.new('openaustralia.wiki')
file = File.open("OpenAustralia-20110309232515.xml", "r")
doc = Hpricot(file)
You can’t perform that action at this time.