Programming

warning: Creating default object from empty value in /home1/seocactu/public_html/csharptocsharp/modules/taxonomy/taxonomy.module on line 1388.

Hello friends! It's been a while, but I've been busy! Since you last heard from me I have switched gigs (still a .NET shop), switched locations (Cambridge!) and started a metal band: Vrawsche.

In the programming world, been working a lot lately on Backbone/RequireJS and Jasmine unit testing... and C#/ASP.NET MVC, all really hot stuff...

Oh, and I'm also on github now!

Here are my favorite Firefox add-ons

Web Developer tool bar (gotta love Ctrl+Shift+f)

Firebug (the best javascript debugger and more)

Html Validator (great for seeing all your awesome htmlz c0dez)

Sqlite Manager (the version for Firefox 3.5 is much improved)

Greasemonkey (custom scripts)

Modify Headers (I use to test other user agents)

Live Page Rank (get google page rank for the site you're on)

Search Status (lots of SEO goodies)

Add n Edit Cookies (easily add and/or modify cookies)

Remove Cookies for Site (removes cookies only for the site you're on)

ColorZilla (eyedropper tool to get any color on a web page, in an image, or html)

refspoof (change the referring url)

YSlow (figure out why your site is slow :( )

Hackbar (test your site with various sql injection strings)

So, are YOU going to DevConnections 2008 at Mandalay Bay? (See pathetic poll to the right).

This is my second time to vegas in <6 months and this time, I'm hoping to check out Alex, Picasso, and Ed Roman Guitars.

I'm going with a bunch of guys from w0rk. Should be fun, though I've read some not-so-good reviews of our hotel... (Can't be the Venetian every time...)

kick it on DotNetKicks.com

So... who's going to OWASP NYC AppSec 2008 Conference?? It's coming up very soon...aka NEXT WEEK!

I'm looking forward to the following talks...

· Get Rich or Die Trying - Making Money on The Web, The Black Hat Way (HOT!)
· Next Generation Cross Site Scripting Worms
· Bypassing web application/service security controls using Encoding, Transcoding, Filter Evasion, and other Canonicalization Attacks

kick it on DotNetKicks.com

Tired of seeing 10,343 error emails when your application blows up? So you finally took a hint and got around to logging your web application. Good work, you're another step closer to being a rock and roll geek dude.

Log4Net is a great choice for all of your logging needs. I'll assume that you have log4net correctly installed and it's giving you some sort of output. If not, the mighty Phil Haack has written about configuring log4net numerous times. Rock your Loggin'

I have two Log4Net xml config files that I switch between using debug and release preprocessor directives (Too lazy to change one for releases [They're virtually the same except for priority value]). Having the log4net config outside of web.config won't make the app restart if you need to make a change to it while it's in the wild (hot) (though won't show updates until app restart).

There are a bunch of log4net example configs available for download on the Log4Net website. I have included here the log4net config file that I am using on my latest project.

The Reasons:

Here is why I like the following log4net setup:

  • The current log keeps its static name of "log-file.txt." Paired with something like Log4Net Viewer or baretail (my preference) and the scrolling appender option, it is WICKED easy to watch the logging action as it happens in real time.
  • It will create a new log for each day or if the max size is reached (I have it set to 15mb here and 14 logs).
  • Logs are named in such a way that viewing past logs is easy... log-file.txtYYYYMMDD is what I have here where YYYYMMDD will be replaced by the actual year, month, day. (In the case where you have might have multiple logs per day, a number will be appended to the file name log-file.txtYYYYMMDD.1, log-file.txtYYYYMMDD.2, etc.).
  • What is sexier than logging?

On to the goodies...

The Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<log4net>
<root>
<priority value="Info"/>
<appender-ref ref="RollingFileAppender"/>
</root>

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\Path\\To\\Your\\log-file.txt" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="14" />
<maximumFileSize value="15000KB" />
<datePattern value="yyyyMMdd" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="{%level}%date{MM/dd HH:mm:ss} - %message%newline"/>
</layout>
</appender>
</log4net>
</configuration>

The End:

In closing, I hope you have some sort of logging strategy for your application, using my log4net config or not, it will lead you even closer to being rocktaclar, and that is veddie nice.

Thumbs Up!
I like the log! Niiiiice.

kick it on DotNetKicks.com

So I came across this post about the uncommon features of C# when I thought I'd add one of my own that I recently learned from the master of HttpContext.Current.Items, none other than Mike Duncan.

It's the good 'ol coalesce operator (??). Yeah, yeah, you've heard of it in SQL and the like, but it's pretty hot in C#. It will return the first non-null item from a group of two or more objects. Here's an example noting the hottest card game ever made!

So you love your multi-keyed keyboard shortcuts in Visual Studio, well I do too. The best part about them is the message that pops up after you eff it up! "(Ctrl+K) was pressed. Waiting for second key of chord." Key of chord? Am I getting ready to modulate?

About Brian


profile for bluevoodoo1 on Stack Exchange, a network of free, community-driven Q&A sites

Brian Canzanella brings you nifty tips and tricks for most things .NET. read more...

Readers / Stuff