Skip to content

Instantly share code, notes, and snippets.

View adamculpepper's full-sized avatar

Adam Culpepper adamculpepper

View GitHub Profile
var cache = {};
function checkCache(key){
if(cache[key]){
return cache[key];
} else {
// do some long/expensive action
// ex: calculation, ajax, etc...
cache[key] = Math.random();
return cache[key];
}
@rxaviers
rxaviers / gist:7360908
Last active May 7, 2024 09:02
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@sanand0
sanand0 / textarea-maxlength.js
Created September 7, 2010 07:17
Restricts number of characters to maxlength in textarea
// Textarea maxlength
// Ensures that textarea's maxlength is validated
//
// (c) S Anand, 2010, MIT License
// Credits: http://yelotofu.com/2009/12/jquery-textarea-max-length/
// Credits: http://stackoverflow.com/questions/43569/max-length-for-html-text-areas
(function() {
var ignore = [8,9,13,33,34,35,36,37,38,39,40,46];
function limit(event) {
@timsnadden
timsnadden / jquery.equalheights.js
Created August 6, 2010 01:42
jquery equal heights
$.fn.equalHeights = function() {
/* Create an array of element heights */
var heights = this.map(function() {
return $(this).height();
}).get();
/* Find the tallest */
var max = Math.max.apply(null, heights);
/* Set all elements to be equal height */
@patrys
patrys / jquery.placeholder.js
Created August 3, 2010 14:43
Fallback code for the HTML5 "placeholder" attribute
$(function() {
if (!('placeholder' in document.createElement('input'))) {
$('input[placeholder], textarea[placeholder]').each(function() {
var text = this.getAttribute('placeholder');
var fld = $(this);
function setPlaceholder() {
if (fld.val() == text || fld.val() == '') {
fld.addClass('jqPlaceholder');
fld.val(text);
$('li:last-child, th:last-child, td:last-child, tr:last-child').addClass('last-child');
$('li:first-child, th:first-child, td:first-child, tr:first-child').addClass('first-child');
$('input').addClass(function() { return $(this).attr('type'); });
$('input[readonly]').addClass('readonly');
$('th').addClass(function() { return $(this).attr('scope'); });
if($.browser.msie) {
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
// Before hiding all the inactive togglables, hard-code their height so
// the jQuery effect isn't choppy.
// See http://stackoverflow.com/questions/1092245/basic-jquery-slideup-and-slidedown-driving-me-mad
$(".togglable").each(function(){
$(this).css("height", $(this).height());
});
// Passive way of hiding stuff that should be hidden.
// This way it won't be for users with js disabled.
$(".inactive").hide();