`clang`

or `clang++`

links to the `clang-3.6`

or `clang++-3.6`

executables, or a way of easily selecting the active clang version when you have multiple versions installed.
This command/script creates a clang group using update-alternatives so you can easily execute `clang`

(without the version number) and switch between different clang versions.

The following python script automates the process of converting from Tellico to Calibre so you don’t have to re-enter all the books by hand.

Install requirements (BeautifulSoup v4 is used to parse the XML):

sudo apt-get install python-bs4

Extract the Tellico data (the Tellico file (*.tc) is just a zip file with the XML data and cover images):

mkdir /tmp/tellico cd /tmp/tellico unzip [/path/to/tellico/file/MyBookLibrary.tc]

Now run the import/conversion script. The only argument it needs is the path to the tellico.xml file that you just unzipped:

python Tellico2Calibre.py tellico.xml

All the books are tagged with “Print”, and if they’re marked as loaned out in Tellico they also get the “Loaned” tag. The following data is imported:

- Title
- Authors
- ISBN
- Cover image
- Publisher
- Published date
- Comments
- Rating

Here’s a before/after image (click for the full size):

]]>`vim`

is harder than it should be. Scripts such as `Tail-Bundle`

and `WatchForChanges`

rely on vim’s `CursorHold`

events which only trigger once. Unlike `tail -f`

, they only work if you’re active in that `vim`

session and pressing keys to cause CursorHold to re-arm.
`tail -f`

works well, but lacks the syntax highlighting and other features from `vim`

.

Some other options require 2 terminals, or 2 separate scripts.

The solution below is very similar to `tail -f`

. The primary difference is that it only monitors a single file at a time.

Get the latest version from: https://gist.github.com/4a334b61e1c34b438ccd.git

#!/bin/bash # Usage: vim-tail.sh <filename> # # This script turns vim into a `tail -f` equivalent, but with syntax # highlighting and all the other goodies. # # A version of vim compiled with +clientserver is required. # On Ubuntu 14.04, vim.tiny, vim.basic and vim.nox won't work. # vim.gtk is compiled with +clientserver, so `apt-get install vim-gtk` # # Author: Gabriel Burca <gburca dash github at ebixio dot com> # Pick one of: vim|view|gvim|gview, etc... VI=vim.gtk # A unique name for the server, in case we monitor multiple files. NAME="TAIL$$" doForever() { # Give the vim server a chance to start sleep 2 # Move to the end of the file $VI --servername $NAME --remote-send '<C-\><C-N>:edit!<CR>G' > /dev/null 2>&1 || exit while true; do # This blocks until the file changes, or the timeout expires inotifywait --quiet --quiet --timeout 10 --event modify "$1" # 0 = the file was modified # 2 = the timeout expired if (( $? == 0 || $? == 2 )); then $VI --servername $NAME --remote-send '<C-\><C-N>:edit!<CR>G' > /dev/null 2>&1 || exit else exit 1 fi # It's possible for the file to be modified before we loop back to # `inotifywait`, but we'll pick it up on the next round. done } # Kick off the vim client script in the background coproc doForever "$1" # Now start the server $VI --servername $NAME --remote-silent "$1" # Nothing below here executes until the `tail` server exits.]]>

First install digikam:

add-apt-repository ppa:philip5/extra apt-get update apt-get install digikam

At this point everything should have worked nicely. Unfortunately digikam (version: 4:4.10.0-trusty~ppa3) wouldn’t start up. Running it from the command line showed that I was missing libavcodec.so.53. To confirm:

ldd /usr/bin/digikam | grep libavcodec

The normal solution to this would have been:

apt-get install libavcodec-extra-53

But life is not that simple. Ubuntu deprecated and removed libavcodec-extra-53 and claims libav-tools should be used instead. libav-tools however doesn’t include a libavcodec.so.53 file, so after a bit of hunting around, I decided to just build it from source. Here are the steps:

git clone git://source.ffmpeg.org/ffmpeg.git cd ffmpeg git checkout -b ver53 dd453f ./configure --prefix=/usr/local --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-avdevice --disable-swresample --disable-swscale --disable-postproc --disable-avfilter --enable-shared --disable-debug --enable-gpl --enable-x11grab make sudo su - checkinstall ldconfig

After this, digikam started up properly.

`gitk --all libavcodec/version.h`

shows that after the **dd453f** commit the libavcodec version changes to 54, so that’s why that commit was used.

- TMP36 at $2.
- 10K Precision Epoxy Thermistor – 3950 NTC at $4.
- DHT22 at $12.50. This one also contains a humidity sensor, so that’s why it’s more expensive than the other two.

