This post outlines how to create encrypted incremental backups for WordPress using duplicity and duply. The general method, as you will see is pretty generic, and I’ve been using it successfully to backup also Django sites and MediaWiki installations. You can use this method to make secure backups to almost any kind of service imagineable: ftp, sftp, Amazon S3, rsync, Rackspace Open Cloud, Ubuntu One, Google Drive and whatever else you can think about (as long as the duplicity folks implemented :-)). If you prefer a simpler solution, and don’t care about incremental or encrypted backups, see my Improved FTP Backup for WordPress or my WordPress Backup to Amazon S3 Script.
Continue reading Incremental WordPress Backups using Duply (Duplicity)
Manually Install SSL Certificate in Android Jelly Bean
Apparently it’s pretty easy, but there are some pitfalls. The first step is to export the certificate as a DER encoded X.509 certificate. This can be done using Firefox (on a PC) by clicking on the SSL’s lock sign in the address bar, More Information -> View Certificate -> Details -> Export. The exported certificate needs to be saved on the root directory of the internal storage of the phone, with *.cer extension (or *.crt). Other extensions will not work.
Afterwards, on the phone, click on “Install from device storage” under Settings->Security->Credential Storage. If you did everything as you should at the previous step, it will display the certificate name, and ask you to confirm its installation. If you’ve exported the certificate as the wrong format, gave it the wrong extension or placed it somewhere else than the root of the internal storage, it will display the following error:
No certificate file found in USB storage
If you see it, just make sure you are exporting the certificate correctly and saving it at the right place.
More details: Work with certificates (Geared towards Galaxy Nexus, but should apply to any Android 4.0 and above.
Updated Aug 2015: Fixed a broken link.
GitHub Stops Offering Binary Downloads
Only few month ago, almost anyone would swear by GitHub and curse SourceForge. GitHub was (and probably still) the fastest growing and by now the largest code repository, while SourceForge was the overthrown king. SourceForge looks like an archaic service despite some major facelifts while GitHub is the cool kid on the block. Recently, GitHub showed us why SourceForge is still relevant for the open-source community.
Back in December, GitHub dropped their support for downloading files from outside the code repository. They say that they believe that code should be distributed directly from the git repository. This is probably fine for projects written in dynamic languages (such as python, ruby, javascript) where no binary distribution is expected. However, this seems to me like a blow to any GitHub hosted C/C++ project. No one expects lay users to compile projects directly from source, it a hassle for most people except developers (and possibly Gentoo users :-)).
It might be a good idea on GitHub team, as they promote themselves as a developer collaboration tool, and also most of their projects a indeed in dynamic languages (see the top languages statistics). The GitHub teams offers in their post two solutions: Uploading files to Amazon S3 and switching to SourceForge, and I’ve read at least a few people recommending putting binary releases in the git repository (bad idea).
Overall, I think this move by GitHub, just turned SourceForge into the best code repository (for compiled code) once again.
Vim: Creating .clang_complete using CMake
The clang_complete plugin for Vim, offers superior code completion. If your project is anything but trivial, it will only do so if you provide .clang_compelete file with the right compilation argument. The easy way to do so is by using the cc_args.py script that comes with it to record the options directly into the .clang_compelete file. Usually one does
make CXX='~/.vim/bin/cc_args.py clang++'
However, the makefile generated by CMake doesn’t support the CXX configuration.
The solution is to call CMake with the CXX environment variable set:
CXX="$HOME/.vim/bin/cc_args.py clang++" cmake ..
make
Note that this will create the clang_complete file in the build directory (I’ve assumed out-of-place build), so just copy over the file to the working dir of your vim so it can find it. You’ll need to re-run cmake again (without the CXX, to disable re-creating the .clang_complete file each time.
While looking for this solution, I’ve first tried solving it by setting the CMAKE_CXX_COMPILER variable in CMake, however for some strange reason it didn’t like it, saying that the compiler wasn’t found (it shuns command line arguments given in the compiler command).
The more I use clang_compelete the more awesome I find it. It has it quirks but nonetheless it’s much simpler and better than manually creating tag files for each library.
Updated 6/1/2014: When setting CXX use $HOME instead of ~ (fix issues with newer versions of CMake).
Using std::chrono::high_resolution_clock Example
5 years a go I’ve showed how to use clock_gettime to do basic high_resolution profiling. The approach there is very useful, but unfortunately, not cross-platform. It works only on POSIX compliant systems (especially not windows).
Luckily, the not-so-new C++11 provides, among other things, interface to high-precision clocks in a portable way. It’s still not a perfect solution, as it only provides wall-time (clock_gettime can give per process and per thread actual CPU time as well). However, it’s still nice.
#include <iostream>
#include <chrono>
using namespace std;
int main()
{
cout << chrono::high_resolution_clock::period::den << endl;
auto start_time = chrono::high_resolution_clock::now();
int temp;
for (int i = 0; i< 242000000; i++)
temp+=temp;
auto end_time = chrono::high_resolution_clock::now();
cout << chrono::duration_cast<chrono::seconds>(end_time - start_time).count() << ":";
cout << chrono::duration_cast<chrono::microseconds>(end_time - start_time).count() << ":";
return 0;
}
I’ll explain a bit the code. chrono is the new header files that provides various time and clock related functionality of the new standard library. high_resolution_clock should be, according to the standard, the clock with the highest precision.
cout << chrono::high_resolution_clock::period::den << endl;
Note, that there isn’t a guarantee how many the ticks per seconds it has, only that it’s the highest available. Hence, the first thing we do is to get the precision, by printing how many many times a second the clock ticks. My system provides 1000000 ticks per second, which is a microsecond precision.
Getting the current time using now() is self-explanatory. The possibly tricky part is
cout << chrono::duration_cast<chrono::seconds>(end_time - start_time).count() << ":";
(end_time - start_time) is a duration (newly defined type) and the count() method returns the number of ticks it represents. As we said, the number of ticks per second may change from system to system, so in order to get the number of seconds we use duration_cast. The same goes in the next line for microseconds.
The standard also provides other useful time units such as nanoseconds, milliseconds, minutes and even hours.
Installing Citrix Receiver on Ubuntu 64bit
It’s a hassle.
The first step is to grab the 64bit deb package from Citrix website. Next install it using dpkg:
~$ sudo dpkg --install Downloads/icaclient_12.1.0_amd64.deb
This results in the following error:
dpkg: error processing icaclient (--install): subprocess installed post-installation script returned error exit status 2 Errors were encountered while processing: icaclient
Which can be fixed by changing line 2648 in /var/lib/dpkg/info/icaclient.postinst:
echo $Arch|grep "i[0-9]86" >/dev/null
to:
echo $Arch|grep -E "i[0-9]86|x86_64" >/dev/null
And then execute
~$ sudo dpkg --configure icaclient
Credit for this part goes to Alan Burton-Woods.
Next, when trying to actually use the Citrix Receiver to launch any apps, I’ve encountered the following error:
Contact your help desk with the following information: You have not chosen to trust "AddTrust External CA Root", the issuer of the server's security certificate (SSL error 61)
In my case the missing root certificate was Comodo’s AddTrust External CA Root, depending on the certificate used by the server you’re trying to connect to, you may miss some other root certificate. Now you can either download the certificate from Comodo, or use the one in /usr/share/ca-certificates/mozilla/AddTrust_External_Root.crt (they are the same). Either way, you should copy the certificate to the icaclient certificate directory:
$ sudo mv /usr/share/ca-certificates/mozilla/AddTrust_External_Root.crt /opt/Citrix/ICAClient/keystore/cacerts/
These steps got Citrix working for me, but your mileage may vary.
nameref Doesn’t Work Properly with Theorem Environment
I came across not-so-expected behavior in nameref, the package responsible for creating named references, when used in conjunction with theorem environments such as the one provided by amsthm. For example take a look at the following LaTeX document.
\documentclass{article}
\usepackage{amsmath,hyperref}
\begin{document}
\section{My Section}
\newtheorem{theorem}{Theorem}
\begin{theorem}[My Theorem]
\label{theo:My}0=0
\end{theorem}
This is a named reference: \nameref{theo:My}
\end{document}
You would expect the named reference to refer to the theorem’s name. However in reality it refers to the section’s name.

Continue reading nameref Doesn’t Work Properly with Theorem Environment
The New SourceForge
I’ve recently started upgrading my projects to SourceForge’s new “forge” software Allura. Upgrading existing projects have been available for quite some time (IIRC since July), but I thought I didn’t have time to deal with it until now. From my short experience with the “new” SourceForge resulted in two short insights.
Continue reading The New SourceForge
Separate Numbering for Problems in LaTeX
By default when using the amsthm to create environments such as theorems, claims and problems, they all use the same numbering. Sometimes it’s annoying, as the numbering for the problems should generally be unaffected by the theorems present (or lack of them). For example the default behavior produces:
Problem 1
Problem 2
Theorem 3
Problem 4
where the desired behavior would be (in my opinion):
Problem 1
Problem 2
Theorem 1
Problem 3
Fortunately, this can be done by redefining the problem environment.
\let\problem\@undefined % undefines the existing problem environment
\theoremstyle{definition} % set the style of the new environment to 'definition'
\newtheorem{problem}{\protect\problemname} % (re)define the 'problem' environment
The \theoremstyle can be one of three defaults plain, definition and remark or some custom style defined using \newtheoremstyle.
See amsthm‘s documentation for more information, such as subordinately numbering (numbering per section).
Annoying Outlook Error
Sadly, there are occasions where I can’t use my beloved Gmail account and have to use Outlook to connected to a corporate Exchange servers. Due to Exchange inability to efficiently operate with large mailboxes (at least that what the tech support there tells me), I have to resort to so move messages to a local PST. However, some time a go I’ve started encountering the following error whenever I’ve tried moving messages into a PST file:
Cannot move the items. The item cannot be move. It was either already moved or deleted, or access was denied.
I’ve tried changing permissions, moving my PST around, repairing it with some tools that comes bundled with Office (I read somewhere that such error can be caused by corrupted PST files), and even tried creating a new PST. But, alas, the not so helpful message just wouldn’t get a way.
Continue reading Annoying Outlook Error
