Skip to content

Instantly share code, notes, and snippets.

View mathiasbynens's full-sized avatar

Mathias Bynens mathiasbynens

View GitHub Profile
if (!HTMLVideoElement.prototype.canPlayType) {
HTMLVideoElement.prototype.canPlayType = function(type) {
return [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
#!/usr/bin/python
'''
iSniff-1266.py
SSL man-in-the-middle tool / proof-of-concept exploit for CVE-2014-1266
ServerKeyExchange signature validation flaw patched in iOS 7.0.6 and Mac OS X 10.9.2
Successfully tested against iOS 7.0.4 devices

RegExp.escape(string)

Computes a new version of a String value in which certain characters have been escaped, so that the regular expression engine will interpret any metacharacters that it may contain as character literals.

When the escape function is called with one argument string, the following steps are taken:

  1. Let string be ToString(string).
  2. ReturnIfAbrupt(string).
  3. Let length be the number of characters in string.
  4. Let R be the empty string.
# While GNU coreutil's ls is generally more featureful (including colorization
# based on file extensions, SI size formats, ISO date and time formats,
# semantic version sort, etc.), OS X's fork of FreeBSD ls allows viewing HFS+
# extended attributes and access control lists through the -@ and -e flags,
# respectively.
#
# This script provides a shim to allow BSD ls to be invoked with GNU-style
# flags and .dircolor files, and a function that shadows ls, invoking coreutils
# ls by default but automatically switching to the shim when the -@ and/or -e
# flags are detected.
@rwaldron
rwaldron / exponentiation.md
Last active August 29, 2015 14:01
Exponentiation Operator: **

Exponentiation Operator

Performs exponential calculation on operands. Same algorithm as Math.pow(x, y)

  • Commonly used in albegra, geometry, physics and robotics.
  • Nice to have "inline" operator

Prior Art

  • Python
@annevk
annevk / gist:6bfa782752dde6acb379
Last active August 29, 2015 14:01
APIs that could move into ES

Not really in any particular order. Some are more logical than others.

  • TextDecoder / TextEncoder
  • URL
  • fetch() (unclear yet how we are going to namespace this, CORS behavior also does not make much sense outside browser context)
  • Worker / SharedWorker (and all the port business, structured cloning is on its way already; would require events to be ported too)
  • window.btoa() / window.atob()
  • window.setTimeout(), …
  • ImageBitmap
  • EventSource
@annevk
annevk / gist:3db3fbda2b95e5ae9427
Last active August 29, 2015 14:01
Platform requests to TC39
  • IO streams. (Domenic is leading an effort on GitHub. This is high priority, like promises was last year.)
  • Asynchronous iteration (event streams?). (Database cursor, going through a directory, going through entries in storage, scanning TV channels.)
  • A plan around distinct Error types and detection (e.g. for APIs that can fail in multiple ways where you might want to recover from certain class of errors; think network APIs, databases)
  • A better way to define ES APIs than WebIDL. (Part of the problem here is lack of maintenance. So maybe it's as "simple" as finding someone.)
@xem
xem / README.md
Last active August 29, 2015 14:01 — forked from 140bytes/LICENSE.txt
Mini string encoders for the Web

Mini string encoders/decoders for the Web

Here's a list of tiny functions whose goal is to convert any Unicode string in 28 different formats used on the Web, and do the reverse operation.

An online converter using those functions can be found here: http://xem.github.io/escape

Please contribute in the comments (or by pull request) if you have a feature idea or a code-golf improvement to make or a bug to solve.

NB: to be as short as possible, all those functions assume a valid input and convert all chars (including ASCII chars and non-ASCII chars that don't really need to be converted in some cases).

@mozfreddyb
mozfreddyb / make-ni-uri.py
Created September 29, 2014 09:22
Computes the sha256 digest of the given file names and prints them in a ni URL.
#!/usr/bin/env python
from sys import argv
import hashlib
from base64 import urlsafe_b64encode
from mimetypes import guess_type
from os.path import basename
def get_mimetype(filename):
mt = guess_type(filename)[0]
@tabatkins
tabatkins / gist:57d07e4b75a9fc66ee30
Last active August 29, 2015 14:07
List of Suggested Extensions to CSS

List of Suggested Extensions to CSS

This is a breakdown of "List of Suggested Extensions to CSS", produced by the CSSWG back in 1998. It goes through each feature and either lists where the feature has been defined in the intervening 16 years, or notes that it has yet to be addressed.

Out of the 67 suggested extensions, 30 have been added, 10 have been partially added or been added but with uncertain implementor interest, and 27 have not been added.

  1. Columns: http://dev.w3.org/csswg/css-multicol/
  2. Swash letters and other glyph substitutions: http://dev.w3.org/csswg/css-fonts/#font-rend-props
  3. ~ Running headers and footers: , but unproven so