.bash_profile vs .bashrc or why does OS X ignore my .bashrc in Terminal.app?

## Keyboard shortcut to un-minimise a window in OS X

It’s a bit fiddly but it can be done.

Cmd+m to the item you want to un-minimise, then while still holding cmd, press Option. Release Cmd and then finally release Option.

## Cmd+m to Minimise a window in OS X

Cmd+m to minimise a window in OS X

## Insert a new heading after numbered list in org-mode

In org-mode in emacs, `M-<RET>`

will add either a new heading or if your insertion point is between a list item and a heading, it will add a new list item. This is not always desirable. To add a new heading try `C-U M-<RET>`

.

I only discovered this as I got frustrated with org-mode insisting on adding an item to the list rather than creating a new heading. The emacs way around problems like this is to prefix the command with `C-U`

to make it do something slightly different.

## Collaborative online $\LaTeX$ documents

writelatex.com is awesome. Edit your $LaTeX$ document and see the changes almost immediately.

## Collectd causing rrd illegal attempt to update using time errors

I found collectd causing rrd illegal attempt to update using time errors. I was seeing a whole load of lines like this in my syslog:

`Aug 20 16:27:12 mythbox collectd[32167]: rrdtool plugin: rrd_update_r (/var/lib/collectd/rrd/mythbox/df-root/df_complex-free.rrd) failed: /var/lib/collectd/rrd/mythbox/df-root/df_complex-free.rrd: illegal attempt to update using time 1345444032 when last update time is 1345444032 (minimum one second step)`

It was adding one message like that every second so my logs were completely full of it. Google didn’t reveal much except that this sort of error is either because there are two instances of RRD trying to write the RRD database at the same time, or that my server’s date and time are way out of sync. Neither of these were true in my case.

I asked on #collectd on freenode and a very nice person by the name of tokkee told me that it’s a known issue of sorts. The df plugin for collectd uses /proc/mount to determine which drives to check free space on and if / is in there twice, it tries to update the entry for / twice and causes the problem.

The solution is to add the following to the /etc/collectd/collectd.conf file:

<Plugin df> FSType "rootfs" IgnoreSelected true </Plugin> |

Then I restarted collectd and my logs were peaceful again.

Update 2014-04-10:

I was getting these errors again on one of my VPS hosts. In this instance, / only appeared once in /proc/mounts but /run was in there multiple times:

root@new:/etc/collectd# cat /proc/mounts rootfs / rootfs rw 0 0 /dev/root / ext3 rw,relatime,errors=remount-ro,data=ordered 0 0 devtmpfs /dev devtmpfs rw,relatime,size=1085360k,nr_inodes=271340,mode=755 0 0 tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=217328k,mode=755 0 0 tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0 proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=460860k 0 0 devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620 0 0 root@new:/etc/collectd# |

The solution is to ignore tmpfs instead of rootfs:

<Plugin df> FSType "tmpfs" IgnoreSelected false </Plugin> |

## Choosing passwords for the 21st century

The recent Mat Honan hack got me thinking about password strength. It turns out he was hacked not due to having a poor password, but because of a security flaws in Amazon and Apples’ systems. Nevertheless it serves as a good reminder to keep yourself safe.

One thing you can do is use very long passwords for important things. Increasing the length of your password can make it seriously more difficult for anyone to brute force attack your password.

To get an idea of the impact a long password, have a look at this site: How Big is your Haystack. It lets you type in a password and it gives you an idea of how long it would withstand a brute force attack for. Obviously don’t type your real password in, but type in something that uses the same number of letters, numbers, capitals and punctuation and see how it looks.

8 lower case letter passwords? 2.17 seconds in an offline attack scenario. It’s not until you get up to 17 lower case letters that it pushes the offline attack scenario into the the virtually impossible range.

So how do you go about picking a strong password?

Diceware. Essentially you roll a dice 25 times to form 5 groups of 5 numbers. Then you look each number up in the list of words to generate a 5 word password. Being 5 words makes it relatively easy to remember but also very long.

If you don’t feel like rolling dice, you could consider using random.org to generate a list of numbers for you. If you choose this approach, make sure to visit the site using https and get a nice long list and choose a set of numbers from the list. Write it down on a piece of paper and put it in a safe place. Note this is not as secure as using the offline dice rolling approach.

As a final note, consider using multi factor authentication if you can. Google have made it available for gmail and I recommend you sign up for it.

## CSS Arrows

cssarrowplease makes lovely speech bubbles in pure CSS.

## Twenty Twelve WordPress theme

I switched to using the Twenty Twelve WordPress theme a few days ago. I really am liking it although I’m not sure about the header image being below Site Title and Tag Line. That looks a little strange to me.

Having said that, I think Twenty Twelve looks fantastic on the demo site.

Currently you have get Twenty Twelve from the WordPress trac repository as as far as I know it is not released yet. They will release it as a stand alone theme soon I believe, so you can try it out before WordPress 3.5 is released.

I did a `git clone`

of the WordPress code mirror on github, into my home directory. Then I symlinked the `~/wordpress-git/wp-content/themes/twentytwelve`

directory to my live WordPress install path. That way I can simply do a `git pull`

to update the theme.

## \(\LaTeX\) Equations in WordPress using MathJax

I came accross this great tool for displaying mathematical equations the other day. MathJax not only supports \(\LaTeX\) syntax but also renders the equations as pure text, so no unsightly images and they scale beautifully. You can also right click on the equation and see it’s \(\LaTeX\) code.

The code for MathJax is open source, but if you don’t want to go to the bother of installing it yourself, you can use it on their CDN.

There are a couple of plugins to enable MathJax in WordPress. I’m using the Simple MathJax plugin. I’ve not tried the others.

To use MathJax simply mark up your equation with `\[…\]`

. If you want to have an equation inline, use `\(…\)`

. You can also inline equations in the post title.

Here are a few examples taken from the MathJax site:

### The Lorenz Equations

\begin{aligned}

\dot{x} & = \sigma(y-x) \\

\dot{y} & = \rho x – y – xz \\

\dot{z} & = -\beta z + xy

\end{aligned}

### The Cauchy-Schwarz Inequality

\[\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)\]

### A Cross Product Formula

\[\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}

\mathbf{i} & \mathbf{j} & \mathbf{k} \\

\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\

\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0

\end{vmatrix}\]

### The probability of getting \(k\) heads when flipping \(n\) coins is

\[P(E) = {n \choose k} p^k (1-p)^{ n-k}\]

### An Identity of Ramanujan

\[\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =

1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}

{1+\frac{e^{-8\pi}} {1+\ldots} } } }\]

### A Rogers-Ramanujan Identity

\[1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =

\prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},

\quad\quad \text{for $|q|<1$}.\]

### Maxwell’s Equations

\begin{aligned}

\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\

\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\

\nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}