Giter VIP home page Giter VIP logo

ticktock's Introduction

What?

This is the little API consumer that could for the time tracker Harvest. All this does is connects to Harvest and finds out how many hours a user has logged for the current semi-monthly period. Alternatively, you can see how many hours the user has logged in the past year that remain uninvoiced.

How?

Enter your credentials into config/authentication.yml. If the file doesn't exist, just create it first based on config/authentication.yml.example. Note that you must put your user_id which you can find inside the querystring of most Harvest requests when using their website.

Next, run it with either uninvoiced support:

UNINVOICED=true ruby ticktock.rb

Or with semi-monthly support:

SEMIMONTHLY=true ruby ticktock.rb

This will output to a file inside the directory called .hours with a float value representing how many hours for that user.

Automate it!

I have the following in my ~/.bash_profile:

parse_hours() {
  [ -e /path/to/ticktock/.hours ] && cat /path/to/ticktock/.hours
}
set_ps1() {
  # ... Lots of other things here that aren't relevant ...

  local hours=`printf "%.2f" $(parse_hours)`
  PS1="[$hours] \t:"
}

PROMPT_COMMAND += 'set_ps1;'

This works in conjunction with a script used by crontab at ~/bin/tick:

#!/bin/sh
source /path/to/.rvm/scripts/rvm
cd /path/to/ticktock
ruby ticktock.rb

I have this installed to crontab using:

*/30 * * * * /bin/bash -c '. $HOME/.bashrc && UNINVOICED=true ~/bin/tick'

Or for semi-monthly support:

*/30 * * * * /bin/bash -c '. $HOME/.bashrc && SEMIMONTHLY=true ~/bin/tick'

So, every 30 minutes I get an update on my terminal like magic. This relies on you having run bundle install inside your default Ruby (in my case using chruby) so that all the required gems are available.

ticktock's People

Contributors

parndt avatar

Watchers

Amanda Wagener avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.