Skip to content

Instantly share code, notes, and snippets.

View mathiasbynens's full-sized avatar

Mathias Bynens mathiasbynens

View GitHub Profile
@mathiasbynens
mathiasbynens / some-more-info-on-css-hacks.md
Created May 25, 2011 17:33
Some more info on CSS hacks

There seems to be a difference between longhand properties (e.g. background-color) and shorthand properties (e.g. background). Some CSS hacks only work for one or the other. I’ve updated my test case to test these separately, and there are some interesting results.

The following hacks target IE8 but not IE9:

  • longhandproperty: \0value\0;
  • longhandproperty: \0value;

In practice, you might use these like so:

  • background-color: \0red\0;
@mathiasbynens
mathiasbynens / LICENSE.txt
Created June 11, 2011 08:56 — forked from 140bytes/LICENSE.txt
Quick and dirty way to check if a given string can be used as an unquoted attribute value in HTML. (50 bytes)
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathias Bynens <http://mathiasbynens.be/>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@mathiasbynens
mathiasbynens / fronteers11-belgians.js
Created June 17, 2011 16:47
Belgian #fronteers11 attendees
// Run this in your console on http://fronteers.nl/
// @fronteers Can haz JSON-P, pretty please?
jQuery.get('/congres/2011/attendees.json', function(data) {
var belgians = data.fronteers2011.andAllTheirOtherData.filter(function(attendee) {
return attendee.country == 'BE';
}).map(function(attendee) {
return attendee.name + (attendee.twitter ? ' (@' + attendee.twitter + ')' : '');
}),
title = belgians.length + ' Belgian attendees:';
@mathiasbynens
mathiasbynens / jsconsole.user.js
Created June 24, 2011 13:51
User script to enable the large side-by-side view on jsconsole.com.
// ==UserScript==
// @name Enable the large side-by-side view on jsconsole.com. This is only useful until https://github.com/remy/jsconsole/issues/22 is fixed.
// @author Mathias Bynens <http://mathiasbynens.be/>
// @match http://jsconsole.com/*
// ==/UserScript==
document.body.className = 'large';
@mathiasbynens
mathiasbynens / lolwat.js
Created August 18, 2011 10:48
Fun with v8’s Number#toString bug
var number = 0,
increment = 0.00000000000001, // smallest value that makes a difference
result,
matches,
match;
for (; number < 100; number += increment) {
result = number.toString(33);
matches = result.match(/[a-z]+/g) || [];
match = matches.indexOf('wtf');
@mathiasbynens
mathiasbynens / jsfiddle-defaults.user.js
Created September 8, 2011 12:25
Userscript that enables sensible defaults for jsFiddle.
// ==UserScript==
// @name Sensible defaults for jsFiddle.
// @author Mathias Bynens <http://mathiasbynens.be/>
// @link http://mths.be/bde
// @match http://jsfiddle.net/*
// ==/UserScript==
// Ignore existing fiddles
if (window.location.pathname == '/') {

Cards Against Humanity

Below are the white and black card sets published by Cards Against Humanity. Take them and come back with a bot. You have 48 hours, starting from an arbitrary time that I forget.

Black cards with 2 blanks are pick 2. Black cards with 3 blanks are pick 3, draw 2.

The rules are on the official web site.

These cards are taken from this PDF.

@mathiasbynens
mathiasbynens / jsonp.php
Last active June 25, 2016 02:03
Basic JSON/JSON-P service in PHP
<?php
// Prevent content sniffing attacks such as http://mths.be/bst.
header('X-Content-Type-Options: nosniff');
// Note: The user-provided callback name must be filtered to prevent attack
// vectors. This script simply removes any symbols other than `[a-zA-Z0-9$_]`
// from the input. Sadly, this blocks the use of some valid JavaScript
// identifiers, and also accepts a few invalid ones. See
// http://mathiasbynens.be/notes/javascript-identifiers for details.
@mathiasbynens
mathiasbynens / url-code-points.js
Last active October 27, 2016 14:46
Let’s create a JavaScript-compatible regular expression that matches any URL code point, as per the URL Standard.
// “The URL code points are ASCII alphanumeric, "!", "$", "&", "'", "(", ")",
// "*", "+", ",", "-", ".", "/", ":", ";", "=", "?", "@", "_", "~", and code
// points in the ranges U+00A0 to U+D7FF, U+E000 to U+FDCF, U+FDF0 to U+FFEF,
// U+10000 to U+1FFFD, U+20000 to U+2FFFD, U+30000 to U+3FFFD, U+40000 to
// U+4FFFD, U+50000 to U+5FFFD, U+60000 to U+6FFFD, U+70000 to U+7FFFD, U+80000
// to U+8FFFD, U+90000 to U+9FFFD, U+A0000 to U+AFFFD, U+B0000 to U+BFFFD,
// U+C0000 to U+CFFFD, U+D0000 to U+DFFFD, U+E1000 to U+EFFFD, U+F0000 to
// U+FFFFD, U+100000 to U+10FFFD.”
// — http://url.spec.whatwg.org/#url-code-points
/*
* See http://mathiasbynens.be/notes/async-analytics-snippet#comment-14
*/
<script>
var f = Function(),
clicky = { log: f, goal: f },
clicky_site_id = XXXXXX;
(function(d, t) {
var c = d.createElement(t),