Remove "Picked for you" pins from Pinterest.

Update: Pinterest now lets you disable Picked For You pins! Go to your profile, then press the settings button (a hexagonal bolt). Scroll down to "Home feed", then switch 'Show "Picked for you" Pins in your home feed' to 'No'.

Thank you all for your kind comments and bug fixing for this script. I hope it was useful.
Remove Picked For You pins from Pinterest
It's no secret that I love Pinterest more than is really okay. They've started doing this thing where they show you "Picked for you" pins on your homepage, interspersed with your friends' pins. I quite like the curated pins they choose, but sometimes I like to just see what my friends have been up to.

You have the option to go through and deselect all of your boards, which I assume would prevent you from getting "Picked for you" pins at all. However, I wanted something a little less permanent, so I've made a bookmarklet.

The easiest way to use it is to drag the following link onto your bookmarks toolbar:

Remove Picked For You

Then, if you go to pinterest.com and click on your new bookmark, the "Picked for you" and "Promoted by" pins will have disappeared.

To keep the pins hidden, you have to click on the bookmark every time you load the page. However, there's a browser add-on for Firefox (or Iceweasel) called Greasemonkey, which lets you run little bits of javascript all the time. First, install Greasemonkey. Then, copy the text below:

// ==UserScript==
// @name        Remove Picked For You
// @namespace   bethmcmillan.com
// @include     *
// @version     2
// @grant       none
// ==/UserScript==

function hide_picked_for_you() {
divs=document.getElementsByClassName("creditFooter");
  for(i=0;i<divs.length;i++)
  {if (divs[i].innerHTML.indexOf('Picked for') != -1)
  {divs[i].parentNode.parentNode.parentNode.style.visibility='hidden';}
  }
divs=document.getElementsByClassName('creditName');
  for(i=0;i<divs.length;i++)
  {if (divs[i].innerHTML.indexOf('Promoted') != -1)
  {divs[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.visibility='hidden';}
  }
}

window.setInterval(function(){
  hide_picked_for_you();
}, (5000));

Next, click on the Greasemonkey icon in your browser (usually in the top right), go to "New User Script", then "Use Script From Clipboard". Now, when you go to Pinterest and click on the Greasemonkey icon again, there should be the option "Remove Picked For You". If you tick it, you'll see that the pins disappear. For Google Chrome, there's an extension called Tampermonkey, which works in the same way.

If the script or bookmark aren't working for you, try reinstalling them from this page, as I might have updated the code. If this doesn't fix it, tell me in the comments. The latest code is always available on Github.

...

Playing with Linear Discriminant Analysis

The way that I select which risk category a drug should be in based on the training data I have is called Linear Discriminant Analysis (LDA). I've made a little example of how it works using MATLAB (however, this code also works perfectly on the wonderful, and free, Octave).

You can download my MATLAB/Octave script and try it out yourself (it takes one input, a number). Below, I'll go through it step by step.

function LDA(point)

%% group 1: mean 10, sd 2
%% group 2: mean 3, sd 1
%% group 3: mean 5, sd 0.5

group_1 = 10 + 2*randn(10,1);
group_2 = 3 + randn(10,1);
group_3 = 5 + 0.5*randn(10,1);

These first few lines create a set of training data, by making random numbers based on three normal distributions with different means and standard deviations. In real life, you wouldn't know how your data were generated or what distribution they came from.

%% plot all of the training data
hold off
plot(group_1, zeros(10,1),'o')
hold on
plot(group_2, zeros(10,1),'+')
plot(group_3, zeros(10,1),'.')

Now for visualisation we plot the training data, delineating the different groups by differently shaped markers.

%% find the likelihood of the point given the group
p_x1 = normpdf(point,mean(group_1),std(group_1));
p_x2 = normpdf(point,mean(group_2),std(group_2));
p_x3 = normpdf(point,mean(group_3),std(group_3));

The first thing we need to find is the probability that this point (the input number, in this case 9.5114) would exist given the group that it's a member of, i.e. . In LDA, you assume that the points within each group are normally distributed, so in MATLAB/Octave there's a useful function called normpdf that calculates the probability of a point given the mean and standard deviation of the distribution.

%% find the probability of the group given the point using Bayes' rule
p_i1 = (p_x1*(1/3))/((p_x1+p_x2+p_x3)*1/3);
p_i2 = (p_x2*(1/3))/((p_x1+p_x2+p_x3)*1/3);
p_i3 = (p_x3*(1/3))/((p_x1+p_x2+p_x3)*1/3);

Bayes' rule is that .

is actually the same for all groups, so we can ignore it. Because there are three groups of ten items, we know that is always . This means that we could have simplified these calculations by just comparing the likelihoods ().

%% which one has the maximum probability?
[a b] = max([p_i1,p_i2,p_i3]);

if b==1
    dotshape = 'o';
elseif b==2
    dotshape = '+';
else
    dotshape = '.';
end

%% plot to see if we're right
plot(point,0,strcat(dotshape,'r'))
hold off

end

We end by picking the group that has the highest probability, i.e. the highest , and then plot that on the graph.

If you have more than one set of data points (i.e. if you are classifying based on two features), you can assume that the covariances in different groups are all equal, which simplifies the calculations for that system.

...

Gedit add-ons for LaTeX

The default text editor that comes with the Gnome GNU/Linux desktop is called gedit, and I like using it for editing LaTeX and HTML. I have a few little tweaks I use for a smoother user experience.

Firstly, I can use it as an easy file browser, by going to View > Side Panel, and then clicking on the filing cabinet at the bottom of the panel.

Secondly, gedit has the option of adding little shell scripts that you can set to execute using a keyboard shortcut, by going to Tools > Manage External Tools. I have three useful scripts that I can run on a LaTeX document that I'm currently editing.

Ctrl+Q: TeXCount. Count the number of words in the document, ignoring markup.


#!/bin/sh
NUMWORDS=$(texcount $GEDIT_CURRENT_DOCUMENT_NAME)
exec `zenity --info --title="TeXCount output" --text="$NUMWORDS"`

Ctrl+Alt+W: BibTeX. Insert references into the document.


#!/bin/sh
FULLNAME=$GEDIT_CURRENT_DOCUMENT_NAME
SHORTNAME=${FULLNAME%.tex}
bibtex $SHORTNAME

Ctrl+Alt+Q: PDFLaTeX. Compile the document into a PDF.


#!/bin/sh
pdflatex $GEDIT_CURRENT_DOCUMENT_NAME

I've also had to play around with bibliography styles a bit lately. I've slightly modified the usual abbrv.bst and abbrvnat.bst bibliography style files (which are usually this and this), to stop them from displaying the month:

no-month.bst
no-monthnat.bst

To use, just download the file and put it in the same directory as your document, and then put either:

\bibliographystyle{no-month}

or

\bibliographystyle{no-monthnat}

in the markup.

I'm really glad I get to use LaTeX for everything. It can be a bit of a struggle to enact specific changes to the formatting, but in general it's easy to get a beautiful document while enjoying the portability and robustness of simple text files.

...