At work I have an adjustible-height desk, that way it can be both a standing or a sitting desk. In order to better understand my own usage habits, I made the desk script, which logs state transitions.

Running desk up records the time that the desk was moved up into a standing position, and desk down records the time the desk was moved into the sitting position. Later, when I have a few months of data, I’ll do some analysis and see what the probabilities are in the following state transition diagram:

The script builds a CSV file, and implements a simple interface:

1
2
3
desk up    # log transition to "up" state at current time
desk down  # log transition to "down" state at current time
desk log   # show last 5 state transitions along with time

Here’s the source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
log_filename="/path/to/log/file"

function create_log_file_if_not_exists {
  if [ ! -e $log_filename ]
  then
    echo "timestamp,state" > $log_filename
  fi
}

function log_new_state {
  create_log_file_if_not_exists

  local state=$1
  local timestamp=$(date --iso-8601=seconds)

  echo "$timestamp,$state" >> $log_filename
}

function show_log {
  create_log_file_if_not_exists

  echo "timestamp                 state"
  awk < $log_filename -F, 'NR > 1 {print $1"  "$2}' | tail -5
}

if [ $1 = "up" ] || [ $1 = "down" ]
then
  log_new_state $1
elif [ $1 = "log" ]
then
  show_log
else
  echo "Invalid command: $1"
  exit 1
fi

This will allow me to use a Markov chain to model my sitting/standing habits. More on markov chains in a later blog post.

On the health benefits (or problems) with standing, I am not a medical professional, but I think alternating sitting and standing is probably better than all sitting or all standing.

When working on rails apps, I usually have to make a mental map of the models and how they interrelate.

An Active Record model can belong to another, but when you have more than half a dozen models, keeping all the belongs_to relations in mind quickly becomes impossible. As a solution to this, I made a command line program called argraph, for ‘ActiveRecord graph’, it produces a digraph in the DOT language, which can be rendered as an image using GraphViz.

The nodes are models, and the edges are the ‘belongs to’ relation.

The way to use it is to check it out or fork my bin repo, make sure that directory is in your PATH variable, cd to the root of your rails app and run argraph.

As an example, suppose you have the discourse rails app checked out, and you want to find out how some of it’s models are interrelated:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ cd discourse
$ argraph Post Topic Category PostReply User UserAction UserHistory QuotedPost View UserAvatar
digraph {
 Post -> User
 Post -> Topic
 Topic -> Category
 Topic -> User
 Category -> Topic
 Category -> User
 PostReply -> Post
 UserAction -> User
 QuotedPost -> Post
 QuotedPost -> QuotedPost
 View -> User
 UserAvatar -> User
}
$ !! | dot -Tpng > discourse.png

The above graph renders as: discourse model graph

You can also run the command with no arguments, in which case it maps out all models, but on bigger apps, this can be hard to follow, so I found it useful to be able to explore subgraphs containing more models than my memory could fit, but not so many that the image was polluted and hard to follow.

Traveling to the future is easy, everyone is doing it at 1 second per second. There are a few possible ways to beat this though, one is relativistic, and the other is thermodynamic:

Special Relativity

For time dilation, you can simply travel at a very high speed. The time dilation (or Lorentz) factor is

So suppose you are flying away from Earth at v meters per second for t seconds, then your clock is slower by a factor of γ. If you turned around and traveled back at v meters per second, you would arrive at Earth having experienced 2t seconds, whereas γ(2t) Earth seconds would have passed.

As a concrete example, suppose you traveled away from Earth at 99.49% the speed of light for 10 years, then γ = 10, meaning that 100 Earth years would have passed. Then, you turn around and head home at the same speed, after 10 years, you arrive. However, if you left in 2014, you would have aged 20 years, but it would be year 2214 back on Earth, you would have effectively traveled 200 years into the future.

The big thing preventing this from being applied any time soon is energy. Kinetic energy is given by ½mv2

Assuming the spacecraft has the same mass as the SpaceX Dragon capsule, which is 6,000kg, The energy of motion for traveling at 99.49% the speed of light would be (1/2)(6000kg)(0.9949*c)2 = 1.868x1020kg m2 / s2 or about 0.44 times the amount of energy consumed by the world in 2001.

While that amount of energy is available to humanity, it would need to be carried by the spacecraft, which would add to the mass. The relativistic option may not be possible until humans become a Type II civilization.

Cryonics

The trip to the future using cryonics would require far less energy than the relativistic one.

All that needs to be done is for a cryoprotectant (basically, antifreeze) to be flooded through the body so that most of the water molecules have been replaced with the cryoprotectant, then, cool the body to -196°C (Liquid Nitrogen temperature), and wait 200 years.

There may not be a functioning civilization in 200 years, or even if there is, they may not have the technology to undo the effects of being saturated with a cryoprotectant and cooled down to such low temperatures.

However, recent developments in suspended animation of humans to buy time while fixing tissue damage suggest that this will be possible, and it may happen in less than 200 years.

Either way, as long as there is a stable civilization with a steady supply of liquid nitrogen, people from our time can stay in a suspended state, where the chemistry of life has stopped, until some time later in the future when medical technology is advanced enough to revive them.

About 9 months ago I wrote about NSA bulk spying and how the way the FISA court is being used upsets the balance of powers in the government, the two bills I referenced have a 4% and 2% chance of being enacted, according to GovTrack. Both of those bills still haven’t left the House, and chances are they won’t.

A more promising bill is the USA FREEDOM Act, which just passed the House:

Unforunately, Rep. Justin Amash noted that the changes to it are so bad, that most of the original co-sponsors are out:

Also, the EFF doesn’t approve. Fortunately, Sen. Patrick Leahy said he intends on fixing a lot of those problems in the Senate version of the bill.

It’s easy to get cynical and fatalistic about the erosion of civil liberties and the problems in government, but recognizing the problems and paying attention, putting pressure on congress can make a difference. Stay rational and contact your representative and senators.

Remember that the Congress is the most powerful branch of government, it makes and destroys laws, with or without the President’s consent (1). Each and every member of congress cares about what we citizens think, because they wish to be re-elected, and we elect them. They are more accesible than you might think.

(1) Even if the President vetos a bill, Congress can still override with a 2/3 supermajority in both houses

This is a great article by Arianna Simpson about using bitcoin to implement assurance contracts. The example she uses is crowdfunding.

This is an example of using cryptocurrencies to implement contract law. It completely removes the need for a third party enforcer, and it shows how security systems can not only augment, but actually replace institutions that use legal pressure to make people cooperate.

In Bruce Schneier’s Liars and Outliers, he identitied three societal trust mechanisms:

  • Moral Pressure
  • Reputational Pressure
  • Institutional Pressure

And then showed that security systems can augment and even replace certain forms of societal pressure to reduce the need for trust in individuals. Bitcoin and other blockchain-backed technologies can do this for many types of contract law. I am excited to see how well this works in practice.