How SVG units work
From the specification:
“1pt” equals “1.25px” (and therefore 1.25 user units)
“1pc” equals “15px” (and therefore 15 user units)
“1mm” would be “3.543307px” (3.543307 user units)
“1cm” equals “35.43307px” (and therefore 35.43307 user units)
“1in” equals “90px” (and therefore 90 user units)
What to do with all the GTK+ library files in Win32
Lots of files are helpfully provided here: http://www.gtk.org/download/win32.php
Not bad Win32 support for a GPL, but as is typical, they don’t tell you what to do with them.
What you do is open the zip files, and merge them with the folders in your MinGW directory. The best way I found to do that is to move the zip file to my mingw directory (in my case, C:\Qt\4.7.1\mingw), and then use Windows’ “Extract all…” feature, which will offer to merge the directories automatically.
One more wrinkle: the “Dev” versions are necessary to build code using the libraries; the “Run-time” versions are necessary to actually execute the program. Both need to be installed as described above.
The actual HTML Tidy documentation
For whatever reason there are a ton of pages purporting to document HTML Tidy. This one seems to be the real one:
http://tidy.sourceforge.net/docs/tidy_man.html
Insert characters around characters in XeLaTeX (for RTL languages)
In typesetting RTL documents in XeLaTeX, I have found that characters such as colons or parentheses don’t set properly—adjacent numbers disappear, etc. The code below makes TeX place empty hbox’s around each colon in a document. No further references to macros are necessary.
\def\colon{:}
\catcode`:=\active
\def:{\hbox{}\colon\hbox{}}
xsltproc (XSL transformations)
xsltproc is the best (most efficient) way I’ve found to do XSL transformations. Some of the DLL dependencies have to be from libraries downloaded at the xsltproc web site (or rather, the web site of the associated libraries).
xsltproc ocm.xsl newOcm.xml > result.txt
xsltproc --param which-page 1 -o output.svg xml2svg.xsl nasim.xml
xsltproc --param which-page "hello world" -o output.svg xml2svg.xsl nasim.xml
C++ object/pointer construction/deconstruction
#include <iostream>
using namespace std;
class A
{
public:
char label;
A()
{
label = 'X';
}
A(char l)
{
label = l;
cout << "Constructing " << label << endl;
}
~A()
{
cout << "Deconstructing " << label << endl;
}
};
int main()
{
A a('a');
A *b;
A *c = new A('c');
A *d = new A('d');
delete d;
return 0;
}
Output:
Constructing a Constructing c Constructing d Deconstructing d Deconstructing a
Getting coefficients and p-values from an R lm class
dependent <- runif(100); independent <- runif(100); tmp<-lm(dependent ~ independent); summary(tmp); correlation <- tmp$coeff['independent']; intercept <- tmp$coeff['(Intercept)']; f <- summary(tmp)$fstatistic; p_value <- 1-pf(f['value'], f['numdf'], f['dendf'])
Principal component analysis in Octave
% create sample data matrix = [1 2 3; 4 5 6; 7 8 9; 10 11 12]; matrix = matrix.^2; matrix = center(matrix); % subtract column means cv = cov(matrix); % calculate covariance [v, lambda] = eig(cv); % compute eigenvectors and eigenvalues [sorteigen, order] = sort(diag(lambda),'descend'); % sort the eigenvalues v = v(:,order); % sort the eigenvectors the same way data = [1 2 3; 4 5 6; 7 8 9; 10 11 12]; % a new dataset means = mean(data); % calculate the column means data = center(data); % subtract the means transdata = v' * data'; % project into the new eigenspace reconstituted = (v*transdata + repmat(means,size(data,1),1)')'; % project it back the other way, and add the means back