Skip to content

Instantly share code, notes, and snippets.

@SemanticallyNull
Last active December 30, 2015 16:18
Show Gist options
  • Save SemanticallyNull/7853367 to your computer and use it in GitHub Desktop.
Save SemanticallyNull/7853367 to your computer and use it in GitHub Desktop.
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
char *o(t) {
char* string = malloc(5 * sizeof(char));
int i;
for(i=5;i>=0;i--) {
char on = ((t & 1<<i)==1<<i)?'o':'-';
string[5-i] = on;
}
return string;
}
int main() {
while(1) {
time_t nowTime = time(NULL);
struct tm *now = localtime(&nowTime);
printf("H:\t");
char* hr = o(now->tm_hour);
printf("%s", hr);
free(hr);
printf("\nM:\t");
char* mn = o(now->tm_min);
printf("%s", mn);
free(mn);
printf("\nS:\t");
char* sc = o(now->tm_sec);
printf("%s", sc);
free(sc);
printf("\n\033[3A");
sleep(1);
}
return 0;
}
<?php
date_default_timezone_set('Europe/Dublin');
function o($v) {
for($i=5;$i>=0;$i--) {
echo (($v & (1<<$i))===(1<<$i))?'o':'-';
}
echo "\n";
}
while(true){
$now = new DateTime();
$hour = (int) $now->format("h");
$min = (int) $now->format("i");
$sec = (int) $now->format("s");
echo "H:\t";o($hour);
echo "M:\t";o($min);
echo "S:\t";o($sec);
echo "\033[3A";
sleep(1);
}
require 'date'
def o(time)
for i in 0..5
printf "%s", ((time & 1<<(5-i))===1<<(5-i)) ? 'o' : '-'
end
printf "\n"
end
while true do
printf "H:\t"
o(DateTime.now().hour)
printf "M:\t"
o(DateTime.now().minute)
printf "S:\t"
o(DateTime.now().second)
printf "\n\033[4A"
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment