Wednesday, December 30, 2009

Using pyjamas with web2py

Web2Py is a wonderful frameworks Web written in Python.
If you like the power and ease of use web2py is for you
Pyjamas is a port of Google Web Toolkit in Python

http://www.web2py.com/AlterEgo/default/show/203

Friday, December 11, 2009

C# Tutorial - Using The ThreadPool

http://www.switchonthecode.com/tutorials/csharp-tutorial-using-the-threadpool

VSTO Drag & Drop - Application_SheetChange event handler

http://msdn.microsoft.com/en-us/library/bb840032.aspx

SQLCLR : Table Valued Function


using System;
using Microsoft.SqlServer.Server;
using System.Collections;
using System.Data.SqlTypes;
using System.Collections.Generic;

class Product
{
public int Quantity { get; set; }
public string Description { get; set; }
}


public partial class UserDefinedFunctions
{

[SqlFunction(TableDefinition = @"Quantity int,
Description nvarchar(100)",
Name = "Products",
FillRowMethodName = "FillRowProduct")]
public static IEnumerable GetProducts()
{

List lstPerson = new List();
lstPerson.Add(new Product { Quantity = 1, Description = "Ball" });
lstPerson.Add(new Product { Quantity = 10, Description = "Bike" });
lstPerson.Add(new Product { Quantity = 5, Description = "Club" });
lstPerson.Add(new Product { Quantity = 10, Description = "Bat" });
return lstPerson;
}


public static void FillRowProduct(Object obj, out SqlInt32 Quantity, out SqlChars Description)
{
Product p = (Product)obj;
Description = new SqlChars(p.Description);
Quantity = new SqlInt32(p.Quantity);
}
};

<--->
SELECT Prod.*
FROM dbo.Products() AS Prod

Quantity Description
1    Ball
10    Bike
5    Club
10    Bat

Sunday, December 6, 2009

CLR Stored Procedures

http://www.sqldbatips.com/showarticle.asp?ID=22
http://www.aspfree.com/c/a/MS-SQL-Server/NET-CLR-stored-procedures-in-SQL-Server-2005-DB-Good-News-to-Programmers-Shock-to-DBAs/2/

C# Code Snippets

http://en.csharp-online.net/CSharp_Code_Snippets

VSTO Excel From Range to Array Array to Range


using System;
using Excel = Microsoft.Office.Interop.Excel;

namespace ExcelArray
{
public partial class ThisAddIn
{
Excel.Worksheet ws;
Excel.Range c;
Object[,] arValue;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
ws = (Excel.Worksheet)Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;

for (int j = 1; j < 11; j++)
{
for (int i = 1; i < 11; i++)
{
c = (Excel.Range)ws.Cells[i, j];
c.Value2 = i+j-1;
}
}

// From Range to Array
// We copy the 2nth column
c = (Excel.Range)ws.get_Range(ws.Cells[1, 2], ws.Cells[10, 2]);
c.Interior.ColorIndex = 2;
arValue = (Object[,])c.Value2;

// Array to Range
// We paste on the first column
c = (Excel.Range)ws.get_Range(ws.Cells[12, 1], ws.Cells[21, 1]);
c.Value2 = arValue;
c.Interior.ColorIndex = 6;
}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}

#region VSTO generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}

#endregion
}
}

Saturday, December 5, 2009

Friday, December 4, 2009

C# - DatagridView

I was in search of editing cell programmatically.
Here is a simple attempt


using System.Collections.Generic;
using System.Windows.Forms;

namespace testGridView
{
public partial class Form1 : Form
{
List cars;

int currentValue;

public Form1()
{
InitializeComponent();
InitializeCarsCollection();
SetLayoutGrid();
this.dataGridView1.DataSource = cars;
}

private void SetLayoutGrid()
{
this.dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);
this.dataGridView1.CellEndEdit += new DataGridViewCellEventHandler(dataGridView1_CellEndEdit);
this.dataGridView1.Dock = DockStyle.Fill;
this.dataGridView1.AutoGenerateColumns = true;
this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
}

void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
int editedValue = (int)this.dataGridView1[e.ColumnIndex, e.RowIndex].Value;

if (editedValue != this.currentValue)
{
System.Windows.Forms.MessageBox.Show(this.dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString());
}
}

void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{


if (e.ColumnIndex == 2)
{
this.currentValue = (int)this.dataGridView1[e.ColumnIndex, e.RowIndex].Value;
this.dataGridView1.BeginEdit(true);
}
}

