Friday 22 January 2016

Steps to save battery and increase performance on iOS iPhone and iPad

With each iteration of iOS, iPads and iPhones get slower and slower because of new features that add questionable value and utility.

All the extra work being done by new features, require extra CPU cycles, which in turn require more energy, which results in poor performance and shorter battery life.

Follow this guide to help you choose which features to turn off thus making your battery last longer and iPad/ iPhone more responsive.

All the below paths are in the Settings app.

General > Siri > Hey Siri

Hey Siri has to constantly monitor background sound, just in case you speak those two words, this is an active drain on battery. It sort of works, and thus can be quite nice or quite annoying, but if you don't use it or have stopped because it's not accurate enough, turn it off.

General > Siri > Siri

Siri probably has some background threads running periodically or all the time, if you don't use it or can live without, this option allows you to turn it off completely.

Spotlight Search > Siri Suggestions

Siri Suggestions slow searching in general, use network bandwidth and data and are generally not that useful. You can turn off and probably won't notice any changes.

Spotlight Search > Search Results

Search results will index data from the selected apps, it may also index data from these apps when they are not running! Which creates a noticeable reduction in responsiveness.

Turning all (or a select majority) of app search results off, will mean your phone or tablet will not query data for these apps and will not update the database in the background when you want it to focus on the task at hand.

Note: In general, spotlight seems to be the single biggest contributor to keyboard lag and poor performance in general.

Handoff & Suggested Apps > Handoff

Handoff uses extra bandwidth and CPU cycles, if you don't use it, it's a no brainer to turn off.

Handoff & Suggested Apps > Installed Apps

Some people might like the idea of this, or appreciate how cute the meh suggestions it makes are.

Once you realise it's using bandwidth, CPU and slowing down typing on your phone, the utility of this may become less obvious.

Accessibility > Reduce Motion

This makes navigating iOS faster and more responsive, it reduces animation time and thus CPU cycles.

Background App Refresh

This starts up apps periodically so they are pre-loaded, useful for things like newsreaders that can have the latest news articles ready when you open the app.

I've never noticed any benefit, I expect that most apps do not benefit much from this, I've had it disabled for years without any ill affects.

Software Update

Apple support suggested to me that I should run any updates, merely having an update waiting, causes the iOS device to use extra battery power "checking the update". Didn't make any sense to me, but I updated and it did seem to make a difference.

Safari > Search Engine Suggestions

If the search engine is Google, I find these suggestions to be quite good. You can turn off to save bandwidth and CPU.

Safari > Safari Suggestions

These are suggestions for you to consume more Apple related stuff, easier to turn this one off than Search Engine Suggestions, because these suggestions are less likely to be of great benefit to your search.

Safari > Preload Top Hit

Extra work and bandwidth required to do this, so turn off to save on both.



Wednesday 6 January 2016

netsh http add sslcert fails with error 87

An obscure parameter error may happen when using netsh http add sslcert hostnameport

Command Line Example
netsh http add sslcert hostnameport=localhost:443 certhash=8e58dd9aa3473965b2dc8f08fc0dcbda15e69428 appid={00112233-4455-6677-8899-AABBCCDDEEFF}

SSL Certificate add failed, Error: 87
The parameter is incorrect.

Solution
Specify certstorename, e.g.

netsh http add sslcert hostnameport=localhost:443 certhash=8e58dd9aa3473965b2dc8f08fc0dcbda15e69428 appid={00112233-4455-6677-8899-AABBCCDDEEFF} certstorename=my

SSL Certificate successfully added

Monday 24 November 2014

NUnit Web.config

When using NUnit to test a web project, by default NUnit won't read the Web.config, it is only looking for a config file named TestProjectNamespace.dll.config.

We can quickly configure Visual Studio so the web.config file is copied (and renamed) from your web project to the NUnit build folder.

Add the web.config File as a Link
  1. Right click on NUnit project in Visual Studio
    Add > Existing Item
  2. Navigate to the web.config file in the web project
  3. Select the web.config file
    click on the arrow beside the Add button > Add As Link

