Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Clean Code | 31 comments | Create New Account
Click here to return to the 'Clean Code' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Clean Code
Authored by: petey on Feb 07, '02 04:42:24AM
Inspired by Porkchop, I decided to see how clean I could get the code. (Annoyingly, the site strips out multiple spaces, so you'll have to add them back to the 3rd paragraph get the formatting lined up again.)
set num to 10 set r to return do shell script "ls -l /var/vm/" set swp to ((number of paragraphs of result) - 1) do shell script "vm_stat" set vSS to result do shell script "ps auxmww" set appSS to paragraphs 2 through (num + 1) of result as list set d to r & "Swapfiles: " & swp & r set d to d & "Pageouts: " & vParse(vSS, 11) & r & r & r set d to d & "Free: " & vParse(vSS, 2) & r & r & r repeat with c in appSS set d to d & appParse(c) & r end repeat display dialog d & r on vParse(x, xn) set v to word -1 of (paragraph xn of x) set v to (v - (v mod 256)) / 256 as integer if v > 0 then set v to v & " MB" return v end vParse on appParse(x) set m to word 6 of x set m to (m - (m mod 1024)) / 1024 as integer if 10 > m then set m to " " & " " & m set AppleScript's text item delimiters to {"/"} set n to text item -1 of x set AppleScript's text item delimiters to {""} set o to offset of " -psn" in n if (o > 0) then set n to (text items 1 through (o - 1)) of n as string if n = "TruBlueEnvironment " then set n to "Classic" return m & " MB " & " " & n end appParse

[ Reply to This | # ]