truncate Rails development/test logs
truncate ~/www/*/log/*.log
Even easier, ask cron to do it for me every night:
4 22 * * * * truncate -s 0k ~/www/*/log/*.log
11397 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
truncate ~/www/*/log/*.log
4 22 * * * * truncate -s 0k ~/www/*/log/*.log
def truncate_words(text, length = 30, end_string = ' …') words = text.split() words[0..(length-1)].join(' ') + (words.length > length ? end_string : '') end
<?php function trunc($phrase, $max_words) { $phrase_array = explode(' ',$phrase); if(count($phrase_array) > $max_words && $max_words > 0) $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'...' return $phrase; } ?>