Skip to content

Instantly share code, notes, and snippets.

@brandonaaskov
brandonaaskov / jQuery Change Event: Proper Binding
Created January 11, 2012 21:34
jQuery's change() event doesn't work as expected with input text fields. This, however, does work.
/*
For some reason, the change() event only fires when the input field loses focus.
Binding to other options ('change keypress paste focus textInput input') will
fire the event several times, which is bad. The below code works even when
content is pasted into the text field, and only fires once as expected.
*/
$('#search-form .term').bind('input', function(){
console.log('this actually works');
});
@malihu
malihu / tabs.js
Created October 1, 2012 14:49
Fully commented code for the tabs.js script
(function($){
$.fn.Tabs=function(speed){ /* tabs transition speed parameter */
return this.each(function(){
/* define/cache variables */
var tabs=$(this),
tabsLabels=tabs.children("ul"),
tabLabel=tabsLabels.find("a"),
tabsContent=tabs.children("div"),
tabLink,
tabsLoader=tabsContent.children(".ajax-loader"); /* define ajax loader element */
@Darep
Darep / .htaccess
Last active April 23, 2024 07:16
PHP CSS&JS auto-versioning function.
# CSS/JS auto-versioning
RewriteEngine On
RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]
@jakefentress
jakefentress / svg-fallback.html
Created February 20, 2014 17:04
Inline SVG Fallbacks - especially for problems with IE9
<!--[if gt IE 9]><!-->
<img src="img/wordmark.svg" onerror="this.src=img/wordmark.png;this.onerror=null;">
<!--<![endif]--><!--[if lte IE 9]>
<img src="img/wordmark.png">
<![endif]-->
@richjenks
richjenks / redirect-to-canonical.js
Created January 21, 2015 10:25
Redirect to canonical
if (document.querySelector("link[rel='canonical']")) {
// Get current URL
var url = document.URL;
// If query string, get it and append to current URL
if (location.search) {
var query = location.search;
} else {
var query = '';
@gecon
gecon / improved_greek_uppercase.php
Last active November 15, 2022 13:08
uppercase greek without accents (php solution)
<?php
/***********************************************************************
A simple PHP function that will correctly uppercase Greek language
with proper spelling rules (removing accents in uppercased letters).
This is a server-side alternative to CSS uppercase() for Greek.
Greek CSS uppercase() is not working right on some browsers.
You can fix this by using javascript (increases browser load time) or
in server side by using this function here.
@amboutwe
amboutwe / yoast_seo_prev_next_change.php
Last active July 7, 2023 19:54
Remove or modify the Yoast SEO prev or next URLs. Only copy the section of code you need.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change Yoast SEO Prev/Next URL on some pages
* Credit: Yoast Team
* Last Tested: Jun 10 2017 using Yoast SEO 4.9 on WordPress 4.8
*/
add_filter( 'wpseo_next_rel_link', 'custom_change_wpseo_next' );