Skip to content

2013

How to upgrade GCC to 4.7+ on Ubuntu 12.04

Note: This is only needed on Ubuntu 12.04. Ubuntu 12.10 already comes with GNU C++ 4.7 and above.

Install

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7 g++-4.7

Update Alternatives

Add GCC 4.7
sudo update-alternatives --remove gcc /usr/bin/gcc-4.6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
Make sure GCC 4.7 is the default alternative
sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc)

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-4.7 60 auto mode
1 /usr/bin/gcc-4.6 40 manual mode
2 /usr/bin/gcc-4.7 60 manual mode

Press enter to keep the current choice[*], or type selection number: 0

Verify

gcc --version
gcc (Ubuntu/Linaro 4.7.3-2ubuntu1~12.04) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Configuring PHP / CURL root certificates on Windows Server

This post is about configuring PHP/CURL root certificates for a WordPress installation running on Windows Server 2008 R2 / IIS 7.5.

Yesterday I was trying to add an RSS feed to the AVBlocks Wiki Site and I got this error:

``` text WP HTTP Error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

In my case the [feed](https://groups.google.com/forum/feed/avblocks-support/msgs/rss.xml?num=3) was coming from the [AVBlocks Group](https://groups.google.com/forum/#!forum/avblocks) on Google. However, the Google Groups feeds are served via secure https:// protocol and that requires SSL for server-to-server communication. The problem is that WordPress uses *php\_curl*, and on a standard PHP installation of WordPress, *curl* does not come with the root certificate authorities installed.

Here is how to fix it:

1. You need to be running PHP 5.3.7 or later.
2. Download [mk-ca-bundle.vbs](https://raw.github.com/bagder/curl/master/lib/mk-ca-bundle.vbs) from the [Curl](https://github.com/bagder/curl/tree/master/lib) repository on GitHub.
3. Open a Command Prompt as Administrator and go to the directory in which you downloaded `mk-ca-bundle.vbs`.
4. Run `mk-ca-bundle.vbs`. Accept the default filename and do not include the text information for each certificate.
5. After running this you will end up with a file `ca-bundle.crt`.
6. Copy that to a known location, e.g. `{path}/ca-bundle.crt`.
7. Add `curl.cainfo={path}/ca-bundle.crt` to php.ini. See [PHP Runtime Configuration](http://php.net/manual/en/curl.configuration.php) for more details: 

``` ini
[PHP]

;;;;;;;;;;;;;;;;;;;
; CURL Settings ;
;;;;;;;;;;;;;;;;;;;

curl.cainfo={path}/ca-bundle.crt
8. Restart the IIS web site

Setup Google Analytics for a Bitbucket repository

The idea is to create a new Google Analytics property for Bitbucket and then have a separate Google Analytics profiles for each repository. That way I end up with one profile per repository neatly grouped under the Bitbucket property. In the profiles, I also use filters to include only the traffic for the corresponding repository.

This post is about myself setting up Google Analytics for our AVBlocks-Samples repository, so in the steps below I use the “AVBlocks-Samples” name and the corresponding URL. Needless to say, when going through the steps, you will use the name and URL of your own Bitbucket repo. OK, here it goes:

Create a new Google Analytics property called Bitbucket

  1. Go to Google Analytics and login into your account.
  2. Click on the Admin link at the top right corner.
  3. Click on the property drop-down list and then select the New Property at the bottom.
  4. Select “Classic Analytics” for tracking method.
  5. Under Website Name, type “Bitbucket”.
  6. Under Web Site URL, select “https://” and type “bitbucket.org”.
  7. Click [Get Tracking ID]

2013-08-19-19_30_38-google-analytics 2013-08-19-19_52_18-google-analytics

Add the Tracking ID to the Bitbucket repository

Google Analytics will generate a new tracking ID for you, something that looks like “UA-123456-78″.

  1. Copy the Tracking ID that Google generated
  2. Go to the repository admin page on Bitbucket
  3. Paste the Tracking ID into the “Google Analytics key” field.

2013-08-19-19_55_54-avblocks-samples-bitbucket

## Update the Google Analytics profile

  1. Go back to Google Analytics admin page
  2. Select “Bitbucket” for property
  3. Select “All Web Site Data” for profile
  4. Click “View Settings”
  5. Update the Website’s URL with the full URL of your bitbucket repository.
  6. In my case I put “https://” and “bitbucket.org/primosoftware/avblocks-samples”.
  7. If you plan to have multiple repo profiles under the Bitbucket property, I recommend changing the View name to something other than “All Web Site Data”. I my case, I named my property “AVBlocks-Samples”.
  8. Click Apply.

2013-08-19-20_06_28-google-analytics 2013-08-19-20_12_10-google-analytics 2013-08-22-06_27_20-google-analytics

Setup a profile filter

  1. Go back to Google Analytics admin page
  2. Select “Bitbucket” for property
  3. Select “AVBlocks-Samples” for profile
  4. Click “View Settings”
  5. Click “Filters” and then on the +New Filter button.
  6. Type “AVBlocks-Samples” for Filter Name
  7. Select “Predefined filter” for Filter Type
  8. Select “include only”, “traffic to subdirectories”, “that begin with”
  9. Type “/primosoftware/avblocks-samples/” for Subdirectory
  10. Select “No” for Case Sensitive
  11. Click Save

2013-08-22-07_00_25-google-analytics 2013-08-22-07_15_04-google-analytics 2013-08-22-07_15_47-google-analytics

Super Agile: Accept that your product will never be 100% complete

We now follow thesesimple rules for all our projects:

  • Have a clear product vision / master plan / strategy. This is essential.
  • A grand product vision can be realized only in small incremental steps.
  • Version 1.0 should have the bare minimum of features, not more, not less.
  • Each incremental release must add value for your customers.
  • A high-quality and feature complete product is a natural result of all of the above.

ASP.NET MVC 4: Could not load file or assembly DotNetOpenAuth.Core, Version=4.0.0.0

I got this error in an ASP.NET MVC 4 application after installing DotnetOpenAuth via the Package Manager Console:

Could not load file or assembly 'DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The application was actually upgraded earlier from ASP.NET MVC 3, i.e. it was not autogenerated by Visual Studio 2012. The pre-binding info in the exception was:

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246
    (Fully-specified)
LOG: Appbase = file:///
LOG: Initial PrivatePath = \bin
Calling assembly : Microsoft.Web.WebPages.OAuth, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: \web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: DotNetOpenAuth.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2780ccd10d57b246
LOG: Attempting download of new URL file:////DotNetOpenAuth.Core.DLL.
LOG: Attempting download of new URL file:////DotNetOpenAuth.Core/DotNetOpenAuth.Core.DLL.
LOG: Attempting download of new URL file:////DotNetOpenAuth.Core.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

The key pieces of information here are at lines 3 and 7. Basically, Microsoft.Web.WebPages.OAuth needs DotNetOpenAuth.Core 4.0.0.0, but the DotNetOpenAuth.Core I have is version4.3.0.0.

The solution is to add these lines under the / section of the root Web.config:

<dependentAssembly>
    <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
    <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>

The above solution works for other packages that ASP.NET MVC 4 depends on. For example, if you upgrade WebGrease from 1.0.0.0 to 1.3.0.0, you have to add this to the / section:

<dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>