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;
}