Math and More

April 12, 2009

Mono FastCGI automatic subdomain apps

Filed under: Uncategorized — Bryan Bell @ 11:55 am
Tags: , , , ,

As I outlined in my previous post on using Mono with FastCGI and Nginx, I’m hosting multiple ASP.Net applications with Mono. I already have Nginx configured to automatically direct subdomains of quickpm.net to the fastcgi-mono-server2 program using the fastcgi protocol.

I also have the fastcgi-mono-server2 configured using the following options
fastcgi-mono-server2 /applications=cmd.quickpm.net:/:/usr/local/nginx/html/cmd.quickpm.net,quickpm.net:/:/usr/local/nginx/html/quickpm.net /socket=tcp:127.0.0.1:9000

To quickply explain, the /applications argument is setting the cmd.quickpm.net domain to be served by the directory /usr/local/nginx/html/cmd.quickpm.net, and the other sites are set to their respective directories. The /socket option is telling fastcgi-mono-server2 to listen using the tcp protocol on port 9000 of the local host.

My only problem is that adding new subdomains is not automatic. If I want to add a new subdomain to my website I have to shutdown the mono fastcgi server and restart it with the subdomain added to the /applications argument, I could use a config file instead of the command line option but the point is I have to shut the server down and restart it to add subdomains. I want avoid doing this. What I want is an option like the following /applications=%1.quickpm.net:/:/usr/local/nginx/html/%1.quickpm.net so all subdomains are automatically handled.

The only way to do what I want, I believe, is to patch the mono xsp2 source code.

February 13, 2009

Configuring Mono and ASP.Net on Nginx

Filed under: Uncategorized — Bryan Bell @ 1:59 am
Tags: , , , , , ,

For work I need to setup one domain with multiple subdomains. The basic idea for the website is the same as Fog Bugz, in that it’s a web hosted app. And each customer has their own site e.g. johnny.quickpm.net would be johhny’s site.

For the technology side we use ASP.Net Web forums for the actual software, that is johnny.quickpm.net is running an instance of Asp.net WebForms on Mono.  But for the main site quickpm.net I want to run ASP.Net MVC since I like the MVC model and mono now (mostly) supports ASP.Net MVC in the current daily builds.

For the server software I’m using Nginx and the Mono FastCGI interface.  The important configuration bits are
nginx.conf

#user  nobody;
worker_processes  1;
                       	 
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] $request '
    #                  '"$status" $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost *.quickpm.net;
	root /usr/local/nginx/html/$host;
        #charset koi8-r;

        access_log  logs/access.log;
	location / {	
		 root /usr/local/nginx/html/$host/;
	 	 index index.html index.htm index.aspx default.aspx Default.aspx;
		 fastcgi_index Default.aspx;
		 fastcgi_pass 127.0.0.1:9000;
		 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$host$fastcgi_script_name;
	 	 include ../conf/fastcgi_params;
	 }

        #location / {
        #    root   html;
	#    index index.html index.html index.aspx default.aspx Default.aspx;
        #}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}

To run the mono fastcgi server use

fastcgi-mono-server2 /applications=cmd.quickpm.net:/:/usr/local/nginx/html/cmd.quickpm.net,quickpm.net:/:/usr/local/nginx/html/quickpm.net /socket=tcp:127.0.0.1:9000

Doing the above results in quickpm.net resolving to /usr/local/nginx/html/quickpm.net and cmd.quickpm.net resolving to /usr/local/nginx/html/cmd.quickpm.net also mono will serve the two directories as two separate ASP.Net Applications.

December 15, 2008

Sqlite: Unable to open database file

Filed under: Uncategorized — Bryan Bell @ 7:13 pm
Tags: , , ,

The webapp for my project at work was receiving the error “unable to open database file” from SQLite. The error was intermittent hence it was hard to diagnose. I was using a SQLite database on a webserver running xsp2 and mono (i.e. ASP.Net).  A few times I also received the error “System.IO.File: Too many files open” but this only happened once or twice.

I was running the webapp on openSUSE 11, after some dead ends I finally tried opening a large number of file descriptors from a simple console app. That’s how I discovered that by default openSUSE 11 only lets a process open ~1023 file descriptors. But xsp2 opens a large number of file descriptors when it’s serving web pages in fact this is why SQLite was giving the error “unable to open database file”. SQLite couldn’t allocated a new file descriptor for opening the database file since xsp2 had already used all of the available file descriptors. The fix is to add the following lines to /etc/security/limits.conf

* soft nofile 2048

* hard nofile 4096

To check the user file descriptor limits on unix run the command: ulimit -a

September 9, 2008

Mt Whitney Hike

Filed under: Uncategorized — Bryan Bell @ 8:31 pm
Tags: , , , , ,

I took a long weekend to climb Mt Whitney with my Dad, the photos are at http://picasaweb.google.com/Bryan.W.Bell/MtWhitney

August 16, 2008

Music Similarity (somebody did it!)

Filed under: Uncategorized — Bryan Bell @ 6:28 am
Tags: , ,

Way back last year I did a couple posts on audio analysis in the context of music similarity. It turns out that Dominik Schnitzer of Austria has worked extensively on this project for his masters thesis. The project is Mirage

Mt Shasta Climb

Filed under: Uncategorized — Bryan Bell @ 6:22 am
Tags: , , , ,