This is how accurate they each claim to be:

Model | Accuracy in °C | Accuracy in °F |
---|---|---|

TMP36 | ±2.00°C | ±3.6°F |

Thermistor | ±0.45°C | ±0.8°F |

DHT22 | ±0.50°C | ±0.9°F |

All the data below was collected with a BeagleBone Black which has a 12-bit ADC. The 10K thermistor was hooked up in a voltage divider configuration with a 1% 10K resistor. The DHT22 uses a thermistor inside as well, but has a digital output. Readings were taken every 3s over a 2 hour period.

The sensors are all positioned within 1/4″ of each other. The slow temperature drifts are from the house cooling and the furnace heating it back up.

I used a running average filter with a window of 10 samples to clean up the noise a bit and these are the results.

Finally, taking the 10K thermistor as ground truth, these are the differences observed. The TMP36 is consistently about 2°F lower than the thermistor, and the DHT22 is roughly 1°F higher even though it’s also using a thermistor inside. I don’t know how accurate the ADC inside the DHT22 is, so that might explain some of the difference.

In conclusion, when you hear someone say “I keep my thermostat at 67°F” and another guy responds “My wife would kill me if I did that. I keep mine at 73°F” they might both be keeping their temperature at 70°F. It just depends on what temperature sensor their thermostat is using, and how well it was calibrated.

]]>This Tig Quick Reference Card shows all the key bindings supported by tig version 0.17.

The reference card is available as a PDF so you can print it out. The PDF version is derived from the TeX file which is hosted at http://github.com/gburca/git-qrc so anyone can update it.

]]>We start with an acceleration defined as:

\[

A = \sum\limits_{i} a_i \sin(c_i t) dt

\]

First integration, to obtain velocity:

\[

\begin{align}

V = \int\limits_{s}^{e} \sum\limits_{i} a_i \sin(c_i t) dt &= \sum\limits_{i}{ – \frac{a_i \cos(c_i x)}{c_i}\bigg|_{s}^{e}} \\

&= \sum\limits_{i}{ – \frac{a_i \cos(c_i e)}{c_i}} \ – \sum\limits_{i}{ – \frac{a_i \cos(c_i s)}{c_i}}

\end{align}

\]

Let \(m \equiv \sum\limits_{i}{ – \frac{a_i \cos(c_i s)}{c_i}}\) and then do the second integration, to obtain displacement or position.

\[

\begin{align}

D &= \int\limits_{g}^{h} \sum\limits_{i}{ – \frac{a_i \cos(c_i e)}{c_i}} \ – m\ de \\

&= \sum\limits_{i}{-\frac{a_i \sin(c_i e)}{c_i^2} – me \bigg|_g^h} \\

&= \left[ \sum\limits_{i}{-\frac{a_i \sin(c_i h)}{c_i^2}} – mh \right] – \left[ \sum\limits_{i}{-\frac{a_i \sin(c_i g)}{c_i^2}} – mg \right]

\end{align}

\]

Substitute everything back in (given \(g \equiv s\) and \(h \equiv e\)), and simplify:

\[

\begin{align}

D &= \left[ \sum\limits_{i}{-\frac{a_i \sin(c_i h)}{c_i^2}} – mh \right] – \left[ \sum\limits_{i}{-\frac{a_i \sin(c_i g)}{c_i^2}} – mg \right] \\

&= \left[ \sum\limits_{i}{-\frac{a_i \sin(c_i e)}{c_i^2}} – me \right] – \left[ \sum\limits_{i}{-\frac{a_i \sin(c_i s)}{c_i^2}} – ms \right] \\

&= \sum\limits_{i}{-\frac{a_i \sin(c_i e)}{c_i^2}} \ – \sum\limits_{i}{-\frac{a_i \sin(c_i s)}{c_i^2}} + (s-e)\sum\limits_{i}{ – \frac{a_i \cos(c_i s)}{c_i}} \\

&= \sum\limits_{i}{\frac{a_i \sin(c_i s)}{c_i^2}} \ – \sum\limits_{i}{\frac{a_i \sin(c_i e)}{c_i^2}} + (e-s)\sum\limits_{i}{\frac{a_i \cos(c_i s)}{c_i}}

\end{align}

\]

Finally, to take the phase of the signal into account, we would start with:

\[

A = \sum\limits_{i} a_i \sin(c_i t + p_i) dt

\]

And end with:

\[

D = \sum\limits_{i}{\frac{a_i \sin(c_i s + p_i)}{c_i^2}} \ – \sum\limits_{i}{\frac{a_i \sin(c_i e + p_i)}{c_i^2}} + (e-s)\sum\limits_{i}{\frac{a_i \cos(c_i s + p_i)}{c_i}}

\]