private void InitializeCarsCollection()
{
cars = new List();
cars.Add(new Car { Marque = "Renault", Couleur = "rouge", Cylindree = 6 });
cars.Add(new Car { Marque = "Citroen", Couleur = "bleu", Cylindree = 4 });
cars.Add(new Car { Marque = "Peugeot", Couleur = "vert", Cylindree = 8 });
cars.Add(new Car { Marque = "BMW", Couleur = "jaune", Cylindree = 16 });
}
}
}

Monday, August 10, 2009

User Defined Functions

'...if you have ever wanted to use the results of a stored procedure as part of a T-SQL command, use parameterized non-updateable views, or encapsulate complex logic into a single database object, the SQL Server 2000 User-Defined function is a new database object that you should examine to see if its right for your particular environment.'

http://www.sqlteam.com/article/user-defined-functions

CLR Stored Procedures

http://msdn.microsoft.com/en-gb/library/ms131094.aspx

http://www.devx.com/dbzone/Article/28412/1954

http://www.amergerzic.com/post/CLRStoredProcedures.aspx

http://aspalliance.com/1338_Working_with_Managed_Stored_Procedure_using_Visual_Studio_2005.5

Saturday, July 11, 2009

The adventures of a Pythonista in Schemeland

http://www.artima.com/weblogs/viewpost.jsp?thread=238789

Beginning F#: Card Tricks

http://www.devx.com/dotnet/Article/40537/1954

Mastermind F# WPF Game Sample

http://www.trelford.com/blog/post/Mastermind-F-WPF-Game-Sample.aspx

How to Write XNA Game Studio Express Games

http://grammerjack.spaces.live.com/blog/cns!F2629C772A178A7C!156.entry

Learning WPF through F#, and vice versa, by John Liao

http://blogs.msdn.com/dsyme/archive/2008/01/05/learning-wpf-through-f-and-vice-versa-by-john-liao.aspx

Exploring F# with Conway’s Game of Life

http://blogs.vertigo.com/personal/rtaylor/Blog/Lists/Posts/Post.aspx?ID=8

Simple F# Game using WPF

http://blogs.msdn.com/chrsmith/archive/2008/09/04/simple-f-game-using-wpf.aspx

F# FOR GAME DEVELOPMENT

http://sharp-gamedev.blogspot.com/2008/09/hello-world.html

Tuesday, July 7, 2009

How to Design Programs

http://www.htdp.org/2003-09-26/Book/curriculum.html

Factory Pattern in C#

I wanted to access the fields of the created classes.
Here is the code I've implemented, feel free to comment


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FactoryPattern
{

    interface Base
    {      
    }
    
    class Factory
    {
        Base derived;

        public Base GetObject(int selector)
        {
            switch (selector)
            {
                case 1:
                    derived = new Derived1();
                    break;
                case 2:
                    derived = new Derived2();
                    break;
            }
            return derived;
        }
    }


    class Derived1 : Base
    {
        public string origin = "Derived1";      
    }


    public class Derived2 : Base
    {
        public string origin = "Derived2";
        public int value = 145;
    }

    class Program
    {
        public static object GetFieldValue(string nameField, object obj)
        {
            return obj.GetType().GetField(nameField).GetValue(obj);
        }

        static void Main(string[] args)
        {
            Base obj;
            Factory f = new Factory();
            obj = f.GetObject(2);          
            var origin =  GetFieldValue("value", obj);
            System.Console.WriteLine(String.Format("{0}",origin));
            Console.ReadLine();          
        }
    }
}

Tuesday, June 23, 2009

VSTO Excel : GetRange

        /// <summary>
        /// Return a range starting from cell C
        /// The range can contain empty cell
        /// C - - - - - -
        ///  - -   - - - -
        ///  - - - - - - -
        ///  - -   - -          
        ///  </summary>
        /// <param name="ws"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        public Excel.Range GetRightDownRegion(Excel.Worksheet ws, Excel.Range start)
        {
            Excel.Range curCell = start;
            Excel.Range endCell = start;
                  
            int lastCol;
            int offsetCol;
            int j = 0;

            while (curCell.Value2 != null)
            {
                curCell = start.get_Offset(0, j);
                if (curCell.Value2 != null)
                {
                    endCell = curCell;
                }
                j++;
            }
            
            lastCol = endCell.Column;

            int i = 0;
            curCell = start;
            endCell = start;

            while (curCell.Value2 != null)
            {
                curCell = start.get_Offset(i, 0);
                if (curCell.Value2 != null)
                {
                    endCell = curCell;
                }
                i++;
            }
            
            offsetCol = lastCol - endCell.Column;

            endCell = endCell.get_Offset(0, offsetCol);
                                    
            return ws.get_Range(start, endCell);            
        }
    }

