Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias Bynens mathiasbynens

View GitHub Profile
View toggleAttr() jQuery plugin
/*!
* toggleAttr() jQuery plugin
* @link http://github.com/mathiasbynens/toggleAttr-jQuery-Plugin
* @description Used to toggle selected="selected", disabled="disabled", checked="checked" etc…
* @author Mathias Bynens <http://mathiasbynens.be/>
*/
jQuery.fn.toggleAttr = function(attr) {
return this.each(function() {
var $this = $(this);
$this.attr(attr) ? $this.removeAttr(attr) : $this.attr(attr, attr);
@mathiasbynens
mathiasbynens / .gitignore
Last active Mar 11, 2020
Unicode version diff for ECMAScript
View .gitignore
node_modules
package-lock.json
@mathiasbynens
mathiasbynens / hide-jimmy-wales.user.js
Created Nov 21, 2011
Userscript that hides Jimmy Wales on Wikipedia
View hide-jimmy-wales.user.js
// ==UserScript==
// @name Hide Jimmy Wales.
// @match http://*.wikipedia.org/*
// ==/UserScript==
(function() {
var banner = document.getElementById('siteNotice');
banner && banner.style.display = 'none';
}());
@mathiasbynens
mathiasbynens / README.md
Created Apr 22, 2011
Improved swipe gestures plugin for jQuery
View README.md

Improved swipe gestures plugin for jQuery

What was changed (compared to the original v0.1.2):

  • Don’t modify the default settings internally.
  • Merge the options recursively (deep copy) so that the custom threshold values actually get used.
  • Allow overriding the options globally through $.fn.swipe.options.
  • Use namespaced jQuery events (using the swipe namespace) instead of DOM2 addEventListener to prevent errors in old IEs.
  • Simplified and optimized code.
  • Changed swipeLeft and swipeRight functions to be called within the context of the bound element. Thanks, @kswedberg!
@mathiasbynens
mathiasbynens / jquery.fluid-youtube-videos-original.js
Created Jun 8, 2011
Fluid width YouTube videos of different aspect ratios, by Chris Coyier
View jquery.fluid-youtube-videos-original.js
// Original code from http://css-tricks.com/examples/FluidWidthYouTube/iframe.php
$(function() {
// find all videos
var allVideos = $("iframe[src^='http://www.youtube.com']"),
// The thing that is fluid width
body = $("body"),
View output.txt
http://AI./
└ IP: 209.59.119.34
http://ARAB./
└ IP: 127.0.53.53
http://BH./
└ IP: 10.10.10.10
http://CM./
└ IP: 195.24.205.60
http://DK./
└ IP: 193.163.102.58
@mathiasbynens
mathiasbynens / jquery.preload.js
Created Apr 22, 2010
JavaScript preload() function
View jquery.preload.js
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
View optimized-async-ga-snippet.html
<!-- See http://mathiasbynens.be/notes/async-analytics-snippet -->
<!-- Gisted for P. Ireland -->
<script>var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'))</script>
@mathiasbynens
mathiasbynens / bf.js
Created Jul 17, 2015
How many hex-formatted Unicode code points can be mistaken for a number in scientific notation? Which ones are those? https://twitter.com/tabatkins/status/621440178087960576
View bf.js
'use strict';
const pad = function(string) {
const totalCharacters = 4;
return string.length < totalCharacters ?
(Array(totalCharacters + 1).join('0') + string).slice(-totalCharacters) :
string;
}
const UNICODE_MIN = 0x0;
@mathiasbynens
mathiasbynens / opera-15-regressions.md
Last active Aug 4, 2018
List of things that broke with the Opera 15 release due to the switch to Blink/Chromium (Web features, not UI-specific stuff)