[bglug] Il calendario del LUG!

k|b|s bglug@lists.linux.it
Fri, 27 Dec 2002 18:15:47 +0100


--TB36FDmn/VVEgNH/
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline

Visto che tutti ormai fanno i calendari, dai calciatori alle veline,
ecco che anche il lug ha provveduto a colmare questa lacuna. Chi avremo
come miss gennaio? Lo Zio Mc? E a settembre? Al? Niente di tutto questo;
solamente un file postscript da inviare direttamente alla stampante :)
Hint: vale anche per il prossimo anno (e i seguenti), basta editare la
riga 11 e modificare la data.
Per vederlo prima di stamparlo usate gs.
Have fun :)

P.S. Ne voglio vedere uno appeso al lug. Ciao.
-- 
0000000: 2a20 6b7c 627c 7320 2a20 6d61 696c 746f  * k|b|s * mailto
0000010: 2060 6563 686f 2074 692e 6775 6c67 6240   `echo ti.gulgb@
0000020: 7362 6b7c 2772 6576 2760 0a0a            sbk|'rev'`..

--TB36FDmn/VVEgNH/
Content-Type: application/postscript
Content-Disposition: attachment; filename="bglugcal-1.1.ps"
Content-Transfer-Encoding: quoted-printable

%!PS-Adobe-1.0=0A%%Title: calyear-1.1.ps=0A%%Modified by: k|b|s (`echo ti.g=
ulgb@sbk|'rev'`)=0A%%CreationDate: December 27, 2002=0A%%License: Public Do=
main=0A%%EndComments=0A=0A% User definable stuff=0A=0A% Modify this variabl=
e to reflect the year you want to print=0A/year 2003 def=0A=0A% The followi=
ng are font related and language related.=0A/day_names [ (Do) (Lu) (Ma) (Me=
) (Gi) (Ve) (Sa) ]  def=0A=0A/month_names [ (Gennaio) (Febbraio) (Marzo) (A=
prile) (Maggio) (Giugno) (Luglio) =0A               (Agosto) (Settembre) (O=
ttobre) (Novembre) (Dicembre) ]  def=0A=0A/year_font /Times-Bold findfont d=
ef=0A/year_font.scale 48 def=0A/year_spacing 36 def=0A/month_font /Helvetic=
a findfont def=0A/month_font.scale 14 def=0A%/day_font /Times findfont def=
=0A%/day_font.scale 14 def=0A/day_font /Hevetica findfont def=0A/day_font.s=
cale 14 def=0A/footer_font /Hevetica findfont def=0A/footer_font.scale 10 d=
ef=0A/footer_spacing 18 def=0A=0A% end of user definable stuff =0A=0A% Marg=
ins for 8.5X11 page=0A/left_margin 72 def  % 1 inch=0A/right_margin 540 def=
 % 1 inch=0A/top_margin 756 def % 0.5 inch=0A/bottom_margin 72 def % 1 inch=
=0A=0A% Center justified text=0A/centered_text { % x1 y x2 str =3D> -=0A   =
 dup stringwidth pop 2 div  % Get string width and store just strlen/2=0A  =
  5 2 roll                   % Move string towards bottom of stack=0A    2 =
index sub                % Use copy of x1 to find width of line=0A    2 div=
                      % Find center of two margins=0A    4 -1 roll sub     =
         % Subtract half strlen to find start location=0A    3 -1 roll add =
             % Add offset to start location=0A    exch moveto              =
  % Move to this location=0A    show                       % Show string=0A=
} def=0A=0A% Right justified text=0A/right_text { % x y str =3D> -=0A    du=
p stringwidth pop % Get string width=0A    4 -1 roll exch sub  % Backtrack =
from right x location=0A    3 -1 roll moveto show % Move to this location a=
nd show string=0A} def=0A=0A/year_string year 4 string cvs def=0A=0Ayear_fo=
nt year_font.scale scalefont setfont=0A=0A/bottom_header { =0A             =
    756 year_font.scale sub =0A		 year_spacing sub % make bottom half an in=
ch down=0A	       } def=0A/top_footer 72 def=0A=0Aleft_margin bottom_header=
 year_spacing add right_margin year_string centered_text=0A=0Afooter_font f=
ooter_font.scale scalefont setfont=0A=0Aright_margin top_footer footer_spac=
ing sub (Bergamo Linux User Group) right_text=0A=0A/page_width right_margin=
 left_margin sub def=0A/page_length bottom_header top_footer sub def=0A=0A/=