Recently I was trying to double integrate a sinusoidal acceleration (ex: a frog leaping forward) and was a bit puzzled at first why double integrating the \(\sin(t)\) wave resulted in no displacement after an integral number of cycles:

\[

\begin{eqnarray}

v(t) = \int \sin(t) dt &=& -\cos(t) \\

d(t) = \int -\cos(t) dt &=& -\sin(t)

\end{eqnarray}

\]

Everybody knows that integrating once gives you velocity, and integrating twice gives you displacement (or position). But if that’s the case, why is the displacement (\(-sin(t)\)) above sinusoidal? Shouldn’t the frog be moving forward instead of back and forth?

It turns out my calculus was rusty enough to where I missed one very obvious fact. In the process I learned the distinction between a *multiple (or double) integral*, which is an integral taken over different variables (ex: \(\int \int f(x, y) dx\ dy\)) and a *repeated integral* which is taken multiple times over the *same* variable. What I missed was the difference between an *indefinite* integral (shown above) and a *definite* integral (shown below).

So let’s make the problem a little more generic and add amplitude and frequency component to our acceleration signal, and then see what happens to it as we integrate it twice. We’ll start with an acceleration signal defined as:

\[A = a \sin(c*t)\]

and we’ll integrate it twice over the interval start..end (\(s..e\)) to see what we get.

For the first integration we have:

\[

\begin{align}

V_{t = e} = \int_{s}^{e} a \sin(ct) dt &= \ – \frac{a \cos(ct)}{c}\bigg|_{s}^{e} \\

&= -\frac{a \cos(ce)}{c} + \frac{a \cos(cs)}{c}

\end{align}

\]

So that allows us to calculate the velocity at any point \( t = e \) after the starting time \(s\). Now we want to integrate a second time to get the displacement. To avoid confusion with the \(s..e\) interval used for the first integration, we’ll use \(g..h\) as the integration interval this time around. To simplify things, let’s also rename the integration constant (time independent) term \(\frac{a \cos(cs)}{c} \equiv m\).

\[

\begin{align}

D_{t = h} = \int_{g}^{h} -\frac{a \cos(ce)}{c} + m\ de &= -\frac{a \sin(ce)}{c^2} + me \bigg|_{g}^{h} \\

&= \left[ mh – \frac{a \sin(ch)}{c^2} \right] – \left[ mg – \frac{a \sin(cg)}{c^2} \right]

\end{align}

\]

Since both integrations are over the same intervals, we know that \(g \equiv s\) and \(h \equiv e\). Now substitute everything back in and simplify:

\[

\begin{align}

D_{t = e} &= \left[ mh – \frac{a \sin(ch)}{c^2} \right] – \left[ mg – \frac{a \sin(cg)}{c^2} \right] \\

&= \left[ me – \frac{a \sin(ce)}{c^2} \right] – \left[ ms – \frac{a \sin(cs)}{c^2} \right] \\

&= m(e-s)\ – \frac{a \sin(ce)}{c^2} + \frac{a \sin(cs)}{c^2} \\

&= \frac{a \cos(cs)}{c} (e-s)\ – \frac{a \sin(ce)}{c^2} + \frac{a \sin(cs)}{c^2}

\end{align}

\]

If we want to take into account the phase of the signal, we start with:

\[

A = a \sin(ct + p)

\]

and end with:

\[

D = \frac{a \cos(cs+p)}{c} (e-s)\ – \frac{a \sin(ce+p)}{c^2} + \frac{a \sin(cs+p)}{c^2}

\]

So there you have it. The result of integrating a sinusoidal acceleration twice on the interval \(s..e\) in order to arrive at the displacement.

]]>remote: error: By default, deleting the current branch is denied, because the next remote: error: 'git clone' won't result in any file checked out, causing confusion. remote: error: remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the remote: error: current branch, with or without a warning message. remote: error: remote: error: To squelch this message, you can set it to 'refuse'. remote: error: refusing to delete the current branch: refs/heads/master To /somewhere/in/the/cloud/repo.git ! [remote rejected] master (deletion of the current branch prohibited) error: failed to push some refs to '/somewhere/in/the/cloud/repo.git'

The reason you’re seeing the error is that HEAD on the remote repository by default contains something like this (see also line 9 in the error message above):

ref: refs/heads/master

If you have access to the remote repository, simply modify the **HEAD** file to point to a different branch and then you’ll be able to delete the remote master branch. There are some significant implications to modifying the remote **HEAD**, especially if other users are tracking that branch, so make sure you know what you’re doing if you choose to point it to some other arbitrary branch.