

Bookmarklet for word counts on your YC application - kaistinchcombe

javascript: (function() { var wordCount = function() { if (!window.jQuery) { return setTimeout(wordCount, 100); } var $ = jQuery; $('.wc').remove(); $('textarea').each(function(idx,elem) { var wc = $(elem).text().split(/[ \n]+/).length; $(elem).after('&#60;div class="wc"'+( (wc&#62;120) ? ' style="color: red"':'')+'&#62;'+wc+'&#60;/div&#62;'); }); }; if (!window.jQuery) { var c=document.createElement("script"); c.type="text/javascript"; c.src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"; document.documentElement.childNodes[0].appendChild(c); } wordCount(); })();<p>https://gist.github.com/kstinchcombe/5087397/raw/6c6d6d852970a5b629a83f9ac6d55d701e0a3926/gistfile1.js<p>doesn't update live, that would be super annoying. click again to update.
======
keiferski
I'm not a programmer by any means, but I did write this little word-counter
while going through a Ruby book. You might find it useful...?

\----

lines = File.readlines("text.txt") line_count = lines.size text = lines.join
total_characters = text.length total_characters_nospaces = text.gsub(/\s+/,
'').length word_count = text.split.length sentence_count =
text.split(/\\.|\?|!/).length paragraph_count = text.split(/\n\n/).length

puts "This document contains:" puts "#{line_count} lines" puts
"#{total_characters} characters" puts "#{total_characters_nospaces} characters
excluding spaces" puts "#{word_count} words" puts "#{sentence_count}
sentences." puts "#{paragraph_count} paragraphs." puts "#{sentence_count /
paragraph_count} sentences per paragraph (average)" puts "#{word_count /
sentence_count} words per sentence (average)"

------
kaistinchcombe
update should have used val() rather than text().
<https://gist.github.com/kstinchcombe/5087397/>

javascript: (function() { var wordCount = function() { if (!window.jQuery) {
return setTimeout(wordCount, 100); } var $ = jQuery; $('.wc').remove();
$('textarea').each(function(idx,elem) { var wc = $(elem).val().split(/[
\n]+/).length; $(elem).after('<div class="wc"'+( (wc>120) ? ' style="color:
red"':'')+'>'+wc+'</div>'); }); }; if (!window.jQuery) { var
c=document.createElement("script"); c.type="text/javascript";
c.src="[http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min...](http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js);
document.documentElement.childNodes[0].appendChild(c); } wordCount(); })();

