Posts Tagged ‘time’

8:30 is the perfect time for anything

Tuesday, November 26th, 2013

8:30 is the perfect time for anything

Determine more recent of two files in bash

Friday, February 18th, 2011

Here’s a simple bash script that determines the more recent of two files”:

# Usage:
#    morerecent file1 file2
if [[ `stat -f %c "$1"` > `stat -f %c "$2"` ]];
  echo "$1"
  echo "$2"

Note: It seems stat is infamously implementation dependent so the format/parameters may be different for your machine.

Getting python to print 5 digits of accuracy in the current time in seconds

Monday, January 11th, 2010

In the python shell if I type:

import time

I get the current time in seconds with 5 digits past the decimal place of accuracy:


If I want to use this as a unique ID then I need to have this value as a string. Namely I need to be able to print it. But if I issue:

print time.time()

I only get 2 digits of accuracy past the decimal place:


This seems to be because print when converting the time to a string is rounding its float value someplace. To solve this I use instead:

print "%f" %  time.time()

Which again returns all of the accuracy places I original had:


Finally to save this value as a string I just remove the print and instead have a variable on the left hand side of an equals sign:

current_time = "%f" %  time.time()

New Clock Design

Wednesday, December 2nd, 2009

I’ve made a new digital design prototype for a physical clock I plan to build.
Here’s a preview of my geometric clock prototype in action:

Here’s a preview of my geometric clock prototype frozen:
geometric clock design prototype