June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,11 +1,14 @@
|
|||
/*Abhishek Ghosh, Original : 20th September 2017, Corrected : 25th September 2017*/
|
||||
|
||||
#include<unistd.h>
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
|
||||
#define DELAY 3000
|
||||
#define SHORTLAG 1000
|
||||
#define LONGLAG 2000
|
||||
|
||||
int main(){
|
||||
int i,times;
|
||||
int i,times,hour,min,sec,min1,min2;
|
||||
|
||||
time_t t;
|
||||
struct tm* currentTime;
|
||||
|
|
@ -14,22 +17,39 @@ int main(){
|
|||
time(&t);
|
||||
currentTime = localtime(&t);
|
||||
|
||||
times = (currentTime->tm_hour%12==0)?12:currentTime->tm_hour%12;
|
||||
hour = currentTime->tm_hour;
|
||||
min = currentTime->tm_min;
|
||||
sec = currentTime->tm_sec;
|
||||
|
||||
if(currentTime->tm_min==0 && currentTime->tm_sec==0){
|
||||
printf("\nIt is now %d:00 %s. Sounding the bell %d times.",times,(currentTime->tm_hour>11)?"PM":"AM",times);
|
||||
hour = 12;
|
||||
min = 0;
|
||||
sec = 0;
|
||||
|
||||
for(i=0;i<times;i++){
|
||||
if((min==0 || min==30) && sec==0)
|
||||
times = ((hour*60 + min)%240)%8;
|
||||
if(times==0){
|
||||
times = 8;
|
||||
}
|
||||
|
||||
if(min==0){
|
||||
min1 = 0;
|
||||
min2 = 0;
|
||||
}
|
||||
|
||||
else{
|
||||
min1 = 3;
|
||||
min2 = 0;
|
||||
}
|
||||
|
||||
if((min==0 || min==30) && sec==0){
|
||||
printf("\nIt is now %d:%d%d %s. Sounding the bell %d times.",hour,min1,min2,(hour>11)?"PM":"AM",times);
|
||||
|
||||
for(i=1;i<=times;i++){
|
||||
printf("\a");
|
||||
sleep(DELAY);
|
||||
|
||||
(i%2==0)?sleep(LONGLAG):sleep(SHORTLAG);
|
||||
}
|
||||
}
|
||||
|
||||
else if(currentTime->tm_min==30 && currentTime->tm_sec==0){
|
||||
printf("\nIt is now %d:30 %s. Sounding the bell once.",times,(currentTime->tm_hour>11)?"PM":"AM");
|
||||
printf("\a");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
1
Task/Nautical-bell/Mathematica/nautical-bell.math
Normal file
1
Task/Nautical-bell/Mathematica/nautical-bell.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
SessionSubmit[ScheduledTask[EmitSound[SoundNote["C", 1, "TubularBells"]], "Hourly"]]
|
||||
|
|
@ -1,25 +1,24 @@
|
|||
/*REXX program sounds "ship's bells" (using PC speaker) when executing (perpetually).*/
|
||||
echo= (arg()\==0) /*echo time and bells if any arguments.*/
|
||||
echo= ( arg()\==0 ) /*echo time and bells if any arguments.*/
|
||||
signal on halt /*allow a clean way to stop the program*/
|
||||
t.1= '00:30 01:00 01:30 02:00 02:30 03:00 03:30 04:00'
|
||||
t.2= '04:30 05:00 05:30 06:00 06:30 07:00 07:30 08:00'
|
||||
t.3= '08:30 09:00 09:30 10:00 10:30 11:00 11:30 12:00'
|
||||
|
||||
do forever; t=time(); ss=right(t,2); mn=substr(t,4,2) /*the current time. */
|
||||
ct=time('C') /*[↓] maybe add leading zero*/
|
||||
hhmmc=left( right( ct, 7, 0), 5) /*HH:MM (with leading zero).*/
|
||||
if echo then say center(arg(1) ct, 79) /*echo 1st arg with the time?*/
|
||||
if ss\==00 & mn\==00 & mn\==30 then do /*wait for the next minute ? */
|
||||
call delay 60-ss; iterate
|
||||
end /* [↑] delay minute fraction*/
|
||||
/* [↓] number bells to peel.*/
|
||||
do j=1 for 3 until $\==0; $=wordpos(hhmmc,t.j)
|
||||
end /*j*/
|
||||
do forever; t=time(); ss=right(t, 2); mn=substr(t, 4, 2) /*the current time.*/
|
||||
ct=time('C') /*[↓] maybe add leading zero to time. */
|
||||
hhmmc=left( right( ct, 7, 0), 5) /*HH:MM (maybe with a leading zero). */
|
||||
if echo then say center(arg(1) ct, 79) /*echo the 1st argument with the time? */
|
||||
if ss\==00 & mn\==00 & mn\==30 then do; call delay 60-ss; iterate
|
||||
end /* [↑] delay for fraction of a minute.*/
|
||||
/* [↓] the number of bells to peel {$}*/
|
||||
do j=1 for 3 until $\==0; $=wordpos(hhmmc, t.j)
|
||||
end /*j*/
|
||||
|
||||
if $\==0 & echo then say center($ "bells", 79) /*echo the bells ? */
|
||||
if $\==0 & echo then say center($ "bells", 79) /*echo the number of bells? */
|
||||
|
||||
do k=1 for $; call sound 650,1; call delay 1 +(k//2==0)
|
||||
end /*k*/ /*[↑] peel and then pause. */
|
||||
call delay 60 /*ensure we don't re-peel. */
|
||||
do k=1 for $; call sound 650,1; call delay 1 + (k//2==0)
|
||||
end /*k*/ /*[↑] peel, and then pause for effect.*/
|
||||
call delay 60; if rc\==0 then leave /*ensure we don't re─peel. */
|
||||
end /*forever*/
|
||||
halt: /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
23
Task/Nautical-bell/Ring/nautical-bell.ring
Normal file
23
Task/Nautical-bell/Ring/nautical-bell.ring
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Project : Nautical bell
|
||||
# Date : 2017/12/26
|
||||
# Author : Gal Zsolt (~ CalmoSoft ~)
|
||||
# Email : <calmosoft@gmail.com>
|
||||
|
||||
m = 0
|
||||
for n = 0 to 23
|
||||
if n = 23
|
||||
see "23" + ":30" + " = " + "7 bells" + nl
|
||||
else
|
||||
m = m + 1
|
||||
see "" + n%23 + ":30" + " = " + m + " bells" + nl
|
||||
ok
|
||||
if n = 23
|
||||
see "00" + ":00" + " = " + "8 bells" + nl
|
||||
else
|
||||
m = m + 1
|
||||
see "" + (n%23+1) + ":00" + " = " + m + " bells" + nl
|
||||
if m = 8
|
||||
m = 0
|
||||
ok
|
||||
ok
|
||||
next
|
||||
Loading…
Add table
Add a link
Reference in a new issue