Sunday, April 10, 2011

Goodbye @googlechrome

  1. After all these years your "awesome bar" still doesn't match substrings in URLs and page titles.
  2. You download and install updates without even asking. Who do you think paid for this machine?
  3. @Opera has a real "awesome bar".

Monday, March 07, 2011

Windows 7 Annoyance

Just one example...



What's with "Check later", Einstein? What about "Check now"?

Monday, November 29, 2010

Video Lectures Online - Part 1

Stanford University on YouTube: http://www.youtube.com/user/StanfordUniversity

Massachusetts Institute of Technology on YouTube: http://www.youtube.com/MIT

Indian Institute of Technology on YouTube: http://www.youtube.com/iit#g/p

Wednesday, July 28, 2010

Reversing the Order of Lines in a File


//
// reversor.js
//
// Reverses order of lines in a file
//
// Execute on Windows as:
// cscript reversor.js input.txt > output.txt
// ------------------------------------------------

var args = WScript.Arguments;
if(args.length != 1)
WScript.Quit();

// don't use square brackets below...
// args is not an array/dictionary
var in_file = args(0);

var f;
var lines = new Array();
var fso = new ActiveXObject("Scripting.FileSystemObject");

var i = 0;
var fin = fso.OpenTextFile(in_file);

while(!fin.AtEndOfStream)
lines[i++] = fin.ReadLine();
for(i = lines.length - 1; i >= 0; --i)
WScript.StdOut.WriteLine(lines[i]);

fin.Close();

Thursday, April 15, 2010

Installing Trac (mod_wsgi, Apache 2.2, Python 2.6, PostgreSQL 8.4) on Windows XP

Installation


Too many pieces to put together here. The following components of the installation are available as Windows installers; just download and install them in the order listed before continuing with the rest:

Apache 2.2
Python 2.6
PostgreSQL 8.4
subversion 1.6.6
svn-python a.k.a Python subversion bindings
psycopg

Creating the PostgreSQL database

Launch pgAdmin III (Start > All Programs > PostgreSQL 8.4 > pgAdmin III). In the pane to the left of the window, right-click your PostgreSQL database (usually labelled "PostgreSQL 8.4 (localhost:5432)") and select "Connect". Supply the password. The tree expands to list all objects in this database.

Right click on the "Login Roles" node and select "New Login Role...".

Fill out the fields to create a new role.

Right click on the "Databases" node and select "New Database...".

Fill out the fields to create a database for Trac to use. Set the owner to the same user created in the previous step as a security measure.

Installing Trac

Trac 0.11.47

Installing mod_wsgi

Download mod_wsgi-win32-ap22py26-3.0.so to a temporary directory. Rename the file to mod_wsgi.so and copy it to the modules subdirectory of your Apache installation (usually C:\Program Files\Apache Software Foundation\Apache2.2\modules).

Locate httpd.conf under the conf subdirectory of the Apache installation (usually C:\Program Files\Apache Software Foundation\Apache2.2\conf) and open it in a text editor. Find the lines starting with LoadModule and insert the following line there:
    LoadModule wsgi_module modules/mod_wsgi.so

Creating a Trac Site

Creating a Trac instance/site:

Run the following command from the command prompt:
    trac-admin path-to-desired-location initenv

Note that you may have to specify the full path to trac-admin as shown here:
    c:\python26\scripts\trac-admin path-to-desired-location initenv

You will be prompted for the following:
  • Project Name
  • Database connection string
  • Repository type
  • Path to repository
For the database connection string, use the following format:
    postgres://user:pass@localhost:5432/dbname?schema=schemaname
If you are following the strings from the screenshots, the corresponding connection string would be:
    postgres://testtrac:password@localhost:5432/testtrac?schema=testtrac
This will create your Trac site. You can do a trial run by saying:
    tracd --port 8000 trac-site-location
...and then visiting http://localhost:8000/ using your web-browser.

Configuring mod_wsgi for the site

Run the following command at the command prompt. Replace "temporary-directory" with the name of a temporary folder where the required scripts for your Trac site will be generated.
    trac-admin trac-site-location deploy temporary-directory
This command will create two folders within "temporary-directory" -- cgi-bin and htdocs. You will find the properly configured WSGI script for your site in temporary-directory\cgi-bin\trac.wsgi. Open the trac.wsgi in a text editor, prefix all path strings using the back-slash ('\') with the letter 'r'. For example, if you find this:
    environ.setdefault('trac.env_path', 'C:\MyProject\Trac\ExampleSite')
...prefix the path string with the letter 'r' like this:
    environ.setdefault('trac.env_path', r'C:\MyProject\Trac\ExampleSite')
I am assuming this to be a bug with how Trac works on Windows paths. Read about Python's raw strings to find out more about this. Create a folder called apache within your Trac site and copy the generated trac.wsgi there. Open httpd.conf, scroll to the bottom and add the following there:
    WSGIScriptAlias /trac "trac-site-location/apache/trac.wsgi"

    <Directory "trac-site-location/apache">
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>

Tuesday, March 02, 2010

Why can't I resize this window?


Who should be held responsible for this ...abomination?

Wednesday, February 17, 2010

Project with 2 CPP files with the same name in different folders.

This comes as a surprise. I have a C++ project in which the code has been split across several folders. I have two .CPP files of the same name (utility.cpp) in two different folders. The content in the files is not the same. Different symbols defined in each. Sounds like this should work without a hitch, right?

I'm not yet sure of this but it looks like there is no straightforward way to do this in VS2008. Both files are compiled to the same output folder. It looks like the compiler (cl.exe) compiles both .CPP files to the same .OBJ file. So, the last compiled .CPP wins. By the time the linker (linker.exe) reaches the scene, only the symbols defined in the last compiled .CPP are available and the linker fails giving you "LNK2028: unresolved token".

I looked at VS2008 options to see if there was a way to include the relative path of the source file as part of the compiler's output file path, but so far I have not been successful.

Here's the  related post on stackoverflow.com.

About Me

My photo
C/C++ Programmer doing CAD on Windows. Some web development experience. Bangalorean.

Blog Archive

Labels