months_per_line 3 def=0A/rows_per_page 12 months_per_line idiv def=0A=0A/mo=
nth_width page_width months_per_line div def=0A/month_length page_length ro=
ws_per_page div def=0A=0A/black	{0 0 0 setrgbcolor} def=0A=0A/dow_string { =
% dow_num -> dow_string=0A  % Number passed in needs to be 0-6 based.=0A  1=
 sub % Make 0-6 based=0A  day_names exch get % Swap array and dow num and g=
et string=0A} def=0A=0A/month_string { % month_num -> month_string=0A  1 su=
b % Convert to 0-11=0A  month_names exch get % Swap array and month num and=
 get string=0A} def=0A=0A/leap_year { % year -> true/false=0A  dup 1752 le=
=0A  {=0A    4 mod 0 eq=0A  }=0A  {=0A    dup 4 mod 0 eq=0A    1 index 100 =
mod 0 ne and=0A    1 index 400 mod 0 eq or=0A  } ifelse=0A  exch pop % Retu=
rn boolean value=0A} def=0A=0A/days_in_month { % month year -> daysinmonth=
=0A  1 index 2 eq % See if we are testing febuary=0A  { =0A    2 -1 roll po=
p % Don't need month any more=0A    leap_year {29} {28} ifelse=0A  } =0A  {=
 =0A    pop % Don't need year any more=0A    dup 4 eq % Compare month numbe=
r with 4=0A    1 index 6 eq or % Compare month number with 6 and OR previou=
s test=0A    1 index 9 eq or % Compare month number with 9 and OR previous =
test=0A    exch 11 eq or % Consume month number and compare with 11=0A    {=
30} {31} ifelse % Tested months have 30 days, else 31=0A  } ifelse =0A} def=
=0A=0A/days_in_year { % day, month, year -> julian-style day=0A    0 % This=
 will be julian-style day that is returned=0A    =0A    1 1 4 index 1 sub %=
 Set up loop for each month before this month=0A    {=0A       2 index days=
_in_month % Find out how many days in this month=0A       add % Add it to c=
ounter created outside loop=0A    } for=0A    exch pop % Get rid of year=0A=
    3 -1 roll add % Add days of this month into total=0A    exch pop % Get =
read of year=0A} def=0A=0A/FIRST_MISSING_DAY 639799 def=0A/NUMBER_MISSING_D=
AYS 11 def=0A=0A/day_of_week { % day month year -> 0-6=0A    3 copy days_in=
_year % Return the julian date of this year=0A    1 index 1 sub % Store las=
t year to count previous leap years=0A    dup 4 idiv % Find how many leap y=
ears happened during past years=0A    1 index 1700 gt=0A    { %ifelse=0A   =
     1 index 100 idiv 17 sub % After 1700, skip leap year every 100 years=
=0A    }=0A    { %else=0A        0  % Invalid leap years were counted befor=
e 1700=0A    } ifelse=0A    sub % Subtract non-valid leap years.=0A    1 in=
dex 1600 gt=0A    { %ifelse=0A        1 index 1600 sub 400 idiv % Quad cent=
ries are valid leap years=0A    }=0A    { %else=0A        0 % Before 1600 w=
ill be counted by 4 idiv=0A    } ifelse=0A    add % and back in vaid quad-c=
entury leap years=0A    exch 365 mul % Find out how many days have past in =
past years=0A    add % Add extra leap years that last step missed=0A    add=
 % Add in this years days.  Now we have days since 1 jan 1=0A    4 1 roll p=
op pop pop % Get rid of everything but days=0A    dup FIRST_MISSING_DAY lt =
% if before reformation on 3 Sep 1752 =0A    { % elseif=0A        1 sub 6 a=
dd % 1 Jan 1 was a saturday so add 6 to force this=0A	7 mod % Comput 0-6 va=
lue for day of week=0A    }=0A    { %else=0A        dup FIRST_MISSING_DAY N=
UMBER_MISSING_DAYS add ge=0A	{ %elseif=0A	    1 sub 6 add =0A	    NUMBER_MI=
SSING_DAYS sub % Same math but removing missing days=0A	    7 mod=0A	}=0A	{=
 %else=0A	    pop 4 % Force to a thursday... This is an invalid request tho=
ugh=0A	} ifelse=0A    } ifelse=0A} def=0A=0A=0A/day_width month_width 8 div=
 def % 7 days + 1 space=0A/day_length month_length 8 div def % 6 lines for =
days + day string + blank line=0A=0A/show_month { % month year -> -=0A=0A  =
month_font month_font.scale scalefont setfont=0A=0A  0 % start x location f=
or month string=0A  7 day_length mul % y location of month string=0A  month=
_width day_width sub % Remove whitespace included at end of month=0A  4 ind=
ex month_string % Create month string=0A  centered_text=0A=0A  day_font day=
_font.scale scalefont setfont=0A=0A  1 1 7 { %for=0A          dup day_width=
 mul % compute right justified x offset=0A	  6 day_length mul % Compute y o=
ffset=0A	  3 -1 roll % Move day number to front of stack=0A	  dow_string=0A=
          right_text=0A	} for=0A=0A  /counter 1 def =0A=0A  1 1 3 index 3 i=
ndex days_in_month % Setup for loop for each day in month=0A  { %for=0A    =
dup 3 index 3 index day_of_week % Find which dow this day is=0A    dup 1 ad=
d day_width mul % Convert it into right-justified column offset=0A    6 cou=
nter sub % Inverse counter to find row=0A    day_length mul % Compute y off=
set=0A    4 -1 roll 2 string cvs % Create string from day number=0A    righ=
t_text % Display day number=0A    6 eq % Increment row counter if end of we=
ek=0A    { %if =0A        counter 1 add /counter exch def %=0A    } if =0A =
 } for=0A=0A  pop pop % Remove month and year=0A} def=0A=0Aleft_margin top_=
footer translate=0A=0A1 1 12 { gsave=0A         dup 1 sub % duplicate curre=
nt loop value and subtract 1 (0-11)=0A	 months_per_line mod % see which col=
umn we are at=0A	 month_width mul % Compute x offset=0A         1 index 1 s=
ub % duplicate current loop value and subtract 1 (0-11)=0A	 months_per_line=
 idiv % Find which row we are currently on (0 based)=0A	 rows_per_page 1 su=
b % Make 0 based version of rows.=0A	 exch sub % invert meanings since orig=
in is at bottom=0A	 month_length mul % Compute y offset =0A	 translate % Mo=
ve origin to these x,y positions.=0A	 year show_month =0A	 grestore =0A    =
   } for=0A=0Ashowpage=0A
--TB36FDmn/VVEgNH/--