Thursday, June 11, 2009

VSTO : ListObjects

VSTO is not obvious, here is to name columns

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Linq;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;

namespace ExcelWorkbook7
{
public partial class Feuil1
{
NorthwindDataContext ctx = new NorthwindDataContext();

private void Feuil1_Startup(object sender, System.EventArgs e)
{
var cs = from cust in ctx.Customers
select cust;

Microsoft.Office.Tools.Excel.ListObject customerData;
customerData = this.Controls.AddListObject(this.get_Range(this.Cells[1,1],this.Cells[1,2]), "Customers");
DataGridTableStyle s = new DataGridTableStyle();

customerData.TableStyle = "TableStyleLight10";
customerData.ListColumns.get_Item(1).Name = "ID";
customerData.ListColumns.get_Item(2).Name = "Name";
customerData.SetDataBinding(cs,"","CustomerID","CompanyName");

}

private void Feuil1_Shutdown(object sender, System.EventArgs e)
{
}

#region VSTO Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InternalStartup()
{

this.Startup += new System.EventHandler(this.Feuil1_Startup);
this.Shutdown += new System.EventHandler(this.Feuil1_Shutdown);

}

#endregion

}
}

How to programmatically display data into an excel worksheet

http://thedotnet.com/nntp/156520/showpost.aspx

Excel Object Model reference

http://msdn.microsoft.com/en-us/library/bb149081.aspx

VSTO : Add ListObject Controls to Worksheets

http://msdn.microsoft.com/en-us/library/eyfs6478(VS.80).aspx

Trie paramétrable

http://forum.hardware.fr/hfr/Programmation/CNET-managed/parametrable-list-sort-sujet_111411_1.htm

Saturday, May 16, 2009

Excel Addin : calling service

Given a simple asmx service, here is how to call it in an Excel AddIn


(...)
using ExcelAddIn.ServiceReference1;

namespace ExcelAddIn
{
public partial class ThisAddIn
{

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}

public void Hello()
{
using (Service1SoapClient svc = new Service1SoapClient())
{
Excel.Range rgStart;
Excel.Worksheet ws = (Excel.Worksheet)Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;
rgStart = ws.Application.ActiveCell;
rgStart.Value2 = svc.HelloWorld();
}
}


#region VSTO generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}

#endregion
}
}



In RibbonBar

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Tools.Ribbon;

namespace ExcelAddIn
{
public partial class Ribbon1 : OfficeRibbon
{
public Ribbon1()
{
InitializeComponent();
}

private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{

}

private void button1_Click(object sender, RibbonControlEventArgs e)
{
Globals.ThisAddIn.Hello();
}
}
}

Friday, May 15, 2009

JQuery : Templating using Pure.js

I have tried to use 'chain.js' but it was too slow so I've adopted Pure.js, which is very fast.
I also use the nice tips of John which allows to hide
html parts.
Here is a sample on how I use Pure with JQuery

Here is the link for the lib:
http://beebole.com/pure
Thanks Mic Cvilic



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script src="../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/pure.js" type="text/javascript"></script>
    <script src="../Scripts/Services.js" type="text/javascript"></script>  

</head>
<body>
    <button onclick="getProducts();">GetProducts</button>        
    <br />
    <div id="productsList"></div>
    <br />
    <button onclick="decS();">prev 10</button><button onclick="incS();">next 10</button>
    

      
   <!-- Scripts -->
  
  
    <script type="text/html" id="productsListTemplate">
            <table id="products" border="1"; width="400">
            <thead>
                <tr>
                    <th style="width:100;">ProductID</th>
                    <th>ProductName</th>
                </tr>
            </thead>
            <tbody id="tableBody">
            </tbody>
        </table>
    </script>
    <script type="text/html" id="tableBodyTemplate">
       <tr class="context">
         <td class="ProductID"></td>
         <td class="ProductName"></td>
       </tr>
    </script>    

    <script type="text/javascript" charset="utf-8">
        var s = 0;
        var t = 10;
        var uriProducts = "ClientBin/DataService.axd/InfoCentreV01-Web-ProductService/GetProducts?";
        var tableBodyTemplate = $("#tableBodyTemplate").html();
        var prdtTemplate = $("#productsListTemplate").html();
        $("#productsList").html(prdtTemplate);


        function incS() {
            s = s + 10;
            getProducts()
        }

        function decS() {
            if (s > 1) {
                s = s - 10;
            }
            getProducts();
            
        } 
        
        function getProducts() {
            var uri = uriProducts + "s=" + s + "&t=" + 10;
            $.getJSON(uri, function(products) {
                var context = products.Results;
                $("#tableBody").html('');
                $("#tableBody").html(tableBodyTemplate);
                $('#products').autoRender(context);
                
            });
        }            
    </script>  

