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
let dim = [...svg.children].filter(el => el.getBBox).reduce((acc, el) => { | |
let { x, y, width, height } = el.getBBox(); | |
if (!acc.min.x || x < acc.min.x) acc.min.x = x; | |
if (!acc.max.x || x + width > acc.max.x) acc.max.x = x + width; | |
if (!acc.min.y || y < acc.min.y) acc.min.y = y; | |
if (!acc.max.y || y + height > acc.max.y) acc.max.y = y + height; | |
return acc; | |
}, { min: {}, max: {} }), | |
viewBox = `${dim.min.x} ${dim.min.y} ${dim.max.x - dim.min.x} ${dim.max.y - dim.min.y}`; | |
svg.setAttribute("viewBox", viewBox); |
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
Qure | |
.wait(1000) | |
.then(function() { | |
// executed after 1 second | |
console.log(1); | |
}) | |
.wait(1000) | |
.then(function() { | |
// executed after 1 second after previous log |
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
<html> | |
<head> | |
<title>3rd party script executed in sandbox mode</title> | |
<script type="text/javascript"> | |
var code = 'console.log(this);'+ | |
'console.log(window);'+ | |
'console.log(document);'+ | |
'console.log(console);'+ | |
'setTimeout(function() {console.log(1);}, 10);'+ |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<rule name="WordPress Rule 1 Identical" stopProcessing="true"> | |
<match url="^index\.php$" ignoreCase="false" /> | |
<action type="None" /> | |
</rule> |
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
// start the timer | |
var start = Date.now(); | |
// get the snapshot with a callback function | |
Defiant.getSnapshot(data, function(snapshot) { | |
console.log('Created snapshot in '+ (Date.now() - start) +' ms'); | |
// searching on snapshot created with web worker | |
var found = JSON.search(snapshot, '//item'); | |
console.log(found); |
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
<!-- Defiant template --> | |
<script type="defiant/xsl-template"> | |
<xsl:template name="tree"> | |
<h1>Tree</h1> | |
<xsl:call-template name="tree-walker"/> | |
</xsl:template> | |
<xsl:template name="tree-walker"> |
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
<!-- Defiant template --> | |
<script type="defiant/xsl-template"> | |
<xsl:template name="books_template"> | |
<h1>Books</h1> | |
<xsl:for-each select="//book"> | |
<xsl:sort order="ascending" data-type="number" select="price"/> | |
<h2><xsl:value-of select="title"/></h2> | |
Author: <strong><xsl:value-of select="author"/></strong><br/> | |
Price: <xsl:value-of select="price"/> |
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
<!-- Defiant template --> | |
<script type="defiant/xsl-template"> | |
<xsl:template name="books_template"> | |
<xsl:for-each select="//movie"> | |
<xsl:value-of select="title"/><br/> | |
</xsl:for-each> | |
</xsl:template> | |
</script> |
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
var obj = { | |
"car": [ | |
{"id": 10, "color": "silver", "name": "Volvo"}, | |
{"id": 11, "color": "red", "name": "Saab"}, | |
{"id": 12, "color": "red", "name": "Peugeot"}, | |
{"id": 13, "color": "yellow", "name": "Porsche"} | |
], | |
"bike": [ | |
{"id": 20, "color": "black", "name": "Cannondale"}, |
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
var data { | |
// ...large JSON structure... | |
}; | |
// Regular search | |
found = JSON.search(data, '//item'); | |
var snapshot = Defiant.getSnapshot(data); | |
// Snapshot search - this is more than 100 times faster than 'regular search' |
NewerOlder