Sat May 12 14:50:26 BST 2012

Learning under pressure

Thought I should add a bit of the C# and MySQL that I've learnt over the last week, hopefully by next week there'll be some on VB.NET too...

First I'll point out that these examples are all in razor script and used in cshtml files, although they'll be easy enough to adapt to add to ASP or C# anyway.

In no particular order I'll start with one of the things that confused me at first, declaring an array; things have changed since I first learned programming and you declare the type of data in the array as an array, then the name of the array then set the values, like so:

[taken directly from MSDN]

// Declare a single-dimensional array 
int[] array1 = new int[5];

// Declare and set array element values
int[] array2 = new int[] { 1, 3, 5, 7, 9 };

// Alternative syntax
int[] array3 = { 1, 2, 3, 4, 5, 6 };

// Declare a two dimensional array
int[,] multiDimensionalArray1 = new int[2, 3];

// Declare and set array element values
int[,] multiDimensionalArray2 = { { 1, 2, 3 }, { 4, 5, 6 } };

// Declare a jagged array
int[][] jaggedArray = new int[6][];

// Set the values of the first array in the jagged array structure
jaggedArray[0] = new int[4] { 1, 2, 3, 4 };

-----

Posted by Phill | Permalink

Fri May 11 10:27:40 BST 2012

Firefox tabs

I was wondering how many tabs I had open in firefox today (I've just finished a project for a job application) and googled around and found this:
javascript:var w=Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator).getEnumerator('navigator:browser'),t=0;while(w.hasMoreElements())t+=w.getNext().document.getElementById("content").mTabs.length;alert("You have "+t+" tabs open");
you pop that into your error console (in firefox 12, Tools > Web Developer > Error Console)

and in case you were wondering... I had 93 tabs open at the time ;)

EDIT: I have since tried this and it no longer works (sad face) and you are warned:
TypeError: Components.classes is undefined
The Components object is deprecated. It will soon be removed.
There are now quite a few add-ins that will tell you though, probably easier, if less geeky...


Posted by Phill | Permalink

Fri May 4 18:41:25 BST 2012

Sharing with Windows

I've been setting up a Windows server (Windows Server 2008) to work in my home domain (as it is now!), the Windows partition and files are in a VM using VMWare, which sadly I may have to purchase licenses for both Windows and VMWare...

I want the Windows server to serve web pages supported with asp.NET and MSSQL whilst being able to edit the files from my Linux laptop.

I installed the IIS web platform, the SQL server and enabled all the appropriate options to be able to serve pages to my NAT network (the firewall stops outsiders). Having done this, to edit the files on my laptop, I enabled CIFS support on my kernel and rebooted, and set the Windows folder to share to everyone. To mount the share:
(substitute C and D with your network information, or the whole IP with the Windows computer designation and the windows_username with your windows username)

mount -t cifs //192.168.C.D/sharename /mnt/windows -o "user=windows_username"

(you'll need to have created a mount point, eg (as root)

# mkdir /mnt/windows
There are a few technical issues which arose from this, the most notable is that the web server on Windows will not access the folders in the share whilst it is mounted, so if you try to go to
http://localhost

or

http://127.0.0.1/
you will be greeted with a timeout and a blank web page. Oddly, from outside on another computer the files seem to serve correctly :confused:

I'll keep investigating, but for now, on to learning asp.NET and interfacing with SQL...

ADDENDUM!

I have been playing with IIS more now, and after the most fruitless search on the M$ support site (every search for "server 2008 <anything>" brought up server 2003 articles...) I found that it is normal for the pages not to serve AND (often) to be replaced with 404 errors, or show just the code - mine did the 404 error...

So, I went into the server manager program and found IIS doesn't turn on ASP (or asp.NET) by default, [have a look on http://learn.iis.net/page.aspx/562/classic-asp-not-installed-by-default-on-iis/ for full details - with pictures!] and you can turn on ASP features there... -----

Posted by Phill | Permalink