Edit the NUnit Project File
Use a text editor to edit the NUnit project file, you will be able to find the lines where you have added the web.config file.

Change from:
    <None Include="..\Other.Project\Web.config">
      <Link>Web.config</Link>
    </None>

To:
    <None Include="..\Other.Project\Web.config">
      <Link>Namespace.dll.config</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>

This will copy the linked file and rename it so NUnit will find it.

Sunday 2 November 2014

Visual Studio Won't Start

Visual Studio 2013 started hanging on startup, a CPU core would be maxed out but there would be no events in Process Monitor.

I'm sure the same debugging rules apply to 2010 & 2012...

  1. It will probably run in safe mode: devenv.exe /safemode
  2. Might be worth a bet resetting settings: devenv.exe /resetsettings
  3. Or viewing a log for warnings: devenv.exe /resetsettings
    Check out the log file in:
    C:\Users\_USERNAME_\AppData\Roaming\Microsoft\VisualStudio\_VERSION_
  4. As a last resort (takes ages) try repair by Control Panel > Add/ Remove Programs

Saturday 21 January 2012

Setting up Jenkins to work with Mercurial on Windows

After spending one day trying to get a build working on a machine other than my development laptop, I decided it was time to setup the project on a continuous integration server.

As I had some trouble getting Jenkins to work with Mercurial, I thought I'd document the steps here for reference.

Environment (pre Jenkins)

  • Windows Server 2008
  • Mercurial Source Control (hosted on BitBucket)


Quickstart
  1. Install Jenkins (1.448)
  2. Install TortoiseHg (2.2.2)

Setup Plugins in Jenkins
> Manage Jenkins > Manage Plugins > Available

Tick the boxes for these plugins:
  • Mercurial Plugin
  • MSBuild Plugin
> Download now and install after restart
> Restart Jenkins when installation is complete and no jobs are running

Mercurial will appear under Source Code Management when you configure a job.
MSBuild will be available under the Build header when you configure a job.

Getting Mercurial working with Jenkins
HTTP
I got this working by changing the account Jenkins runs under (> Start > Run > services.msc > Jenkins > Log On >  This account:), from the local system account, to my account (Note: my account is an admin account, so I'll have to create a Jenkins only account, with less permissions. It's not secure to have a service run under admin!).

Mercurial could then access my username and password, as setup in C:\Users\username\mercurial.ini

SSH
I could not get the Mercurial plugin to work with SSH adequately, but I tried, you can read on, but it may not prove useful nor interesting.

For the Repository URL field, I put in my BitBucket SSH url - ssh://hg@bitbucket.org/username/repository


When I tried to build the project, Jenkins would just hang indefinitely on:


hg clone --rev default --noupdate ssh://hg@bitbucket.org/username/repository "C:\Program Files\Jenkins\jobs\Test\workspace"

So I ran the command myself on the command prompt.

Up pops PuTTY Security Alert, asking if you trust the host, and want to cache the rsa key fingerprint - it appears that Jenkins cannot get past this screen.

As Jenkins is running under the local system account, I decided to see if changing it to run under my account (> Start > Run > services.msc > Jenkins > Log On >  This account:) would make a difference. It did, I assume this is because PuTTY has cached the security key under my account settings.

But I then ran into this error:

remote: No supported authentication methods left to try!
abort: no suitable response from remote hg!

So I used Pageant to add the BitBucket private (ppk) key file (created by myself).

But then I ran into this error, again:

remote: No supported authentication methods left to try!
abort: no suitable response from remote hg!

So I tried the command prompt myself, it worked. Then I tried Jenkins, and it worked. However, Jenkins' Mercurial plugin only works with SSH IF I setup Pageant and run a hg command manually first. Pretty shite IMO.

Wednesday 18 January 2012

Visual Studio Counterintuivity, Edit and Continue

Changes are not allowed while code is running or if the option 'Break all processes when one process breaks' is disabled. The option can be enabled in Tools, Options, Debugging.



I had to disable Edit and Continue in order to use it.