Wednesday, December 30, 2009

Windows XP 64 cannot Hibernate

Just to stop you wasting your time trying to find out how to do this: Windows XP-64 does not allow hibernation.

Well, actually the precise rule is Windows XP-64 does not allow hibernation with more than 4GB of memory.But I figure if you've not got more than 4GB memory, you are probably better of using 32-bit in most cases.

As far as I can tell, this is true for Vista, but since don't use (and won't use) any instance of that execrable mess, I can't say. Thankfully, I can say hibernation does work for Windows 7, as I'm writing this missing on a Windows 7 64-bit (with 12GB ram) that does hibernate quite nicely.

Here are some links that explain it all:

Friday, December 4, 2009

Visual Studio: suppressing the annoying synchronising between active document and project view.

When you've got a solution with several projects and/or you're working on a document from a project that has many files, the automatic synchronisation between the active document and the Project View can be quite confusing. (It is to me, anyway.)

Consider the following case. First, the Visual Studio window while editing one file:



If I then switch to the other document (via Ctrl-Tab), the project view jumps away and expands the recls.100.net project, as in:



This is just too annoying if, like me, you use the keyboard for everything (or almost everything; this is Visual Studio, after all), and don't appreciate your previous Project View position being arbitrarily shifted.

I found this issue vexing for quite some time, until I was finally sufficiently motivated to find the requisite option. As it turns out, it is embarassingly obvious and easy:



HTH

Matt

Sunday, June 7, 2009

Rails / RubyGems version mismatch (Mac OS-X)

Having finally decided to make shift to Rails 2, was experimenting on Mac OS-X. Got the following when trying to generate a controller


$ ruby script/generate controller Site
Rails requires RubyGems >= 1.3.1 (you have 1.2.0). Please `gem update --system` and try again.
matts-MacBook:qualitymatters matthew$ gem update --system
Updating RubyGems
Updating rubygems-update
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.


Various messings around later, and got success with:


$ sudo gem install rubygems-update
$ sudo update_rubygems

Saturday, June 6, 2009

Practical determination of fopen() concurrency


#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
int i;

for(i = 1; i != 10000; ++i)
{
char filename[101];
int n = sprintf(&filename[0], "file-%d", i);
FILE* stm = fopen(filename, "w");

if(NULL == stm)
{
fprintf(stderr, "failed to create %s: %s; FOPEN_MAX=%d\n", filename, strerror(errno), FOPEN_MAX);

return EXIT_FAILURE;
}
}

return EXIT_SUCCESS;
}

Thursday, May 14, 2009

Find-in-files filter

The filter I find most useful when doing find-in-files with Visual Studio:

*.build;*.c;*.cmd;*.cpp;*.cs;*.csproj;*.css;*.cxx;*.d;*.dsp;*.dsw;*.erb;*.h;*.hpp;*.html;*.idl;*.inf;*.inl;*.java;*.js;*.jsp;*.mc;*.mh;*.pl;*.py;*.rb;*.rc;*.rcv;*.rgs;*.rhtml;*.rhtml;*.sln;*.src;*.tlh;*.tli;*.tmpl;*.tmplgen;*.txt;*.vbs;*.vcproj;*.xml;makefile.*;

Wednesday, April 22, 2009

Starting WEBrick on a different port

