Skip to content

Instantly share code, notes, and snippets.

Kyle Pflug kypflug

Block or report user

Report or block kypflug

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kypflug
kypflug / Example-detection.js
Last active Aug 29, 2015
Example of feature detection for responsive images
View Example-detection.js
(function (window) {
document.addEventListener("DOMContentLoaded", function (e) {
var supports = {
srcset: false,
currentSrc: false,
sizes: false,
picture: false
};
View gist:83f14171abf29e1fb7a8
var toggleGainState = function(elementId, elementClass, outputElement){
var ele = document.getElementById(elementId);
return function(){
if (outputElement.gain.value === 0) {
outputElement.gain.value = 1;
ele.classList.remove(elementClass);
} else {
outputElement.gain.value = 0;
ele.classList.add(elementClass);
}
@kypflug
kypflug / Complex default parameter scope case Chakra handles properly
Last active Aug 29, 2015
Complex default parameter scope case Chakra handles properly
View Complex default parameter scope case Chakra handles properly
function fn() { return "outside" }
function outer(a = fn()) {
function fn() { return "inside" };
return fn();
}
outer(); // "outside"
@kypflug
kypflug / Complex default parameter scope that Chakra doesn’t yet handle
Last active Aug 29, 2015
Complex default parameter scope that Chakra doesn’t yet handle
View Complex default parameter scope that Chakra doesn’t yet handle
let x = "outside";
function outer(a = () => eval("x")) {
let x = "inside";
return a();
}
outer(); // "inside", should be "outside"
@kypflug
kypflug / functionsquare
Created May 6, 2015
function square in an asm.js module
View functionsquare
function PhysicsEngine(global, foreign, heap) {
"use asm";
// Function Declaration
function square(x) {
x = +x;
return +(x*x);
}
}
View XPath example with IE-specific code.js
// code for IE
if (window.ActiveXObject || xhttp.responseType == "msxml-document") {
xml.setProperty("SelectionLanguage", "XPath");
nodes = xml.selectNodes(path);
for (i = 0; i < nodes.length; i++) {
document.write(nodes[i].childNodes[0].nodeValue);
document.write("<br>");
}
}
@kypflug
kypflug / css touch-action property
Created Feb 23, 2015
CSS touch-action property from Pointer Events
View css touch-action property
.disable300msDelay {
touch-action: manipulation;
}
@kypflug
kypflug / media queries
Created Feb 5, 2015
Media Queries Level 4 Demo
View media queries
<!DOCTYPE html>
<html lang="en">
<head>
<title>Media Queries Level 4 Demo</title>
<style>
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
@kypflug
kypflug / Windows 10 Phone UA String
Last active Aug 29, 2015
Windows 10 Technical Preview for phones UA String
View Windows 10 Phone UA String
Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Mobile Safari/537.36 Edge/12.0
@kypflug
kypflug / adaptive video element
Created Jan 29, 2015
Adaptive Video Element
View adaptive video element
<video id="video" controls width=640 height=360 src="myvideo.m3u8"></video>
You can’t perform that action at this time.