</body>
</html>

Saturday, April 18, 2009

Inserting Images into Database and Display it in GridView through Handler.ashx

http://www.aspdotnetcodes.com/Insert_Images_Database.aspx

Dynamic Graph and Chart Generator

http://www.codeproject.com/KB/web-image/MyGraphsAndChartsSite.aspx?display=PrintAll

West Wind Ajax Toolkit for ASP.NET

http://www.west-wind.com/tools/wwhoverpanel/

Jquery-Cheat-Sheet

http://www.cheat-sheets.org/saved-copy/Jquery-Cheat-Sheet-1.2.pdf

An introduction to jQuery

http://www.west-wind.com/presentations/jQuery/

Using jQuery in ASP.NET apps with httphandlers (ASHX)

This sample shows how to update cascaded dropdownlist

http://sites.google.com/site/spyderhoodcommunity/tech-stuff/usingjqueryinaspnetappswithhttphandlersashx

Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls

http://mattberseth.com/blog/2008/01/building_a_grouping_grid_with.html

Friday, April 17, 2009

Using jQuery Plugins with ASP.NET

http://mattberseth.com/blog/2008/06/using_jquery_plugins_with_aspn.html

MVC talking to WCF

http://sankarsan.wordpress.com/2009/04/12/a-layered-aspnet-mvc-application-part-i/

Walkthrough: Adding ASP.NET AJAX Scripting to an MVC Project

http://msdn.microsoft.com/en-us/library/dd381533.aspx

ASP.NET MVC Best Practices

http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx

MVC View : Problem returning LIST

http://www.cerkit.com/cerkitBlog/CommentView,guid,4dc9c26c-97c7-479e-b24a-d37d4a5c1229.aspx

RESTful Web Service Using ASPNet-MVC

http://shouldersofgiants.co.uk/Blog/post/2009/02/21/Creating-a-RESTful-Web-Service-Using-ASPNet-MVC-Part-16-e28093-XML-Encoding.aspx

Create REST API using ASP.NET MVC

http://msmvps.com/blogs/omar/archive/2008/10/03/create-rest-api-using-asp-net-mvc-that-speaks-both-json-and-plain-xml.aspx

Wednesday, April 8, 2009

Raising Events From User Controls

Given a simple button in a usercontrol, here is the code behind

Partial Public Class WebUserControl
Inherits System.Web.UI.UserControl

Public Event MyEvent As System.EventHandler

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
RaiseEvent MyEvent(Me, New EventArgs())
End Sub
End Class


And in the code behind aspx page


Partial Public Class _Default
Inherits System.Web.UI.Page

Dim WithEvents uc As WebUserControl

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub myControl_MyEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles uc.MyEvent
'...'
End Sub

End Class


On aspx page

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication37._Default" %>
<%@ Register Src="~/WebUserControl.ascx"  TagPrefix="uc" TagName="mycontrol" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <uc:mycontrol ID="myuc"  runat="server" OnMyEvent="myControl_MyEvent"  />
    </div>
    </form>
</body>
</html>

Sunday, March 29, 2009

OpenFrameWorks

Openframeworks is a c++ library designed to assist the creative process by providing a simple and intuitive framework for experimentation.



http://www.openframeworks.cc/download

Tuesday, March 24, 2009

HTTP Web Programming with WCF 3.5: Creating a Template based URI

http://blogs.microsoft.co.il/blogs/egady/archive/2008/01/14/http-web-programming-with-wcf-3-5-creating-a-template-based-uri.aspx

Consuming REST service using jQuery

http://tech2update.com/blog/?p=94

http://stephenwalther.com/blog/archive/2008/03/14/using-asp-net-ajax-with-asp-net-mvc.aspx

http://stephenwalther.com/blog/archive/2008/03/14/using-asp-net-ajax-with-asp-net-mvc.aspx

Using jQuery with ASP .NET AJAX to create a cascading CheckBoxList

http://weblogs.asp.net/alnurismail/archive/2008/11/21/a.aspx

ASP.NET AJAX createDelegate and the JavaScript "this"

http://www.dennydotnet.com/post/2007/07/24/ASPNET-AJAX-createDelegate-and-the-JavaScript-this.aspx

A DataTable Serializer for ASP.NET AJAX

http://www.iterasi.net/openviewer.aspx?sqrlitid=sryvxbkxmumvzzgfcjgjea

jQuery AJAX calls to a WCF REST Service

http://west-wind.com/weblog/posts/324917.aspx

Calling a WCF Service using jQuery AJAX

