Skip to content

Instantly share code, notes, and snippets.

View Perturbatio's full-sized avatar

Kris Kelly Perturbatio

View GitHub Profile
@Perturbatio
Perturbatio / unrequireElements.js
Created November 16, 2016 01:31
Unrequire elements bookmarklet
javascript:(function()%7Bvar%20selector%3D'input%2Ctextarea%2Cselect'%3B%5B%5D.slice.call(document.querySelectorAll(selector)).forEach(function(value%2C%20index%2C%20list)%7Bvalue.required%3D''%3B%7D)%7D)()
@Perturbatio
Perturbatio / test-str.php
Created September 9, 2016 21:58
Using byte based comparison for startsWith and endsWith since mb_str functions are slow and it doesn't matter what the encoding is in this instance. another performance hit is the current use of mb_strpos since the full length of the string will be checked, resulting in increasingly slow performance as the str length increases.
<?php
$testHaystack = trim(file_get_contents( 'data-large.txt' )); //~4.5MB of text
//$testHaystack = trim(file_get_contents( 'data-small.txt')); //~1KB of text
//$testHaystack = 'السلام علیکم ورحمة الله وبرکاتهöLorem ipsum dolor sit amet voluptatem?öالسلام علیکم ورحمة الله وبرکاته';//Short string test
$validMatch = "السلام علیکم ورحمة الله وبرکاتهöLorem";
$invalidMatch = "I'm not anywhere in there";
$numberOfIterations = 10000;
//------------------[ startsWith valid ]------------------//