Never been to TextSnippets before?

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 (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

Check DNS lookup in Tiger

lookupd -configuration

Look for the following in the output:
LookupOrder: Cache FF DNS NI DS
_config_name: Host Configuration


The FF (flat file) refers to your hosts file (/etc/hosts), and Tiger does check its contents before going to DNS and Netinfo. Just a little FYI for those who may not have realized that 10.4 fixed things.


Calculate the number of working days between two dates

Function
   # wdays is an array with the days of the week
   # to exclude days (eg: wdays = [0,6] for sunday and saturday )

   def calculate_working_days(d1,d2,wdays)
        diff = d2 - d1
        holidays = 0
        ret = (d2-d1).divmod(7)
        holidays =  ret[0].truncate * wdays.length
        d1 = d2 - ret[1]
        while(d1 <= d2)
                if wdays.include?(d1.wday)
                        holidays += 1
                end
                d1 += 1
        end
        diff - holidays
   end


Iterates over date range.
d1 = Date.new( 2006, 12, 1 ) 

d2 = Date.new( 2007, 1, 15 )

weekdays = (d1..d2).reject { |d| [0,6].include? d.wday } 

weekdays.length

concatenate files

The correct syntax for the cat command is:

cat file1 file2 ... [fileN] > file

where file1, file2, fileN are the download images and "file" is the .iso file you are creating.
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed