Skip to content

Instantly share code, notes, and snippets.

@luchaninov
luchaninov / fixNoindex.php
Last active June 28, 2018 16:00
Fix <noindex> for Google
<!-- BEGIN FIX -->
<?php if(strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot')!==false){if(!function_exists('fixNoindex')){
function fixNoindex($buffer){return preg_replace('#<noindex>(.*?)</noindex>#msi','<!-- $1 -->',$buffer);}}ob_start('fixNoindex');} ?>
<!-- END FIX -->
<!-- THIS IS EXAMPLE -->
<!-- DON'T COPY IT TO YOUR SITE -->
Indexable, visible.
<noindex>
Non-indexable, but still visible.
@luchaninov
luchaninov / levenshtein.js
Last active August 28, 2020 20:36
Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (i.e. insertions, deletions or substitutions) required to change one word into the other.
// from https://github.com/thinkphp/String.levenshtein/blob/master/Source/String.levenshtein.js but no depencencies
function levenshtein(str1, str2) {
var cost = new Array(),
n = str1.length,
m = str2.length,
i, j;
var minimum = function(a, b, c) {
var min = a;
if (b < min) {
@RubaXa
RubaXa / jquery.fn.find.js
Last active April 14, 2016 15:47
Fastest jQuery.fn.find
/**
* Fastest jQuery.fn.find
* @jsperf http://jsperf.com/jquery-find-vs-jquery-fastestfind
* @author RubaXa <ibnRubaXa@gmail.com>
* @license MIT
*/
/* global document, jQuery */
document.createElement('div').querySelectorAll && (function ($, originalFind){