http://www.elemenex.com/index.php?option=com_content&view=article&id=19

Thursday, March 19, 2009

Building LINQ Queries at Runtime in C#

http://tomasp.net/articles/dynamic-linq-queries.aspx

Plugin Concept in .Net

Here is th VB.NET translation of this excellent Article
http://www.ottoschellekens.nl/PluginConcept.htm


Imports System.Collections.Generic
Imports System.IO
Imports System.Reflection

Public Class PluginHandler

    Private Shared _Handler As PluginHandler
    Private _haPlugins = New System.Collections.Hashtable

    Public Shared Function Create() As PluginHandler
        If _Handler Is Nothing Then
            _Handler = New PluginHandler()
        End If
        Return _Handler
    End Function

    Public Function LoadPlugins() As Int16
        Dim PluginsLoaded = 0
        'Dim Path = "c:\OceanPlugins"
        Dim Path = System.Configuration.ConfigurationManager.AppSettings("RepertoirePlugins")
        Dim dir As DirectoryInfo = New DirectoryInfo(Path)
        Dim dllFiles() As FileInfo = dir.GetFiles("*.dll")
        For Each objInfo As FileInfo In dllFiles
            If LoadPlugin(objInfo.FullName) Then
                PluginsLoaded += 1
            End If
        Next
        Return PluginsLoaded
    End Function

    Public Function LoadPlugin(ByVal sFile As String) As Boolean
        Dim assPlugin As Assembly = Assembly.LoadFile(sFile)
        Dim typPluginTypes() As Type = assPlugin.GetTypes()
        Dim bReturn As Boolean = False

        For Each typPlugin In typPluginTypes
            Dim typInterface As System.Type = typPlugin.GetInterface("Ocean.IOceanPlugin")
            If typInterface IsNot Nothing And typPlugin.IsClass Then
                Dim objFactory As Object = assPlugin.CreateInstance(typPlugin.FullName)
                Dim objPlugin As Ocean.IOceanPlugin = CType(objFactory, Ocean.IOceanPlugin)
                _haPlugins.Add(objPlugin.GetShortDescription, objPlugin)                
                bReturn = True
            End If
        Next
    End Function

    Public Function getPlugins() As Hashtable
        Return _haPlugins
    End Function

End Class

Tuesday, March 17, 2009

Raytracing from SIGGRAPH

Raytracing Courses
http://www.openrt.de/Siggraph05/UpdatedCourseNotes/Slusallek_Basics.ppt

Raytracing : Compute Intersection

http://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/raycast/raycast.pdf

Python Raytracer in 50 Lines of Code

From http://jan.varho.org/blog/programming/python-raytracer-in-50-lines-of-code/comment-page-1/#comment-11


import math
from PIL import Image

def sub(v1, v2): return [x-y for x,y in zip(v1, v2)]
def dot(v1, v2): return sum([x*y for x,y in zip(v1, v2)])
def norm(v): return [x/math.sqrt(dot(v,v)) for x in v]

def trace_sphere(r, s, tmin, color):
sr = sub(s[0], r[0])
dsr = dot(sr, r[1])

d = dsr*dsr - dot(sr,sr) + s[1]
if d < 0: return
d = math.sqrt(d)

t1 = dsr + d
if t1 < 0: return

t2 = dsr - d
if t2 > tmin[0]: return

if t2 < 0:
tmin[0] = t1
else:
tmin[0] = t2
color[:] = [s[2]]

def trace_ray(ray, spheres):
color = [(0, 0, 0)]
tmin = [100000]
for s in spheres:
trace_sphere(ray, s, tmin, color)
return color[0]

red = (255,0,0)
blue = (0,0,255)
spheres = ( ((0,0,100), 100.0, red), ((0,-5,50), 20.0, blue) )

w, h = 200, 200

image = Image.new("RGB", (w, h))
pix = image.load()

for x in range(w):
for y in range(h):
ray = ( (0,0,0), norm(((x-w/2.0)/w, (y-h/2.0)/w, 1)) )
pix[x,y] = trace_ray(ray, spheres)

image.save("out.png")

Simple Ray Tracing Computation

Example of a simple Ray Tracing Computation to compute primary ray and test intersection with a sphere
http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtexamp1.htm

http://matthieu-brucher.developpez.com/tutoriels/3D/raytracer/01-introduction/

View Database Structure Using C#

http://www.codeproject.com/KB/database/DatabaseSpy_CS.aspx

ASP.NET IronPython Resource

http://www.ironpythonresource.com/post/2008/08/23/IronPython-Dynamically-creating-objects-and-binding-them-to-a-form.aspx