Thursday, January 10, 2013
Making my own wine rack
So I decided to put our loose wine bottles somewhere so they would be out of the way, but easy to find a bottle.
I could have easily drank them all, but after further thought, decided to convert one of our downstairs closets into a mini wine cellar.
I was originally going to build it in place, but my wife convinced me to build it so it could be relocated in the future, so I started to think out a design.
I decided to build it using Pine wood (I like the look and it's reasonably priced), only the supports were non-pine (fir).
Here is a link to the construction:
https://plus.google.com/photos/104338446149726978470/albums/5830527587073893329
I made it to hold 18 bottles, 6 per row. I build the rows separately, and then mounted on the 2x2 supports.
Wednesday, January 18, 2012
Adding PostgreSQL db to Asp.Net web project on Windows 7
Last night I was trying to connect an existing Asp MVC 3 app to use an PostgreSQL database. It is using nHibernate, so I'm still going to have to determine if I need to tweak anything there, but for now just wanted to connect properly.
After installing Postgre, I needed to install the ODBC connector in order to establish a connection in my .Net application. There was a little trick, when I used the ODBC configurator from the Start menu, I didn't see the newly installed ODBC adapter! WTF? Turns out, since I was running a 64 bit version of my OS, I had to run c:\windows\syswow64\odbcad32.exe in order to set my new ODBC driver. There is also another way...
Install NpgSQL adapter, I used the latest .Net 4.0 install. After referencing the Npg dll in your project (plus an associated Mono dll), you can simply use their wrappers in order to connect, here you can get the gist:
using NpgSQL;
var connstring = String.Format("Server=localhost;Port=5432;User Id=;Password=xxx; Database=DbName;");
var conn = new NpgsqlConnection(connstring);
conn.Open();
const string sql = "SELECT LastName FROM Users ORDER BY LastName LIMIT 10";
var da = new NpgsqlDataAdapter(sql, conn);
var ds = new DataSet();
da.Fill(ds);
Install NpgSQL adapter, I used the latest .Net 4.0 install. After referencing the Npg dll in your project (plus an associated Mono dll), you can simply use their wrappers in order to connect, here you can get the gist:
using NpgSQL;
var connstring = String.Format("Server=localhost;Port=5432;User Id=
var conn = new NpgsqlConnection(connstring);
conn.Open();
const string sql = "SELECT LastName FROM Users ORDER BY LastName LIMIT 10";
var da = new NpgsqlDataAdapter(sql, conn);
var ds = new DataSet();
da.Fill(ds);
Monday, January 9, 2012
Angular.js and setting up IIS to recognize JSON
Ok, so I've been messing around with Angular.js, so far, a great framework for client-side HTML manipulation. Advantages include separation of concern (with an MVC architecture), and really good testing ease using Jasmine, taking advantage of Dependency injection, and awesome databinding features.
With regards to the Dependency injection, there is a $xhr service (it's a service used to GET data), but when I attempted to use it with IIS 7, no go. Checking IIS under the hood, I found no MIME mapping to .json files, so after some digging on the web, here is how to set it up:
With regards to the Dependency injection, there is a $xhr service (it's a service used to GET data), but when I attempted to use it with IIS 7, no go. Checking IIS under the hood, I found no MIME mapping to .json files, so after some digging on the web, here is how to set it up:
Configure IIS to recognize JSON:
IIS7 configuration to support JSON:
Using IIS manager: clock on IIS server (the main node on the left - where you see the machine name)
- Add ‘json’ MIME Type
- Double click on ‘MIME Types’ icon
- Click ‘Add…’ link (under Actions section on the right side)
- In ‘Add MIME Type’ window type:
File name extension: .json
MIME type: application/json2. Add Script Map Handler for ‘json’ MIME Type
- Click OK, You should see the .json MIME Type added to the list of the MIME Types list.
- Double click on ‘Handler Mappings’ icon
- Click on ‘Add Script Map…’ link (under Actions section on the right side)
- In ‘Add Script Map’ window type:
Request path: *.json
Executable: C:\Windows\System32\inetsrv\asp.dll
Name: JSON
- Click OK (Message box pops up with a message: Do you want to allow this ISAPI extension?...etc ) Click Yes, You should see the .json extension added to the list of the Handler Mappings list
Wednesday, December 14, 2011
CDs and DVDs - Why???
As far as the CD and DVD technology, I've felt like I've been in a twilight zone episode for the past 5 years!
Let's face it, CDs were a breakthrough technology in the 80s, brought great features and portability over the existing tape players. Later DVDs brought more storage and functionality, but I can't understand why this media is still being used commercially today.
Netflix tried to buck the trend and tried to push streaming versus physical DVD rental and the stock plunged, the masses rebuffed. (in this case the business model and content availability were to blame)
I have two little boys that rent DVDs from the library to see the latest Sesame Street video, it is rarely playable since a few tiny scratches render the medium unplayable. Bring back the 3 1/2 floppy! :)
Solid State sticks are great, but I guess the cost per use ratio isn't as viable as the cheaply produced DVDs...
Any alternatives on the horizon so I can go on in peace?
Let's face it, CDs were a breakthrough technology in the 80s, brought great features and portability over the existing tape players. Later DVDs brought more storage and functionality, but I can't understand why this media is still being used commercially today.
Netflix tried to buck the trend and tried to push streaming versus physical DVD rental and the stock plunged, the masses rebuffed. (in this case the business model and content availability were to blame)
I have two little boys that rent DVDs from the library to see the latest Sesame Street video, it is rarely playable since a few tiny scratches render the medium unplayable. Bring back the 3 1/2 floppy! :)
Solid State sticks are great, but I guess the cost per use ratio isn't as viable as the cheaply produced DVDs...
Any alternatives on the horizon so I can go on in peace?
Friday, November 4, 2011
Beginning a S#arp architecture ASP MVC 3 solution
I've used a lot of blogs in order to piecemeal together a S#arp architecture solution and here are the steps involved.
Why use S#arp architecture? Well, you could try various architectures, I am currently working a Unity/nHibernate/Fluid NHibernate solution, but it takes so long to set up, whereas S#arp is first of all a great setup, but also very simple to install and setup the project.
1. Download and install T4 Templater (choose Typical install) http://www.codeplex.com/t4toolbox
The templater allows you to have VS templates such as S#arp.
2. Get Templify. It's a great tool to deploy your S#arp architecture solution, it even comes with the S#arp template ready to go.
3. This step is optional. You can a Visual Studio template editor for more pizzazz.
4. To insure you have the latest S#arp template, might as well install the latest Templify template from here: http://www.sharparchitecture.net/downloads.htm
5. Using Windows Explorer, create a folder where you want your new MVC project to go. Right click on the folder and select "Templify Here". You will be shown the following screen and it will guide you to create your project. Be patient as it sets it up...
Compile and run your project. You may have to specify an NHibernate DB login to proceed. You now have the template compiled and running! You should see the following and be ready to start coding:
Why use S#arp architecture? Well, you could try various architectures, I am currently working a Unity/nHibernate/Fluid NHibernate solution, but it takes so long to set up, whereas S#arp is first of all a great setup, but also very simple to install and setup the project.
1. Download and install T4 Templater (choose Typical install) http://www.codeplex.com/t4toolbox
The templater allows you to have VS templates such as S#arp.
2. Get Templify. It's a great tool to deploy your S#arp architecture solution, it even comes with the S#arp template ready to go.
3. This step is optional. You can a Visual Studio template editor for more pizzazz.
4. To insure you have the latest S#arp template, might as well install the latest Templify template from here: http://www.sharparchitecture.net/downloads.htm
5. Using Windows Explorer, create a folder where you want your new MVC project to go. Right click on the folder and select "Templify Here". You will be shown the following screen and it will guide you to create your project. Be patient as it sets it up...
Compile and run your project. You may have to specify an NHibernate DB login to proceed. You now have the template compiled and running! You should see the following and be ready to start coding:
Wednesday, August 10, 2011
Ignoring certain file types on SVN commit
I've been using SVN as my main source control and was annoyed that on every commit I had to uncheck a few files that were created locally and shouldn't be part of the repository.
Files like roo.log and a bunch of *.externalToolBuilder files. How to exclude those every time from the check in process?
Fortunately you can exclude certain file types when you are commiting.
First, you can check what is currently being omitted by typing:
svn propget svn:ignore
You will probably see .project, .setting, etc. svn does exclude some by default, but now type:
svn propedit svn:ignore .
If it complains about not having an editor, simply create an environmental variable to store the following:
SVN_EDITOR=notepad
Now type the propedit command and add whatever additional filters you want!
Files like roo.log and a bunch of *.externalToolBuilder files. How to exclude those every time from the check in process?
Fortunately you can exclude certain file types when you are commiting.
First, you can check what is currently being omitted by typing:
svn propget svn:ignore
You will probably see .project, .setting, etc. svn does exclude some by default, but now type:
svn propedit svn:ignore .
If it complains about not having an editor, simply create an environmental variable to store the following:
SVN_EDITOR=notepad
Now type the propedit command and add whatever additional filters you want!
Sunday, July 31, 2011
Custom Event Logger for .Net 3.5 and .Net 4.0
I needed to write a .Net 3.5 Event logger for a custom lib I am coding for a client. After scouring the internet, there were a lot of antiquated code samples. I even found a lot of modern samples on MSDN, but was surprised to see very poor code (having a .close() not within a using() or finally())
I decided to write a custom Event logger class with the following simple functionality, since the primary use was to report events or errors.
Here is the Class:
Here is also sample usage:
I decided to write a custom Event logger class with the following simple functionality, since the primary use was to report events or errors.
- Have a write() event that would log a custom error to the event log (found in the System logs)
- Would write to a text file in the event the Event did not get logged. I found this step necessary since the calling program may not have Event log access due to security.
Here is the Class:
class CustomEventLog
{
const string sourceName = "Your custom event name here";
const string logType = "System";
const string customTextLog = "c:\\CustomEventLog.log";
public static void Write(string message, EventLogEntryType type)
{
try
{
//See if the source exists.
if (!(EventLog.SourceExists(sourceName, System.Environment.MachineName)))
{
System.Diagnostics.EventLog.CreateEventSource(new EventSourceCreationData(sourceName, logType));
}
using (EventLog ev = new EventLog(logType, System.Environment.MachineName, sourceName))
{
ev.WriteEntry(message, type, 10001);
Console.WriteLine(message);
ev.Close();
}
}
catch (Exception ex)
{
// If all else fails write to disk
using (StreamWriter sw = new StreamWriter(customTextLog, true))
{
sw.WriteLine(ex.ToString());
if (message != null)
{
sw.WriteLine(message);
}
sw.Close();
}
}
}
}
Here is also sample usage:
CustomEventLog.Write("This is an informational comment.", EventLogEntryType.Information);
Subscribe to:
Posts (Atom)