I don’t normally post personal items but last weekend I climbed Mount Shasta with my dad, which I was very happy to summit. In July we’d tried to summit but got turned back by some ice.

The photos are at photos

July 25, 2008

Screencast

Filed under: Uncategorized — Bryan Bell @ 10:10 am
Tags: , , , , ,

I’ve uploaded a screencast demonstrating the capabilities of a quickbooks sync application that I wrote. The video is at link

There are several issues with the screencast that I want to fix before I upload my next one.

1. The audio is out of sync with the video. I’ll have to fiddle around with the settings for CamStudio to try and fix this. It’s also possible that my computer is just too old and getting a faster computer would fix this problem.

2. The uploaded video has blurry text. I tried uploading the AVI video that CamStudio generates to Google video and Youtube. Youtube generated a better result from the Avi video. But I’m still not happy. I might try creating the video with a different resolution or maybe try Vimeo which I believe has higher resolution videos.

Anyways it was a fun experience creating a screencast and I’m sure to do it again.

June 29, 2008

Multiple Ways to Do It

Filed under: Uncategorized — Bryan Bell @ 9:24 pm
Tags: ,

By do it I do not mean sex! What dirty dirty minds you all have. Infact I want to talk about the dual of limiting user choice. My post on limiting the number of choices a user has to make, has an obvious corollary in that you want to give the user multiple ways to accomplish a task.

A classic example are the cut-copy-paste operations. Windows/Linux/Apple all have three distinct ways to cut/copy/paste.

1. Select the text and goto the edit menu and select the cut/copy operations. Similarly goto the edit menu to paste.

2. Select the text and then use the right click menu to select the cut/copy operations, ditto for paste.

3. Use the keyboard shortcuts for the cut/copy/paste operations.

There are the three different ways to cut/copy/paste because, depending on the user they will prefer one way or another. Also if there was only one way to cut/copy/paste many users would never figure out how to cut/copy/paste.

Also the keyboard shortcuts are for power users (you can see this by observing run of the mill users who almost never use the keyboard shortcuts).

I want to make clear that the purpose of having multiple ways to do a task is to allow for the variance in how the users of your application think. As designers we want our application to be appealing to all of its users. This implies that we must have multiple ways to accomplish tasks because our users have different mental models of how the components of our application fit together. For example in Firefox you can create a new tab by (1) File-> New Tab menu, (2) Ctl-T Keyboard, (3) right click on link and click New Tab. Firefox needs all of these different ways to create new tabs because some users want to use the File menu, some want to use the keyboard and some want to right click. Any one of these ways is the “right-way” but the only way to keep our users happy is to include all three.

This post is almost the dual of the my post on limiting user choice. A big part of creating a good user interface is in finding the best balance between limiting choices and having multiple ways for users to accomplish their tasks.

June 12, 2008

Database Wrapper Objects

Filed under: Uncategorized — Bryan Bell @ 3:57 am
Tags: , , ,

It’s common to use small wrapper objects around database tables. One object represents one row in the database table. For the sake of clarity the following is a simple example:

Database: Documents table, with columns (Id, FileName, Data). Where Id is an identifier for the object, I use a <a href=”http://en.wikipedia.org/wiki/Guid”>Guid</a>.

A simple wrapper object for the Documents table would have the following pseudo code

class Document {
property Id
prpoerty FileName
property Data
}

The only issues are how to create new Document objects, how to save Document objects, and how to retrieve Document objects.

Since I’m young and stupid I had the wrong solution for all three problems.
First I created a separate Database class with static methods for Retrieving, Adding, & Updating Document objects. This becomes unmanageable when the number of wrapper objects for the database gets above 10.

The correct solution is to
1. Create a Save() method for the Document class that intelligently either adds the document to the database or updates the existing document in the database. Thus the user of the document class doesn’t need to remember if they’re updating an existing document or creating a new document.

2. Have a single constructor for the Document class that accepts an Id. This constructor then creates a new Document object if that Id does not exist in the database or retrieves the existing Document object from the database if that Id is in the database.

By doing the above the creation and saving of Document objects is entirely consistent. This reduces the cognitively load on users of the Document class so they don’t have to think about the details of how Document objects are created and stored, instead they can concentrate their effort on other things.

User Interface Design

Filed under: Uncategorized — Bryan Bell @ 3:56 am
Tags: , ,

The below post has absolutely nothing to do with mathematics but it’s my blog so I can post whatever I want :)

So you’ve got this great business application. It has all the the greatest features, it does everything but clean the house.

The only problem is it’s way too complicated for your poor users to figure out. It has twenty different tabs just to change an email address. This is where good user interface design can make the difference between a successful application and one that your users (if you have any) absolutely despise.

One of the principles of UI design is to not give users too many choices. This comes from the
Paradox of Choice. Thus as designers we need to ensure that the user does not consciously make choices. One way to do this is to limit the number of choices for the user based on the context (typically the page they are currently at). The below image from Picasa Web Albums illustrates this by not allowing users to click on the current tab.

In the below example from Golden1′s website you can’t even tell which tab is currently selected.

A great example of reducing choice to improve the user experience is Gnome vs. KDE (which has configurations up the wazoo).

This is just one small example of what goes into UI design. For more info see http://ometer.com/free-software-ui.html, http://www.joelonsoftware.com/uibook/chapters/fog0000000057.html, etc.

Next Page »

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.