a technical notebook
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
5.3 KiB

9 years ago
  1. Friday, December 19, 2014
  2. =========================
  3. {timetracking}
  4. So hamster really doesn't scratch my particular itch all that well. Rather
  5. than devote any serious brain energy to finding or writing a replacement that
  6. does, I've decided to just use a text file.
  7. It looks like the following:
  8. 2014-12-17 21:55 - 2014-12-17 11:40
  9. 2014-12-18 10:05 - 2014-12-18 12:50
  10. 2014-12-18 13:45 - 2014-12-18 16:00
  11. This is just two datetimes for each range of time when I'm working on a given
  12. thing, delimited by `/ - /`. I just want a quick script to tally the time
  13. represented. (Later, if I need to track more than one project, I'll expand on
  14. this by adding a project name and/or notes to the end of the line.)
  15. It kind of seems like I should be able to do this with GNU `date`, but let's
  16. find out. Here're the [official examples][date-examples]. This sounds about
  17. right:
  18. > To convert a date string to the number of seconds since the epoch (which is
  19. > 1970-01-01 00:00:00 UTC), use the --date option with the ‘%s’ format. That
  20. > can be useful in sorting and/or graphing and/or comparing data by date. The
  21. > following command outputs the number of the seconds since the epoch for the
  22. > time two minutes after the epoch:
  23. >
  24. > date --date='1970-01-01 00:02:00 +0000' +%s
  25. > 120
  26. As a test case, I start here:
  27. $ cat ~/bin/timelog
  28. #!/usr/bin/env bash
  29. date --date="$1" +%s
  30. $ timelog '2014-12-17 21:55'
  31. 1418878500
  32. Ok, groovy.
  33. I was going to do the rest of this in shell or awk or something, but then I
  34. thought "I should not spend more than 10 minutes on this", and wrote the following
  35. Perl:
  36. #!/usr/bin/env perl
  37. use warnings;
  38. use strict;
  39. use 5.10.0;
  40. my $total_hours = 0;
  41. # while we've got input from a file/stdin, split it into two datestamps
  42. # and feed that to date(1)
  43. while (my $line = <>) {
  44. chomp($line);
  45. my ($start, $end) = map { get_seconds($_) } split / - /, $line;
  46. my $interval = $end - $start;
  47. my $hours = $interval / 3600;
  48. $total_hours += $hours;
  49. say sprintf("$line - %.3f hours", $hours);
  50. }
  51. say sprintf("%.3f total hours", $total_hours);
  52. sub get_seconds {
  53. my ($stamp) = @_;
  54. my $seconds = `date --date="$stamp" +%s`;
  55. chomp($seconds);
  56. return $seconds;
  57. }
  58. Which gives this sort of output:
  59. brennen@desiderata 14:54:38 /home/brennen/bin (master) ★ timelog ~/notes/some_employer.txt
  60. 2014-12-15 13:10 - 2014-12-15 14:35 - 1.417 hours
  61. 2014-12-16 10:00 - 2014-12-16 12:55 - 2.917 hours
  62. 2014-12-16 14:00 - 2014-12-16 17:15 - 3.250 hours
  63. 2014-12-17 15:00 - 2014-12-17 16:51 - 1.850 hours
  64. 2014-12-17 21:55 - 2014-12-17 23:40 - 1.750 hours
  65. 2014-12-18 10:05 - 2014-12-18 12:50 - 2.750 hours
  66. 2014-12-18 13:45 - 2014-12-18 16:00 - 2.250 hours
  67. 2014-12-18 17:00 - 2014-12-18 17:30 - 0.500 hours
  68. 16.683 total hours
  69. This is me once again being lazy and treating Perl as a way to wrap shell
  70. utilities when I want to easily chop stuff up and do arithmetic. It is _many
  71. kinds of wrong_ to do things this way, but right now I don't care.
  72. If this were going to be used by anyone but me I would do it in pure-Perl and
  73. make it robust against stupid input.
  74. [date-examples]: https://www.gnu.org/software/coreutils/manual/html_node/Examples-of-date.html
  75. drawing tools
  76. -------------
  77. Ok, so because I'm starting to poke at drawing again for the first time in
  78. quite a while (even to the extent that I'll soon be publishing some stuff that
  79. includes cartoon graphics, despite having _no_ idea what I'm doing), I thought
  80. I'd take some rough notes on where I'm at with toolset.
  81. The first thing is that I'm not using any Adobe tools, or indeed any
  82. proprietary software (unless you count the firmware on my cameras and maybe
  83. Flickr) to work with images. I am fully aware that this is a _ridiculous_
  84. limitation to self-impose, but I want to stick with it as best I can.
  85. For a long time, I've sort of fumbled my way through GIMP whenever I needed to
  86. do the kind of light image editing stuff that inevitably comes up in the life
  87. of a web developer no matter how many things you foist off on your
  88. Photoshop-skilled, design-happy coworkers. I think GIMP gets kind of an unfair
  89. rap; it's a pretty capable piece of software. That said, I've still never
  90. really put the time in to get genuinely skilled with it, and it's not the most
  91. accessible thing for just doodling around.
  92. Several years back, I [bought a cheap Wacom tablet](https://p1k3.com/2011/4/13).
  93. I was maybe a little optimistic in that writeup, but I still really enjoy
  94. [MyPaint](http://mypaint.intilinux.com/). The problem is that, while it's really
  95. fun for a sketchy/painty/extemperaneous kind of workflow, and dovetails
  96. beautifully with the tablet interface, it deliberately eschews a lot of features
  97. that you start to want for _editing_ an image. I don't blame its developers for
  98. that --- they're obviously trying to do a certain kind of thing, and constraints
  99. often make for great art --- but I'm wondering if I can't get some of the same
  100. vibe with a tool that also lets me easily cut/copy/scale stuff.
  101. I'm giving [Krita](https://krita.org/) a shot with that in mind. It has a real
  102. KDE vibe to it. Lots of modular GUI widgets, menus, etc. A little
  103. bureaucratic. It doesn't feel as fluid or immediate as MyPaint right out of
  104. the gate, but it's definitely got more in the way of features. Could grow on
  105. me.