For example, to start Rails on port 3001 (perhaps because you're running multiple Rails apps during development):

$ ruby script/server -p 3001

Tuesday, April 14, 2009

Showing pre-processor symbols for gcc

gcc -dM -E -xc /dev/null

and for G++:

g++ -dM -E -xc /dev/null

Monday, February 23, 2009

Basic MySQL tips #1

History

MySQLAdmin maintains a history, accessible with the up and down arrows. And it works between sessions.

Which is nice.

Show all the (user) tables

> show tables;

Describe a specific table (e.g. users table):

> describe users;

Installing Web Frameworks, part 6: installing MySQL

  1. install mysql: sudo apt-get install mysql-server-5.0
  2. set the root password
  3. change root password (I didn't like the one I set it to): mysqladmin -u root -p password , where is the new password (and not the actual word 'password')

Thursday, February 12, 2009

apt-get without cdrom prompt

When running certain versions of Ubuntu (7.10 in this case), you might encounter a request to insert the cdrom when doing apt-get.

To stop this happening, edit the /etc/apt/sources.list file, and comment out (using leading #) the line containing 'deb cdrom...'

Installing Web Frameworks, part 5: Ruby On Rails

  1. Install Ruby: sudo apt-get install ruby-full build-essential
  2. Install SVN: sudo apt-get install subversion
  3. Install gems: download rubygems-1.2.0.tgz from rubyforge.org, then tar -zxvf rubygems-1.2.0.tgz, then sudo ruby setup.rb
  4. Install gems: download rubygems-1.3.1.tgz from rubyforge.org, then tar -zxvf rubygems-1.3.1.tgz, then sudo ruby setup.rb, then sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
  5. update gems: sudo gem update --system
  6. install Rails: sudo gem install rails -v 1.2.3 --include-dependencies


Wednesday, February 11, 2009

Installing Web Frameworks, part 4: renaming hosts

  1. edit the hostname file: sudo vi /etc/hostname
  2. change to required name
  3. reboot

Tuesday, February 10, 2009

Installing Web Frameworks, part 3: fixed IP address for SCC server

Next task was to ensure a fixed IP was assigned to the SCC (SVN) server. There's a known feature in Ubuntu 8.10 whereby any attempt to assign a fixed IP address using the Network Manager is overridden during reboot. There are many proposed solutions: here, here, here and here.

Having spent ~3 hours today fighting my own unique battle, I can relay the following measures that I had to do:
  1. I had to uninstall Network Manager: sudo apt-get purge network-manager
  2. edit /etc/networking/interfaces, as shown below
  3. edit /etc/resolv.conf, as shown below
  4. restart networking and/or reboot: sudo /etc/init.d/networking restart
# /etc/networking/interfaces
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
address 192.168.0.11
netmask 255.255.255.0
gateway 192.168.0.1

# /etc/resolv.conf
nameserver 192.168.0.2
nameserver 192.168.0.1

HTH

Installing Web Frameworks, part 2: SVN

  1. install apache2: sudo apt-get install apache2
  2. install svn: sudo apt-get install subversion
  3. add a svnusers group: sudo groupadd svnusers
  4. enabled visibility for all users: Alt-F2 to bring up run, and then type in gconf-editor. Within this, open apps/gnome-system-tools/users, and check showall.
  5. add me, root and www-data to svnusers group: I cheated and did it via the GUI!
  6. create root repositories directory: sudo mkdir /srv/repositories
  7. assign repositories to www-data & svnusers: sudo chown -R www-data:svnusers /srv/repositories
  8. change mod: sudo chmod -R g+rws /srv/repositories
  9. create rails repo, in /srv/repositores: svnadmin create rails
  10. repeat steps 7 & 8, to ensure that apache owns and controls all the files in the repo
  11. install libapache2-svn: sudo apt-get install libapache2-svn
  12. restart Apache2: sudo /etc/init.d/apache2 restart
  13. edit /etc/apache2/mods-available/dav_svn.conf. Add in the contents specified here. The list is below.
  14. create the password file /etc/subversion/passwd: sudo htpasswd -c /etc/subversion/passwd matthew. Don't forget this, or you'll end up with weird permissions errors in local and remote clients, including things along the lines of "Server sent unexpected return value (500 Internal Server Error) in response to MKACTIVITY request"

<Location /svn>
DAV svn
SVNParentPath /srv/repositories
SVNListParentPath On
AuthType Basic
AuthName "Synesis Web Subversion Repository"
AuthUserFile /etc/subversion/passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>

Minimal C++ program to verify GCC installation

#include <iomanip>
#include <iostream>
#include <stdlib.h>

int main(int argc, char** argv)
{
  std::cout << "__GNUC__: 0x" << std::hex << __GNUC__ << std::endl;

  return EXIT_SUCCESS;
}

Minimal C program to verify GCC installation

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
  printf("__GNUC__: 0x%08x\n", __GNUC__);

  return EXIT_SUCCESS;
}

Monday, February 9, 2009

Installing Web Frameworks, part 1: Ubuntu

  1. Download Ubuntu 8.10 in 32 and 64-bit guises
  2. Install two 32-bit systems: 1-processor and 2-processor
  3. Action all the latest updates
  4. Install/update the basic build tools, as described in the next few steps:
  5. gcc: sudo apt-get install build-essential
  6. verify gcc, by defining two programs, one C and a C++, and compiling them.

Wednesday, January 21, 2009

Using your own blog domain with BlogSpot

Having just started this blog, I want to give it its own domain. I've registered skegging-it-out.net (and skeggingitout.net, just for completeness; I prefer the separated form), and now need to connect them up. In this post, I'll explain what I did, in the hope that it may be of some help to someone else.

I have actually done this process before, with my other BlogSpotted blog, STLSoft Musings, but, being a programmer and programming consultant, I have forgotten how. So, I'll do it again, and, in the spirit of Skegging It Out, will record it for posterity. Here goes:

  1. Register your domain name, in this case skegging-it-out.net
  2. Read the BlogSpot help on this subject
  3. Add a CNAME record to the DNS settings for the domain. I like the blog to appear in the sub-domain blog, so this will be blog.skegging-it-out.net. So, specify blog.skegging-it-out.net (done via entering blog in the requisite field with my registrar), and enter ghs.google.com for the canonical name.
  4. [OPTIONAL] If, like skegging-it-out.net, your domain is used solely for the blog, you will probably want www.skegging-it-out.net to come to BlogSpot. To do this, add another CNAME record named www again specifying ghs.google.com for the canonical name.
  5. You'll want add URL forwarding from your registrar (to whom arbitrary accesses to your domain will go) to blog.skegging-it-out.net, using standard URL forwarding. (Don't use stealth forwarding, if that's available.)
  6. Finally, you need to let BlogSpot know to start servicing requests for blog.skegging-it-out.net. From you blog's main page, click Customize, then Settings, then Publishing, then Custom Domain, then Switch to Advanced Settings, and enter your domain, in my case blog.skegging-it-out.net. Then save your settings, and cross your legs - because it takes time for the DNS settings and whatnot to propagate, you will likely find, as I have both times, that your blog will be unavailable for several hours. During this time, you will doubtless worry that you've not executed the previous steps correctly, and may even flip your blog settings back to skegging-it-out.blogspot.com a few times in your panic. If, after a day, you've not got a nicely hosted custom domain for your blog, you've made a mistake, and you're up the creek, and it's time to call a sysadmin.
I may have written that with the seeming authority of someone who understands it intimately. That's not an entirely accurate picture of reality. Nonetheless, it works for me. If you have any insights to add, please let me know. If it doesn't work for you, by all means let me know about that, after you've worked out how to make it work, and I will add that information.

HTH

Matt

Welcome to "Skegging It Out"

AFAIK, I introduced the phrase "Skegging It Out" to the world in the preface of my first book, Imperfect C++. I learnt it from my first commercial mentor, the redoubtable Andy Thurling, who gave me my first great insight, which is that no one in software engineering knows everything. Having now done 15+ years in the industry, and written 3 (well, 2.6, to be precise) books, I can certainly attest to this truth. I know that I don't know everything - don't ask me any questions on floating-point types! - and I know that a lot of other people don't know everything. (Some of the horrors I've seen in my consulting lead me to ponder whether 80+% of the programmers of the world would be far better suited to some other pursuit.)

Anywhat, this blog will be a place to record miscellaneous, non-portentous, things learned. Examples would be:
If you're after information on what's going on with my open-source libraries, check out my STLSoft Musings blog.

If you're after philosophical insights into the programming world, check out my occasional Artima blog.

If you want to learn about all the tricks and pitfalls of extending the C++ Standard Template Library (STL), including many of the issues its original designers (and most current practitioners and authors) didn't consider, then you should purchase and wade your way through my latest book, Extended STL, volume 1: Collections and Iterators.

If you want to learn the dark, complex secrets how to write the world's most robust, most flexible and fastest formatting and logging C++ libraries, you'll have to wait until I'm up to 3.0 books, and the latest, Breaking Up The Monolith: Advanced C++ Design without Compromise, has been published, hopefully later this year.

If you want to write mean things about the arrogant, autarchic, red-headed step-child of the C++ world, you could adulterate the Wiki page that's been started about me.

If, however, you want to just borrow some hard-won lessons from someone who knows just enough to get by in the majority of technology areas in which he's not expert, then this blog is for you. I make no promises about subject matter, focus, frequency, gravity, or quality. All I will endeavour to do is share the knowledge any time I learn something useful.

Can't say fairer 'n that, can ah?

Matt

P.S. If anyone knows where Andy Thurling is, or if, Bob-permitting, Andy reads this, please let me know!