Skip to content

Instantly share code, notes, and snippets.

@davegaeddert
davegaeddert / style.less
Last active Aug 29, 2015
Bootstrap variables-custom.less example
View style.less
// (reference) is important, read more on that here: http://lesscss.org/features/#import-options-reference
@import (reference) "../bootstrap/less/variables.less";
@import (reference) "../bootstrap-custom/less/variables-custom.less";
@import (reference) "../bootstrap/less/mixins.less";
// now your styles...
.specific-class {
color: @brand-primary;
.transition(color .25s linear);
View generate-thumbnails.php
<?php /*
**************************************************************************
Plugin Name: Generate Sized Thumbnails On The Fly
Description: When a thumbnail image is requested of a specific width/height (rather than by name), generate it if it doesn't exist.
Version: 2.0.0
Author: Dave Gaeddert (davegaeddert), forked from Alex Mills (Viper007Bond) - https://gist.github.com/Viper007Bond/2785428
**************************************************************************/
@davegaeddert
davegaeddert / jquery.select-text.js
Created Sep 4, 2013
jQuery select / highlight text.
View jquery.select-text.js
jQuery.fn.selectText = function(){
var doc = document
, element = this[0]
, range, selection
;
if (doc.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
} else if (window.getSelection) {
View jquery.django-csrf.js
jQuery(function($) {
// https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
@davegaeddert
davegaeddert / rename-extensions.sh
Last active Dec 20, 2015
Batch rename extensions from the command line.
View rename-extensions.sh
find site -depth -name "*.asp.html" -exec sh -c 'mv "$1" "${1%.asp.html}.php"' _ {} \;
@davegaeddert
davegaeddert / fresh-image.js
Last active Dec 14, 2015
jQuery (or anything) force browser to refresh an image even though it has the same url.http://stackoverflow.com/questions/2104949/how-to-reload-refresh-an-elementimage-in-jquery
View fresh-image.js
d = new Date();
$("#myimg").attr("src", "/myimg.jpg?"+d.getTime());
View jquery.regex.js
jQuery.expr[':'].regex = function(elem, index, match) {
var matchParams = match[3].split(','),
validLabels = /^(data|css):/,
attr = {
method: matchParams[0].match(validLabels) ?
matchParams[0].split(':')[0] : 'attr',
property: matchParams.shift().replace(validLabels,'')
},
regexFlags = 'ig',
regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
@davegaeddert
davegaeddert / jquery.smartresize.js
Created Jan 27, 2013
jQuery Smartresize - attempt to wait until resize is done as opposed to continuously firing
View jquery.smartresize.js
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
View array.remove.js
// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
You can’t perform that action at this time.