Skip to content

Instantly share code, notes, and snippets.

@yoavweiss
yoavweiss / gist:3609089
Created September 3, 2012 12:43
post-onload async script loader
(function(s){var a=addEventListener,d=document;if(a){a("load",function(){setTimeout(function(){d.body.appendChild(d.createElement('script')).src=s})})}})("a.js")
@yoavweiss
yoavweiss / preload_feature_detection.js
Last active July 24, 2020 19:31
Preload feature detection
var DOMTokenListSupports = function(tokenList, token) {
if (!tokenList || !tokenList.supports) {
return;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
@yoavweiss
yoavweiss / domtokenlist_feature_detection.js
Last active January 10, 2020 17:36
DOMTokenList supports() example
var DOMTokenListSupports = function(tokenList, token) {
if (!tokenList || !tokenList.supports) {
return;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
@yoavweiss
yoavweiss / Remap_esc_key.sh
Created October 7, 2018 20:14
Remap § to Esc and Esc to F24
#!/bin/bash
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000029}, {"HIDKeyboardModifierMappingSrc":0x700000029,"HIDKeyboardModifierMappingDst":0x700000073}]}'
@yoavweiss
yoavweiss / gist:5793495
Created June 16, 2013 21:28
Responsive Web sites from @rwd's twitter stream
http://responsivedesignworkflow.com/
https://www.rijksmuseum.nl/en/explore-the-collection/subjects/owls
http://www.julianabicycles.com/
http://metaframe.elliance.com/
http://purecss.io/
http://hellogeri.com/
http://2012.dconstruct.org/
http://www.moneydesktop.com/
http://thepaintdrop.com/
http://www.npr.org/blogs/thisisnpr/2013/05/08/180363048/see-a-new-npr-homepage-on-your-smartphone
@yoavweiss
yoavweiss / Sites using picturefill
Created May 12, 2013 20:27
Sites using picturefill to implement art-direction
alistapart.com
animoto.com
behance.net
cato.org
ceskatelevize.cz
creativemarket.com
dribbble.com
evernote.com
extra.cz
flavorwire.com
@yoavweiss
yoavweiss / multiple_forms.html
Created March 19, 2013 17:31
An HTML page with multiple forms
<html>
<body>
<form method="post" action="basket_backend">
Where do I send this to? <input type="text">
<input type="submit" value="You will SUBMIT!!!">
</form>
<form method="post" action="product_backend">
Shoe
<input type="button" value="+">
<span class="quantity">1</span>
<picture>
<source srcset="http://placehold.it/300.png">
<img src="http://placehold.it/100.png" id=bla>
</picture>
<script>
(function() {
var img = document.getElementById("bla");
img.parentNode.removeChild(img);
})();
</script>
@yoavweiss
yoavweiss / gist:2b6a5fdb991be72a1f79
Created December 3, 2015 17:12
DOMTokenList feature detection
var tokenListSupports = function(tokenList, token) {
if (!tokenList || !tokenList.supports) {
return false;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
@yoavweiss
yoavweiss / GeckoNetworkManager.java
Created December 4, 2012 16:56
Firefox on Android BW detection
static private final double kDefaultBandwidth = -1.0;
static private final boolean kDefaultCanBeMetered = false;
static private final double kMaxBandwidth = 20.0;
static private final double kNetworkSpeedEthernet = 20.0; // 20 Mb/s
static private final double kNetworkSpeedWifi = 20.0; // 20 Mb/s
static private final double kNetworkSpeedWiMax = 40.0; // 40 Mb/s
static private final double kNetworkSpeed_2_G = 15.0 / 1024.0; // 15 kb/s
static private final double kNetworkSpeed_2_5_G = 60.0 / 1024.0; // 60 kb/s