Skip to content

Instantly share code, notes, and snippets.

@timhettler
timhettler / top-words.js
Created March 29, 2012 20:20
Take a String and return the top N words found within the String, by frequency
(function top(string, num) {
var words = string.toLowerCase().split(/[\s,.]+/),
count = {},
topWords = [];
for(var i=0; i<words.length;i++){
(count[words[i]] !== undefined) ? count[words[i]]++ : count[words[i]] = 1;
}
var list = Object.keys(count).sort(function(a, b){return count[a]-count[b];}).reverse();
@timhettler
timhettler / reveal.js
Created March 12, 2012 16:24
Animating an element from a fixed height to "auto" height using jQuery
var $selector = $('div');
$selector.data('oHeight',$selector.height()).css('height','auto').data('nHeight',$selector.height()).height($selector.data('oHeight')).animate({height: $selector.data('nHeight')},400);