This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Load a script asynchronously | |
* @param {string} src - url to the script you're trying to load | |
* @returns {Promise} | |
*/ | |
function loadScript(src) { | |
return new Promise(function (resolve, reject) { | |
const script = document.createElement('script'); | |
let ready = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="POST" | |
action="https://form.io" | |
enctype="multipart/form-data" | |
onsubmit="return trackSubmit()"> | |
</form> | |
<script> | |
function trackSubmit() { | |
ga('send', 'event', 'webform', document.title, 'SUBMIT button clicked'); | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sets z-indices of reference's children in reverse order | |
* @param {Node} $slider | |
*/ | |
function setZIndices($slider) { | |
const slideCount = $slider.children().length; | |
$slider.children().css('zIndex', function(i){ | |
return slideCount - i; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var xhrObj = new XMLHttpRequest(); | |
xhrObj.open('GET', "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore.js", false); | |
xhrObj.send(''); | |
var script = document.createElement('script'); | |
script.type = "text/javascript"; | |
script.text = xhrObj.responseText; | |
document.head.appendChild(script); | |
</script> | |
<!-- Trying it out --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function header_is_set($header_name) { | |
if (!function_exists('getallheaders')) { | |
$headers = []; | |
foreach ($_SERVER as $name => $value) { | |
if (substr($name, 0, 5) == 'HTTP_') { | |
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function Parse ($url) { | |
$fileContents= file_get_contents($url); | |
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); | |
$fileContents = trim(str_replace('"', "'", $fileContents)); | |
$simpleXml = simplexml_load_string($fileContents); | |
$json = json_encode($simpleXml); | |
return $json; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
#target { | |
background: cadetblue; | |
height: 20vh; |