Functions
WebDev/*nix assorted functions & hacks
Search
find all
Array
-
Bash
-
Classes
-
Config
-
DateTime
-
Debug
-
dotjs
-
File
-
foooo
-
Git
-
HTML
-
Images
-
Javascript
-
Linux
-
Math
-
Misc
-
MySQL
-
OS X
-
Reading
-
Redis
-
Shell scripts
-
snippets
-
SQL
-
Strings
-
TextMate
-
Web
-
\(^o^)/ Fun!
-
_Misc hacks
-
_Pages
Bash
goto
mcal
2
found
auth
Name:
Category: Bash
Body:
# bored at work. and I wanted the hilight colour to survive past piping because reasons. #!/usr/bin/env php <?php array_shift($argv); // get rid of commandname $time = time(); if ($argc > 1) $time = strtotime(join(' ', $argv)); $hilight = true; $header = date('F Y', $time); echo str_repeat(' ', (floor(20 - strlen($header)) / 2))."$header\n"; $names = explode(' ', "Mo Tu We Th Fr Sa Su"); echo join(' ', $names)."\n"; $days = date('t', $time); // days in this month $numbers = range(1, $days); $first_day = substr(date('D', strtotime(date('Y-m-01', $time))), 0, 2); // first two letters of name of first day for ($i=0; $i < array_search($first_day, $names); $i++) array_unshift($numbers, ''); // prepend the list of days with some empty values so we can simply loop through it and add a line every 7th foreach($numbers as $i => $num) { if ($hilight and date('j', $time) == $num) echo "\e[30;47m"; echo str_pad($num, 2, ' ', STR_PAD_LEFT); if ($hilight and date('j', $time) == $num) echo "\e[0m"; echo ' '; if (($i+1)%7==0) echo "\n"; } echo "\n";
Footer