<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://shazwazza.com/rss/xslt"?>
<rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Shazwazza</title>
    <link>https://shazwazza.com/</link>
    <description>My blog which is pretty much just all about coding</description>
    <generator>Articulate, blogging built on Umbraco</generator>
    <image>
      <url>/media/0libq25y/frog.png?rmode=max&amp;v=1da0e911f4e6890</url>
      <title>Shazwazza</title>
      <link>https://shazwazza.com/</link>
    </image>
    <item>
      <guid isPermaLink="false">1314</guid>
      <link>https://shazwazza.com/post/writing-a-docfx-markdown-plugin/</link>
      <category>Web Development</category>
      <title>Writing a DocFx markdown plugin</title>
      <description>&lt;p&gt;What is &lt;a rel="noopener" href="https://dotnet.github.io/docfx/" target="_blank"&gt;DocFx&lt;/a&gt;? It’s a static site generator mainly used for creating API documentation for your code. But it can be used for any static sites. We use this for the Lucene.Net project’s &lt;a rel="noopener" href="https://lucenenet.apache.org/" target="_blank"&gt;website&lt;/a&gt; and &lt;a rel="noopener" href="https://lucenenet.apache.org/docs/4.8.0-beta00007/" target="_blank"&gt;documentation&lt;/a&gt;. The end result is API docs that look and feel a little bit familiar, kind of like Microsoft’s own API documentation website. I’m not entirely sure if their docs are built with DocFx but I suspect it is but with some highly customized builds and plugins … but that’s just my own assumption.&lt;/p&gt;
&lt;p&gt;Speaking of customizing DocFx, it is certainly possible. That said the ironic part about DocFx is that it’s own documentation is not great. One of the markdown customizations we needed for the Lucene.Net project was to add a customized note that some APIs are experimental. This tag is based on the converted Java Lucene docs and looks like: &lt;a&gt;“@ &lt;em&gt;lucene&lt;/em&gt;.&lt;/a&gt;&lt;em&gt;experimental&lt;/em&gt;&lt;em&gt; ”. &lt;/em&gt;So we wanted to detect that string and convert it to a nice looking note similar to the &lt;a rel="noopener" href="https://dotnet.github.io/docfx/spec/docfx_flavored_markdown.html#note-warningtipimportant" target="_blank"&gt;DocFx markdown note&lt;/a&gt;. Luckily there is &lt;a rel="noopener" href="https://dotnet.github.io/docfx/tutorial/howto_customize_docfx_flavored_markdown.html" target="_blank"&gt;some docs on how to do that&lt;/a&gt; although they’re not at all succinct but the example pretty much covers exactly what we wanted to do.&lt;/p&gt;
&lt;h2&gt;Block markdown token&lt;/h2&gt;
&lt;p&gt;This example is a block level token since it exists on it’s own line and not within other text. This is also the example DocFx provides in it’s docs. It’s relatively easy to do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Register a IDfmEngineCustomizer to insert/add a “Block Rule”&lt;/li&gt;
&lt;li&gt;Create a new “Block Rule” which in it’s simplistic form is a regex that parses the current text block and if it matches it returns an instance of a custom “Token” class&lt;/li&gt;
&lt;li&gt;Create a custom “Token” class to store the information about what you’ve parsed&lt;/li&gt;
&lt;li&gt;Create a custom “Renderer” to write out actual HTML result you want&lt;/li&gt;
&lt;li&gt;Register a &lt;em&gt;IDfmCustomizedRendererPartProvider&lt;/em&gt; to expose your “Renderer”&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This all uses &lt;a rel="noopener" href="https://docs.microsoft.com/en-us/dotnet/framework/mef/" target="_blank"&gt;MEF&lt;/a&gt; to wire everything up. You can see the Lucene.Net implementation of a custom markdown block token here: &lt;a href="https://github.com/apache/lucenenet/tree/master/src/docs/LuceneDocsPlugins"&gt;https://github.com/apache/lucenenet/tree/master/src/docs/LuceneDocsPlugins&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Inline markdown token&lt;/h2&gt;
&lt;p&gt;The above was ‘easy’ because it’s more or less following the DocFx documentation example. So the next challenge is that I wanted to be able to render an Environment Variable value within the markdown… sounds easy enough? Well the code result is actually super simple but my journey to get there was absolutely not!&lt;/p&gt;
&lt;p&gt;There’s zero documentation about customizing the markdown engine for inline markdown and there’s almost zero documentation in the codebase about what is going on too which makes things a little interesting. I tried following the same steps above for the block markdown token and realized in the code that it’s using a &lt;em&gt;MarkdownBlockContext&lt;/em&gt; instance so I discovered there’s a &lt;em&gt;MarkdownInlineContext&lt;/em&gt; so thought, we’ll just swap that out … but that doesn’t work. I tried inserting my inline rule at the beginning, end, middle, etc… of the &lt;em&gt;DfmEngineBuilder.InlineInlineRules&lt;/em&gt; within my &lt;em&gt;IDfmEngineCustomizer&lt;/em&gt; but nothing seemed to happen. Hrm. So I cloned the DocFx repo and started diving into the tests and breaking pointing, etc…&lt;/p&gt;
&lt;p&gt;So here’s what I discovered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Depending on the token and if a token can contain other tokens, its the tokens responsibility to recurse the parsing&lt;/li&gt;
&lt;li&gt;There’s a sort of ‘catch all’ rule called &lt;a rel="noopener" href="https://github.com/dotnet/docfx/blob/dev/src/Microsoft.DocAsCode.MarkdownLite/Basic/InlineRules/MarkdownTextInlineRule.cs" target="_blank"&gt;MarkdownTextInlineRule&lt;/a&gt; and that will ‘eat’ characters that don’t match the very specific markdown chars that it’s not looking for.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;This means that if you have an inline token that is delimited by chars that this doesn’t ‘eat’, then your rule will not match. So your rule can only begin with certain chars: &lt;a rel="noopener" href="https://github.com/dotnet/docfx/blob/dev/src/Microsoft.DocAsCode.MarkdownLite/Regexes.cs#L114" target="_blank"&gt;&lt;strong&gt;\&amp;lt;!\[*`&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Your rule must run before this one&lt;/li&gt;
&lt;li&gt;For inline rules you don’t need a “Renderer” (i.e. &lt;em&gt;IDfmCustomizedRendererPartProvider)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Inline rule regex needs to match at the beginning of the string with the hat ^ symbol. This is a pretty critical part of how DocFx parses it’s inline content.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now that I know that, making this extension is super simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I’ll make a Markdown token: &lt;strong&gt;[EnvVar:MyEnvironmentVar] &lt;/strong&gt;which will parse to just render the value of the environment variable with that name, in this example: MyEnvironmentVariable.&lt;/li&gt;
&lt;li&gt;I’ll insert my rule to the top of the list so it doesn’t come after the catch-all rule&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class="lang-csharp"&gt;// customize the engine
[Export(typeof(IDfmEngineCustomizer))]
public class LuceneDfmEngineCustomizer : IDfmEngineCustomizer
{
    public void Customize(DfmEngineBuilder builder, IReadOnlyDictionary&amp;lt;string, object&amp;gt; parameters)
        {
        // insert inline rule at the top
        builder.InlineRules = builder.InlineRules.Insert(0, new EnvironmentVariableInlineRule());
    }
}

// define the rule
public class EnvironmentVariableInlineRule : IMarkdownRule
{
    // give it a name
    public string Name =&amp;gt; "EnvVarToken";

    // define my regex to match
    private static readonly Regex _envVarRegex = new Regex(@"^\[EnvVar:(\w+?)\]", RegexOptions.Compiled);

    // process the match
    public IMarkdownToken TryMatch(IMarkdownParser parser, IMarkdownParsingContext context)
    {
        var match = _envVarRegex.Match(context.CurrentMarkdown);
        if (match.Length == 0) return null;

        var envVar = match.Groups[1].Value;
        var text = Environment.GetEnvironmentVariable(envVar);
        if (text == null) return null;

        // 'eat' the characters of the current markdown token so they aren't re-processed
        var sourceInfo = context.Consume(match.Length);

        // return a docfx token that just returns the text passed to it
        return new MarkdownTextToken(this, parser.Context, text, sourceInfo);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the end, that’s actually pretty simple! But don’t go trying to create a fancy token that doesn’t start with those magic characters since it’s not going to work.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:09:54 Z</pubDate>
      <a10:updated>2023-03-23T15:09:54Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1169</guid>
      <link>https://shazwazza.com/post/finding-success-in-oss/</link>
      <category>Web Development</category>
      <title>Finding success in OSS</title>
      <description>&lt;p&gt;I’ve been working in open source for quite some time and wanted to share some of my experiences in regards to managing OSS projects and communities. I’ve been employed by &lt;a href="https://umbraco.com/" target="_blank"&gt;Umbraco&lt;/a&gt;, an open source .Net based CMS, for over 7 years (wow! where has the time gone!?) and have been working with the Umbraco project for even longer. In the past 10 years I’ve also started a number of my own OSS projects, seen many other colleagues and companies do the same, seen many get stalled, sometimes fail, sometimes succeed and more rarely, actually thrive. We’ve seen an enormous rise in the OSS take-up within the .Net world in the past few years thanks to Microsoft really embracing and encouraging open source and the communities that make it work. But OSS is not an easy or straightforward task. So how does an open source project succeed? … I unfortunately don’t have a straightforward answer for that either but I would like to share some insight based on my own experience.&lt;/p&gt;&lt;p&gt;The main reason I’ve mentioned Umbraco is because it is one of these rarer open source projects that has actually thrived and it’s quite exciting to be part of such a large worldwide community. So how have they made it work? Like many other Umbraco community members, I started using it many moons ago, working in agency land and wanting a .Net based open source CMS. At that time, it turned out that this was really the only one out there that seemed to do the job. For me, what made this project so exciting back then was how easy it was to help make the software better. It was easy to submit patches, it was easy to get feedback on issues and proposed features, it was easy to get in touch with other community members and what was really great was that it didn’t take long for your fixes or features that you submitted to be part of a new release. This was all back before GitHub or even Git existed so all of this communication was done in email or on custom built forums, but it still worked. Skip ahead to today and the underlying principles that still make this project exciting haven’t changed, it’s now just infinitely easier to do all of these things with better tools. The community of Umbraco is what makes this project tick, it has always been the main focus of the project and with community growth, the software and ecosystem thrive.&lt;/p&gt;&lt;h2&gt;But it’s free! … so how am I employed??&lt;/h2&gt;&lt;p&gt;This is the most common question I get asked about working for an open source project. When I started, I had no idea how to make an open source project sustainable along with having paid employees and I was equally intrigued. Umbraco offered a few services and products that were paid in order to be able to pay full time staff members and keep the project growing. These were things like various levels of certified training courses, add-on licensed products and paid support plans. Today the story for Umbraco is similar and includes all of these things but now also includes subscription models for Software as a Service called Umbraco Cloud which helps to continue the cycle of re-investing into growing the community and the project.&lt;/p&gt;&lt;h2&gt;Most OSS projects are made by individuals&lt;/h2&gt;&lt;p&gt;But … most OSS projects are tiny and are run by a single person who is the sole developer on a project who dedicate their own time to writing and maintaining it. A lot of this time will be used to help people: investigating issues, answering questions, writing documentation, fixing bugs, releasing new versions, etc… and all of this is done for &lt;strong&gt;Free&lt;/strong&gt; but these are the things that make a project successful. It is actually quite difficult to create a community that re-invests their time into helping write your software rather than just using your software. If you can convince one or more developers to get on board, you’ll then need to invest more of your time in reviewing code, documentation updates, bug fixes and features created by your community. This time is critical, you want to be able to provide feedback and to integrate your communities changes as fast as possible… this is what will help keep your community re-investing their own time in growing the project and hopefully drumming up support for even more developers to chip in.&lt;/p&gt;&lt;p&gt;In my experience, this is where most OSS projects plateau because the project’s founder doesn’t have enough time to manage it all. This generally leaves projects in a semi-stalled state and may end up losing active developers and community members since their pull requests and submitted issues will remain pending for too long. These projects will ebb and flow, developers get busy and then may be re-inspired to find some more time. This doesn’t mean these projects are unsuccessful and it is probably the state of most OSS projects out there.&lt;/p&gt;&lt;h2&gt;So how do you keep a project’s momentum?&lt;/h2&gt;&lt;p&gt;I try to keep my own projects ‘active’ by answering questions, reviewing PRs and releasing new versions as often as I can… but in reality, this doesn’t happen as often as I would like. Sometimes I get re-inspired and may invest my evenings or weekends on some features but ultimately, I don’t think this is sustainable if you do want your OSS project to become community driven. One of the first OSS projects I created was called “uComponents” which was a collection of plugins for Umbraco and I did something with that project that I haven’t done with any of my other ones – I asked another community member to take over the project. This meant providing write access to the code but more importantly &lt;strong&gt;trusting another developer&lt;/strong&gt; to help move the project forward. Eventually there was a few devs with write access and helping to manage the project and it ended up being very successful. I think if you can find people to help manage your project and allow yourself to trust other devs with that task, it will massively help your chances of not stalling the project.&lt;/p&gt;&lt;p&gt;I think the key to keeping a project’s momentum is to get really good at setting up the fundamentals for establishing a community:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Make it as easy as possible to contribute and discuss&lt;/li&gt;&lt;li&gt;Respond to your community in a timely fashion – doesn’t need to be a solution, but some form of acknowledgement is needed&lt;/li&gt;&lt;li&gt;Have good documentation and make sure the community can contribute to it&lt;/li&gt;&lt;li&gt;Have small achievable tasks on your tracker and use tags like &lt;a href="https://up-for-grabs.net/" target="_blank"&gt;“up-for-grabs”&lt;/a&gt; or “help-needed” so it’s easy for the community to know where they can ship in&lt;/li&gt;&lt;li&gt;Have CI/CD setup with tests, feedback and build outputs for the community to use&lt;/li&gt;&lt;li&gt;Trust other people in helping you to manage your project&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;How do larger OSS projects do it?&lt;/h2&gt;&lt;p&gt;I can’t answer this question for all larger OSS projects, but I can provide some insight with what we do at Umbraco. The more popular a project becomes, the more people there will be that that need help. &lt;strong&gt;Ideally, you’ll want to try to convert the people that are needing help, into people that are providing help&lt;/strong&gt;. To do that you should have all of the above points working well to make it easy for your community to start helping each other instead of just relying on you. Trusting the community is certainly at the heart of it all and this allows for the community to manage several aspects of itself.&lt;/p&gt;&lt;p&gt;At Umbraco, we have a &lt;a href="https://umbraco.com/blog/introducing-the-new-pr-team/" target="_blank"&gt;community PR team&lt;/a&gt; that dedicates their own time to helping out with the project and assisting with communication between the community and dev team and ensuring that contributors are receiving a timely response. We have a &lt;a href="https://umbraco.com/blog/the-umbraco-documentation-curators/" target="_blank"&gt;community documentation team&lt;/a&gt; that dedicates their own time to generate missing documentation, assessing documentation PRs and to help encourage more contributors to get involved. Our community forum is also open source and is where community members can ask and answer questions. We use &lt;a href="https://github.com/" target="_blank"&gt;GitHub&lt;/a&gt; for all of our code and our public issue tracker and use tags like up-for-grabs along with some bots to help automate the interaction with contributors on GitHub. We’ve also established some policies regarding issues and PRs to try to keep their numbers to a minimum, as one example: only allowing an up-for-grabs issue to be open for a certain amount of time and if it doesn’t get picked up it just gets closed. The premise for this is that it isn’t important enough for the community at the moment since nobody wanted to pick it up, so it gets closed with the option of being reopened if it becomes important again.&lt;/p&gt;&lt;p&gt;In order to manage all of this interaction we have a couple of full-time staff members that spend a significant amount of time working with the community and these community teams, on our forums and on our issue trackers. Several years ago, this was not the case and it’s now clear that managing a large community is a full time role and what quickly became obvious was that the more you invest in the community the more you get back.&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-managing-open-source-projects_a7b3-crop_34591114033_7b2c3e0869_o-1-_2.jpg"&gt;&lt;img width="1028" height="281" title="CodeGarden conference" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" alt="CodeGarden conference" src="https://shazwazza.com/media/articulate/open-live-writer-managing-open-source-projects_a7b3-crop_34591114033_7b2c3e0869_o-1-_thumb.jpg" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2&gt;Are my own projects successful?&lt;/h2&gt;&lt;p&gt;Sort of, yes and no. Some projects get old and I’d rather they didn’t exist anymore but people still use them so they need to be maintained. Some projects are newer and I’m excited about them but then lack the time to keep their momentum going. Then I have a problem of having too many projects! The important thing to me is that I keep learning and I’m generally happy to keep investing the time I can find into all of my projects. I think some of my projects would be more successful if I actually did all of the things I mentioned above :)&lt;/p&gt;&lt;p&gt;The fact is, unless you have a lot of spare time or you are getting paid to work on OSS (so that you can make time), establishing and fostering an active community is difficult and requires putting in a lot of time and effort. For me it’s entirely worth it, I think starting and managing your own OSS project is hugely rewarding and it’s a wonderful platform for learning and collaborating regardless of how big or small the project becomes. &lt;/p&gt;&lt;h2&gt;Being a part of a community&lt;/h2&gt;&lt;p&gt;You don’t need to be the founder of a project to reap the rewards of OSS. You can learn an enormous amount by collaborating on an OSS project. Of course there’s plenty of technical knowledge to gain but there’s a lot of other skills you can gain too and in my opinion the most important of all is communication skills. It’s easy to get frustrated by software or by other community members especially if you’ve run into some annoying bugs, somebody is being a jerk or just being difficult to communicate with. But, it’s important to not let these types of things get the better of you and that in itself is a difficult skill to master! &lt;/p&gt;&lt;p&gt;Communication is a 2 way street and it’s important for both community members and project owners to be &lt;strong&gt;friendly&lt;/strong&gt;, &lt;strong&gt;patient &lt;/strong&gt;and &lt;strong&gt;helpful&lt;/strong&gt;. &lt;/p&gt;&lt;p&gt;A great example of this is in bug reports. Some reports are unhelpful, aggressive or even angry. When submitting bug reports or asking questions, keep in mind that you are generally asking people for help for free. Please be helpful, please be friendly, please be patient. Please think about how you would like to receive a bug report or be asked a question, include as much information as you can and remember that most people can’t read minds ;) And vice-versa, if you are responding to questions where people aren’t being as helpful as they should be, you’ll typically you’ll be able to turn a conversation into a friendly, patient and helpful one by just communicating that way yourself.&lt;/p&gt;&lt;p&gt;English is typically the language used in OSS projects and some people might not speak English as a first language and that’s ok! In this case, those 3 points are extremely important and it’s quite rewarding to see international community members who come from all sorts of backgrounds, countries and languages collaborating on a single project. &lt;/p&gt;&lt;p&gt;When both community members and project owners adopt these values, great things will happen and everyone wins!&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-managing-open-source-projects_a7b3-crop_47992054518_f04761e447_o_4.jpg"&gt;&lt;img width="1028" height="388" title="Umbraco Friendly Hoodie" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" alt="Umbraco Friendly Hoodie" src="https://shazwazza.com/media/articulate/open-live-writer-managing-open-source-projects_a7b3-crop_47992054518_f04761e447_o_thumb_1.jpg" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;hr&gt;&lt;p&gt;… now I need to go find some time to update my OSS projects :) &lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;em&gt;This blog is powered by &lt;a href="https://github.com/shazwazza/articulate" target="_blank"&gt;Articulate&lt;/a&gt;, an OSS project that I maintain which is running on &lt;a href="https://umbraco.com/" target="_blank"&gt;Umbraco&lt;/a&gt;, an OSS project that I work for and this post was written using &lt;a href="https://github.com/OpenLiveWriter/OpenLiveWriter" target="_blank"&gt;Open Live Writer&lt;/a&gt;, an OSS project that could use some love. &lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:09:33 Z</pubDate>
      <a10:updated>2023-03-23T15:09:33Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1213</guid>
      <link>https://shazwazza.com/post/configuring-azure-active-directory-login-with-umbraco-members/</link>
      <category>ASP.Net</category>
      <category>Web Development</category>
      <category>Umbraco</category>
      <title>Configuring Azure Active Directory login with Umbraco Members</title>
      <description>&lt;p&gt;This post is about configuring Azure Active Directory with Umbraco &lt;u&gt;Members&lt;/u&gt; (not &lt;em&gt;Users&lt;/em&gt;), meaning this is for your front-end website, not the Umbraco back office. I did write up a post about Azure AD with back office users though, so if that is what you are looking for then &lt;a href="https://shazwazza.com/post/configuring-azure-active-directory-login-with-umbraco/" target="_blank"&gt;this is the link&lt;/a&gt;. &lt;/p&gt;&lt;h2&gt;Install the Nuget packages&lt;/h2&gt;&lt;p&gt;First thing to do is get the &lt;a href="https://www.nuget.org/packages/UmbracoIdentity" target="_blank"&gt;UmbracoIdentity&lt;/a&gt; package installed. &lt;/p&gt;

&lt;div style="width: 100%;"&gt;
&lt;div style="padding: 10px; color: rgb(255, 255, 255); line-height: 1.5; font-family: consolas, menlo, monaco,&amp;quot;Courier New&amp;quot;, monospace; background-color: rgb(0, 36, 64);"&gt;PM &amp;gt; Install-Package UmbracoIdentity&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(This will also install the UmbracoIdentity.Core base package)&lt;/em&gt;&lt;/p&gt;&lt;p&gt;This package installs some code snippets and updates your web.config to enable ASP.Net Identity for Umbraco members. Umbraco ships with the old and deprecated ASP.Net Membership Providers for members and not ASP.Net Identity so this package extends the Umbraco CMS and the Umbraco members implementation to use ASP.Net Identity APIs to interact with the built in members data store. Installing this package will remove the (deprecated) FormsAuthentication module from your web.config and it will no longer be used to authenticate members, so the typical members snippets built into Umbraco macros will not work. Instead use the supplied snippets shipped with this package.&lt;/p&gt;&lt;p&gt;To read more about this package see the &lt;a href="https://github.com/Shazwazza/UmbracoIdentity" target="_blank"&gt;GitHub repo here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next, the OpenIdConnect package needs to be installed&lt;/p&gt;

&lt;div style="width: 100%;"&gt;
&lt;div style="padding: 10px; color: rgb(255, 255, 255); line-height: 1.5; font-family: consolas, menlo, monaco,&amp;quot;Courier New&amp;quot;, monospace; background-color: rgb(0, 36, 64);"&gt;PM &amp;gt; Install-Package Microsoft.Owin.Security.OpenIdConnect&lt;/div&gt;
&lt;/div&gt;

&lt;h2&gt;Configure Azure Active Directory&lt;/h2&gt;&lt;p&gt;Head over to the &lt;em&gt;Azure Active Directory &lt;/em&gt;section on the Azure portal, choose &lt;em&gt;App Registrations &lt;/em&gt;(I’m using the Preview functionality for this) and create a &lt;em&gt;New registration&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_4.png"&gt;&lt;img width="802" height="362" title="image" style="display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_thumb_1.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3&gt;Next fill out the app details&lt;/h3&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_22.png"&gt;&lt;img width="802" height="805" title="image" style="display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_thumb_10.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You may also need to enter other redirect URLs depending on how many different environments you have. All of these URLs can be added in the Authentication section of your app in the Azure portal.&lt;/p&gt;&lt;p&gt;For AAD configuration for front-end members, the redirect Urls are just your website’s root URL and it is advised to keep the trailing slash. &lt;/p&gt;&lt;h3&gt;Next you will need to enable Id Tokens&lt;/h3&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_12.png"&gt;&lt;img width="802" height="559" title="image" style="display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_thumb_5.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2&gt;Configure OpenIdConnect&lt;/h2&gt;&lt;p&gt;The UmbracoIdentity package will have installed an OWIN startup class in &lt;em&gt;~/App_Start/UmbracoIdentityStartup.cs &lt;/em&gt;(or it could be in App_Code if you are using a website project)&lt;em&gt;. &lt;/em&gt;This is how ASP.Net Identity is configured for front-end members and where you can specify the configuration for different OAuth providers. There’s a few things you’ll need to do:&lt;/p&gt;&lt;h3&gt;Allow external sign in cookies&lt;/h3&gt;&lt;p&gt;If you scroll down to the &lt;em&gt;ConfigureMiddleware &lt;/em&gt;method, there will be a link of code to uncomment: &lt;em&gt;app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); &lt;/em&gt;this is required for any OAuth providers to work.&lt;/p&gt;&lt;h3&gt;Enable OpenIdConnect OAuth for AAD&lt;/h3&gt;&lt;p&gt;You’ll need to add this extension method class to your code which is some boiler plate code to configure OpenIdConnect with AAD:&lt;/p&gt;

&lt;pre class="lang-csharp"&gt;&lt;code&gt;public static class UmbracoADAuthExtensions
{
    public static void ConfigureAzureActiveDirectoryAuth(this IAppBuilder app,
        string tenant, string clientId, string postLoginRedirectUri, Guid issuerId,
        string caption = "Active Directory")
    {
        var authority = string.Format(
            System.Globalization.CultureInfo.InvariantCulture,
            "https://login.windows.net/{0}",
            tenant);

        var adOptions = new OpenIdConnectAuthenticationOptions
        {
            ClientId = clientId,
            Authority = authority,
            RedirectUri = postLoginRedirectUri
        };

        adOptions.Caption = caption;
        //Need to set the auth type as the issuer path
        adOptions.AuthenticationType = string.Format(
            System.Globalization.CultureInfo.InvariantCulture,
            "https://sts.windows.net/{0}/",
            issuerId);
        app.UseOpenIdConnectAuthentication(adOptions);
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next you’ll need to call this code, add the following line underneath the &lt;em&gt;app.UseExternalSignInCookie&lt;/em&gt; method call: &lt;/p&gt;

&lt;pre class="lang-csharp"&gt;&lt;code&gt;app.ConfigureAzureActiveDirectoryAuth(
    ConfigurationManager.AppSettings["azureAd:tenantId"],
    ConfigurationManager.AppSettings["azureAd:clientId"],
    //The value of this will need to change depending on your current environment
    postLoginRedirectUri: ConfigurationManager.AppSettings["azureAd:redirectUrl"],
    //This is the same as the TenantId
    issuerId: new Guid(ConfigurationManager.AppSettings["azureAd:tenantId"]));&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then you’ll need to add a few appSettings to your web.config (based on your AAD info):&lt;/p&gt;

&lt;pre class="lang-csharp"&gt;&lt;code&gt;&amp;lt;add key="azureAd:tenantId" value="YOUR-TENANT-ID-GUID" /&amp;gt;
&amp;lt;add key="azureAd:clientId" value="YOUR-CLIENT-ID-GUID" /&amp;gt;
&amp;lt;add key="azureAd:redirectUrl" value="http://my-test-website/" /&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Configure your Umbraco data&lt;/h2&gt;&lt;p&gt;The UmbracoIdentity repository has the &lt;a href="https://github.com/Shazwazza/UmbracoIdentity#installation" target="_blank"&gt;installation documentation&lt;/a&gt; and you must follow these 2 instructions, and they are very simple:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="https://github.com/Shazwazza/UmbracoIdentity/wiki#2-member-type-updates" target="_blank"&gt;You need to update your member type with the securityStamp property&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="https://github.com/Shazwazza/UmbracoIdentity/wiki#3-creating-the-account-page" target="_blank"&gt;Create the Account document type&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Once that is done you will have an Member account management page which is based off of the installed views and snippets of the UmbracoIdentity package. This account page will look like this:&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_8.png"&gt;&lt;img width="802" height="305" title="image" style="display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_thumb_3.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;As you can see the button text under the “Use another service to log in” is the login provider name which is a bit ugly. The good news is that this is easy to change since this is just a partial view that was installed with the UmbracoIdentity package. You can edit the file: &lt;em&gt;~/Views/UmbracoIdentityAccount/ExternalLoginsList.cshtml&lt;/em&gt;, the code to render that button text is using &lt;em&gt;@p.Authentication&lt;/em&gt; provider but we can easily change this to &lt;em&gt;@p.Caption&lt;/em&gt; which is actually the same caption text used in the extension method we created. So the whole button code can look like this instead:&lt;/p&gt;
&lt;pre class="lang-html"&gt;&lt;code&gt;
&amp;lt;button type="submit" class="btn btn-default"
        id="@p.AuthenticationType"
        name="provider"
        value="@p.AuthenticationType"
        title="Log in using your @p.Caption account"&amp;gt;
    @p.Caption
&amp;lt;/button&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is a bit nicer, now the button looks like:&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_10.png"&gt;&lt;img width="802" height="192" title="image" style="display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_thumb_4.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The purpose of all of these snippets and views installed with UmbracoIdentity is for you to customize how the whole flow looks and works so you’ll most likely end up customizing a number of views found in this folder to suit your needs.&lt;/p&gt;&lt;h2&gt;That’s it!&lt;/h2&gt;&lt;p&gt;Once that’s all configured, if you click on the Active Directory button to log in as a member, you’ll be brought to the standard AAD permission screen:&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_18.png"&gt;&lt;img width="402" height="434" title="image" style="display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_thumb_8.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Once you accept you’ll be redirect back to your Account page:&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_20.png"&gt;&lt;img width="802" height="930" title="image" style="display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-configuring-azure-active-directory-login_c313-image_thumb_9.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Any customizations is then up to you. You can modify how the flow works, whether or not you accepting auto-linking accounts (like in the above example), or if you require a member to exist locally before being able to link an OAuth account, etc… All of the views and controller code in UmbracoIdentity is there for you to manipulate. The main files are:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;~/Views/Account.cshtml&lt;/li&gt;&lt;li&gt;~/Views/UmbracoIdentityAccount/*&lt;/li&gt;&lt;li&gt;~/Controllers/UmbracoIdentityAccountController.cs&lt;/li&gt;&lt;li&gt;~/App_Start/UmbracoIdentityStartup.cs&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Happy coding!&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:09:08 Z</pubDate>
      <a10:updated>2023-03-23T15:09:08Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1264</guid>
      <link>https://shazwazza.com/post/deploying-to-azure-from-vsts-using-publish-profiles-and-msdeploy/</link>
      <category>Web Development</category>
      <category>etc...</category>
      <category>Hosting</category>
      <category>Servers</category>
      <title>Deploying to Azure from VSTS using publish profiles and msdeploy</title>
      <description>&lt;p&gt;In almost all of the examples online about how to deploy various services to Azure, they always list the super easy way to do it and that is to authenticate your current account to your Azure subscription which then grants your VSTS build to do all sorts of things… The problem is that not everyone has the security clearance to use the super easy tools in VSTS.&lt;/p&gt;&lt;p&gt;When you attempt to use these nice tools in VSTS you might get an error like this: &lt;font color="#f79646"&gt;“Failed to set Azure permission ‘RoleAssignmentId: some-guid-goes-here’ for the service principal … does not have authorizationto perform action ‘Microsoft.Authorization/roleAssignments/write’ over scope”&lt;/font&gt; This is because these nice VSTS tools actually creates a custom user behind the scenes in your azure subscription to use but your account doesn’t have access to authorize that.&lt;/p&gt;&lt;p&gt;Luckily there’s a work around&lt;/p&gt;&lt;h2&gt;MS Deploy … sigh&lt;/h2&gt;&lt;p&gt;Maybe there are other work arounds but this works, however it’s not the most elegant. I thought I’d post my findings here because it was a bit of a pain in the ass to get this all correct.&lt;/p&gt;&lt;p&gt;So here’s the steps:&lt;/p&gt;&lt;h3&gt;1. Download the publish profile&lt;/h3&gt;&lt;p&gt;You need to get the publish profile from your app service that you want to deploy to. This can be a website, a staging slot, an Azure function, (probably a bunch of others)&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-deploying-to-azure_ead7-image_2.png"&gt;&lt;img width="600" height="185" title="image" style="border: 0px currentcolor; border-image: none; display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-deploying-to-azure_ead7-image_thumb.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The file downloaded is an XML file containing a bunch of info you’ll need&lt;/p&gt;&lt;h3&gt;2. Create a release definition and environment for your deployment&lt;/h3&gt;&lt;p&gt;&lt;em&gt;This assumes that you are pretty familiar with VSTS&lt;/em&gt;&lt;/p&gt;&lt;p&gt;You’ll want to create an empty environment in your release definition. Normally this is where you could choose the built in fancy VSTS deployment templates like “Azure App Service Deployment” … but as above, this doesn’t work if you don’t have security clearance. Instead, choose ‘Empty’&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-deploying-to-azure_ead7-image_4.png"&gt;&lt;img width="600" height="330" title="image" style="border: 0px currentcolor; border-image: none; display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-deploying-to-azure_ead7-image_thumb_1.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Then in your environment tasks, add Batch Script&lt;/p&gt;&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/open-live-writer-deploying-to-azure_ead7-image_6.png"&gt;&lt;img width="600" height="312" title="image" style="border: 0px currentcolor; border-image: none; display: inline; background-image: none;" alt="image" src="https://shazwazza.com/media/articulate/open-live-writer-deploying-to-azure_ead7-image_thumb_2.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3&gt;3. Setup your batch script&lt;/h3&gt;&lt;p&gt;There’s 2 ways to go about this and both depend on a msdeploy build output. This build output is generated by your build in VSTS if you are using a standard VSTS Visual Studio solution build. This will create msdeploy packages for you and will have put them in your artifacts folder. Along with msdeploy packages this will also generate a cmd batch file that executes msdeploy and a readme file to tell you how to execute it which contains some important info that you should read.&lt;/p&gt;&lt;p&gt;So here’s 2 options: Execute the cmd file, or execute msdeploy.exe directly&lt;/p&gt;&lt;h2&gt;Execute the cmd file&lt;/h2&gt;&lt;p&gt;There’s a bit of documentation about this online but most of it is based on using the SetParameters.xml file to adjust settings… but i just don’t want to use that. &lt;/p&gt;&lt;p&gt;Here’s the Path and Arguments that you need to run:&lt;/p&gt;


&lt;pre class="language-batch"&gt;&lt;code&gt;$(System.DefaultWorkingDirectory)/YOUR_BUILD_NAME/drop/YOUR_MSBUILD_PACKAGE.deploy.cmd&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=" language-batch"&gt;&lt;code&gt;/y "/m:https://${publishUrl}/MSDeploy.axd?site=${msdeploySite}" /u:$(userName) /p:$(userPWD) /a:Basic -enableRule:DoNotDeleteRule "-setParam:name='IIS Web Application Name',value='${msdeploySite}'"

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The parameters should be added to your VSTS Variables: ${msdeploySite}, $(userName), $(userPWD) and these variables correspond exactly to what is in your publish profile XML file that you downloaded. These parameters need to be pretty much exact, any misplaced quote or if you don’t include https, etc… will cause this to fail.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: the use of &lt;strong&gt;-enableRule:DoNotDeleteRule&lt;/strong&gt; is totally optional, if you want to reset your site to exactly what is in the msdeploy package you do not want this. If however, you have user generated images, content or custom config files that exist on your site and you don’t want them deleted when you deploy, then you need to set this.&lt;/p&gt;&lt;p&gt;I’m unsure if this will work for Azure Functions deployment (it might!) … but I used the next option to do that:&lt;/p&gt;&lt;h2&gt;Execute msdeploy.exe directly&lt;/h2&gt;&lt;p&gt;If you execute the CMD file, you’ll see in the VSTS logs the exact msdeploy signature used which is:&lt;/p&gt;
&lt;pre class="language-batch"&gt;&lt;code&gt;"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='d:\a\r1\a\YOUR_PROJECT_NAME\drop\YOUR_MSDEPLOY_PACKAGE_FILE.zip' -dest:auto,computerName="https://YOUR_PUBLISH_URL/MSDeploy.axd?site=YOUR_PROFILE_NAME",userName=********,password=********,authtype="Basic",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"d:\a\r1\a\YOUR_PROJECT_NAME\drop\YOUR_MSDEPLOY_PACKAGE_FILE.SetParameters.xml" -enableRule:DoNotDeleteRule -setParam:name='IIS Web Application Name',value='YOUR_PROFILE_NAME'&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So if you wanted, you could take this and execute that directly instead of the CMD file. I use this method to deploy Azure Functions but the script is a little simpler since that deployment doesn’t require all of these parameters. For that I use this for the Path and Arguments:&lt;/p&gt;
&lt;pre class="language-batch"&gt;&lt;code&gt;C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe&lt;/code&gt;&lt;/pre&gt;


&lt;pre class="language-batch"&gt;&lt;code&gt;-verb:sync -source:package='$(System.DefaultWorkingDirectory)/YOUR_BUILD_NAME/drop/YOUR_MSDEPLOY_PACKAGE.zip' -dest:auto,computerName="https://$(publishUrl)/msdeploy.axd?site=$(msdeploySite)",UserName='$(userName)',Password='$(userPWD)',AuthType='Basic' -setParam:name='IIS Web Application Name',value='$(msdeploySite)'&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Hopefully this comes in handy for someone &lt;img class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="https://shazwazza.com/media/articulate/open-live-writer-deploying-to-azure_ead7-wlemoticon-winkingsmile_2.png"&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:44 Z</pubDate>
      <a10:updated>2023-03-23T15:08:44Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1271</guid>
      <link>https://shazwazza.com/post/how-to-lazily-set-the-multi-term-rewrite-method-on-queries-in-lucene/</link>
      <category>Web Development</category>
      <title>How to lazily set the multi-term rewrite method on queries in Lucene</title>
      <description>&lt;p&gt;For wildcard queries in Lucene that you would like to have the results ordered by Score, there’s a trick that you need to do otherwise all of your scores will come back the same. The reason for this is because the default behavior of wildcard queries uses &lt;em&gt;CONSTANT_SCORE_AUTO_REWRITE_DEFAULT&lt;/em&gt; which as the name describes is going to give a constant score. The code comments describe why this is the default:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;a) Runs faster &lt;/p&gt;&lt;p&gt;b) Does not have the scarcity of terms unduly influence score&lt;/p&gt;&lt;p&gt;c) Avoids any "TooManyBooleanClauses" exceptions&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Without fully understanding Lucene that doesn’t really mean a whole lot but the Lucene docs give a little more info&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;NOTE: if setRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod) is either CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE or SCORING_BOOLEAN_QUERY_REWRITE, you may encounter a BooleanQuery.TooManyClauses exception during searching, which happens when the number of terms to be searched exceeds BooleanQuery.getMaxClauseCount(). Setting setRewriteMethod(org.apache.lucene.search.MultiTermQuery.RewriteMethod) to CONSTANT_SCORE_FILTER_REWRITE prevents this.&lt;/p&gt;&lt;p&gt;The recommended rewrite method is CONSTANT_SCORE_AUTO_REWRITE_DEFAULT: it doesn't spend CPU computing unhelpful scores, and it tries to pick the most performant rewrite method given the query. If you need scoring (like FuzzyQuery, use MultiTermQuery.TopTermsScoringBooleanQueryRewrite which uses a priority queue to only collect competitive terms and not hit this limitation. Note that org.apache.lucene.queryparser.classic.QueryParser produces MultiTermQueries using CONSTANT_SCORE_AUTO_REWRITE_DEFAULT by default.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;So the gist is, unless you are ordering by Score this shouldn’t be changed because it will consume more CPU and depending on how many terms you are querying against you might get an exception (though I think that is rare).&lt;/p&gt;&lt;h2&gt;So how do you change the default?&lt;/h2&gt;&lt;p&gt;That’s super easy, it’s just this line of code:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-csharp"&gt;QueryParser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But there’s a catch! You &lt;strong&gt;must&lt;/strong&gt; set this flag before you parse any queries with the query parser otherwise it won’t work. All this really does is instruct the query parser to apply this scoring method to any &lt;em&gt;MultiTermQuery&lt;/em&gt; or &lt;em&gt;FuzzyQuery&lt;/em&gt; implementations it creates. So what if you don’t know if this change should be made before you use the query parser? One scenario might be: At the time of using the query parser, you are unsure if the user constructing the query is going to be sorting by score. In this case you want to change the scoring mechanism just before executing the search but after creating your query. &lt;/p&gt;&lt;h2&gt;Setting the value lazily&lt;/h2&gt;&lt;p&gt;The good news is that you can set this value lazily just before you execute the search even after you’ve used the query parser to create parts of your query. There’s only 1 class type that we need to check for that has this API: &lt;em&gt;MultiTermQuery &lt;/em&gt;however not all implementations of it support rewriting so we have to check for that. So given an instance of a Query we can recursively update every query contained within it and manually apply the rewrite method like:&lt;/p&gt;



&lt;pre&gt;&lt;code class="language-csharp"&gt;protected void SetScoringBooleanQueryRewriteMethod(Query query)
{
	if (query is MultiTermQuery mtq)
	{
		try
		{
			mtq.SetRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
		}
		catch (NotSupportedException)
		{
			//swallow this, some implementations of MultiTermQuery don't support this like FuzzyQuery
		}
	}
	if (query is BooleanQuery bq)
	{
		foreach (BooleanClause clause in bq.Clauses())
		{
			var q = clause.GetQuery();
			//recurse
			SetScoringBooleanQueryRewriteMethod(q);
		}
	}
}

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So you can call this method just before you execute your search and it will still work without having to eagerly use &lt;em&gt;QueryParser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);&lt;/em&gt; before you use the query parser methods.&lt;/p&gt;&lt;p&gt;Happy searching!&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:40 Z</pubDate>
      <a10:updated>2023-03-23T15:08:40Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1310</guid>
      <link>https://shazwazza.com/post/smidge-plus-nuglify-bundling-minification-and-source-maps/</link>
      <category>Web Development</category>
      <title>Smidge + Nuglify bundling, minification and source maps</title>
      <description>&lt;p&gt;Smidge &lt;strong&gt;&lt;a rel="noopener noreferrer" href="https://github.com/Shazwazza/Smidge/releases/tag/v2.0.0-rtm" target="_blank"&gt;2.0.0 RTM&lt;/a&gt;&lt;/strong&gt; is finally here!&lt;/p&gt;
&lt;p&gt;What is Smidge? Smidge is a lightweight &lt;u&gt;runtime &lt;/u&gt;bundling library (&lt;em&gt;CSS/JavaScript file minification, combination, compression&lt;/em&gt;) for ASP.NET Core -  &lt;a rel="noopener noreferrer" href="/post/smidge-20-alpha-is-out/" target="_blank"&gt;&lt;em&gt;Here’s some more background info on Smidge&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There’s plenty of great &lt;a rel="noopener noreferrer" href="https://github.com/Shazwazza/Smidge/milestone/5" target="_blank"&gt;new features in the version 2.0.0&lt;/a&gt; , but in this post I’ll just highlight a couple of fun ones….&lt;/p&gt;
&lt;h2&gt;Nuglify and source maps&lt;/h2&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/xoofx/NUglify" target="_blank"&gt;Nuglify&lt;/a&gt; if an ASP.NET Core port of the old &lt;a rel="noopener noreferrer" href="http://ajaxmin.codeplex.com/" target="_blank"&gt;AjaxMin&lt;/a&gt; library and this works very nicely with Smidge too. By default Smidge uses an updated version of &lt;a rel="noopener noreferrer" href="http://www.crockford.com/javascript/jsmin.html" target="_blank"&gt;JsMin&lt;/a&gt; that I maintain called &lt;a rel="noopener noreferrer" href="https://github.com/Shazwazza/JsMinSharp" target="_blank"&gt;JsMinSharp&lt;/a&gt; for it’s JavaScript minification engine. JsMin works fairly well, it’s primary feature is that it’s &lt;em&gt;fast &lt;/em&gt;because it doesn’t come with any bells and whistles and doesn’t produce a &lt;a rel="noopener noreferrer" href="https://en.wikipedia.org/wiki/Abstract_syntax_tree" target="_blank"&gt;Syntax Tree&lt;/a&gt;. Nuglify on the other hand does produce a Syntax Tree which gives it loads of control over how the minification is done so that it can produce much smaller files, has the ability to rename/reduce parts of the JS and to produce &lt;a rel="noopener noreferrer" href="https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/" target="_blank"&gt;source maps&lt;/a&gt;. The downfall of all this control is that it becomes much slower but Smidge is smart enough to cache processed files on the server in a persistent state so it won’t re-process your files if it doesn’t need to.&lt;/p&gt;
&lt;p&gt;Here’s a quick benchmark of JsMin vs Nuglify to minify jQuery using the default options (and no source map). As you can see JsMin is substantially faster and is far better for memory but Nuglify can reduce the file size quite a lot more &lt;em&gt;(smaller Minified % is better)&lt;/em&gt;&lt;/p&gt;
&lt;table border="0" width="700" style="box-sizing: border-box; overflow: auto; margin-bottom: 16px; white-space: normal; word-spacing: 0px; margin-top: 0px; border-collapse: collapse; text-transform: none; border-spacing: 0px; orphans: 2; widows: 2; display: block; letter-spacing: normal; background-color: #ffffff; text-indent: 0px; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;
&lt;thead&gt;
&lt;tr style="box-sizing: border-box; border-top: #cccccc 1px solid; background-color: #ffffff;"&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Method&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Median&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;StdDev&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Scaled&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Scaled-SD&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Minified %&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Gen 0&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Gen 1&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Gen 2&lt;/th&gt;
&lt;th style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Bytes Allocated/Op&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr style="box-sizing: border-box; border-top: #cccccc 1px solid; background-color: #ffffff;"&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;JsMin&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;10.2008 ms&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;0.3102 ms&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;1.00&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;0.00&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;51.75%&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;-&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;-&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;-&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;155,624.67&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style="box-sizing: border-box; border-top: #cccccc 1px solid; background-color: #f8f8f8;"&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;Nuglify&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;69.0778 ms&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;0.0180 ms&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;6.72&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;0.16&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;32.71%&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;53.00&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;22.00&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;15.00&lt;/td&gt;
&lt;td style="box-sizing: border-box; border: #dddddd 1px solid; padding: 6px 13px 6px 13px;"&gt;4,837,313.07&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Source maps you say? JsMin isn’t all that smart so it can’t produce source maps (&lt;em&gt;&lt;a rel="noopener noreferrer" href="https://github.com/Shazwazza/Smidge/issues/57" target="_blank"&gt;yet&lt;/a&gt;&lt;/em&gt;) but Nuglify certainly can and by default the &lt;em&gt;Smidge.Nuglify&lt;/em&gt; package has this turned on by default. Here’s how you can get this working:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Follow the super easy Smidge &lt;a rel="noopener noreferrer" href="https://github.com/Shazwazza/Smidge#quick-start" target="_blank"&gt;quick start installation guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the Smidge.Nuglify package
&lt;div&gt;
&lt;div class="nuget-badge"&gt;
&lt;p&gt;&lt;code&gt;PM&amp;gt; Install-Package Smidge.Nuglify&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Add Smidge Nuglify to your services: &lt;code&gt;services.AddSmidgeNuglify();&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use Smidge Nuglify in your Configure method: &lt;code&gt;app.UseSmidgeNuglify();&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Replace JsMin  with Nuglify for the default pipeline:
&lt;pre&gt;&lt;code class="language-csharp"&gt;services.Configure(opt =&amp;gt;
{
    opt.PipelineFactory.OnCreateDefault = (type, pipeline) =&amp;gt; pipeline.Replace(opt.PipelineFactory);
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;That’s it! Nuglify is now the JS minifier for the default pipeline and will produce source maps. You can configure the Nuglify settings in the &lt;em&gt;AddSmidgeNuglify&lt;/em&gt; method.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now you can debug via the source maps in dev tools:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate/windows-live-writer-smidge-nuglify_9f43-image_4.png"&gt;&lt;img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;" src="https://shazwazza.com/media/articulate/windows-live-writer-smidge-nuglify_9f43-image_thumb_1.png" border="0" alt="image" title="image" width="600" height="350" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;File watching&lt;/h2&gt;
&lt;p&gt;Smidge can now watch your source files and if any changes are detected it can auto cache bust the bundle and flag for re-processing.&lt;/p&gt;
&lt;p&gt;Previous to version 2.0.0 if you were in release mode all of the bundling/minification would be active but you really just wanted to test this behavior but unfortunately it meant that if you updated a js/css file you would have to go bump the Smidge version in the config file to clear out the server side persistent cache. In 2.0.0, you can configure your bundle with different environment options for both Debug and Production. For example, perhaps in Debug mode you still want your bundles to be active so that the minification, combination, compression, etc… is still happening but you want to still actively edit files … you can easily do this! Here’s a nice fluent syntax to achieve this:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-csharp"&gt;bundles.CreateJs("my-application", "~/js/site.js", "~/js/app")
    .WithEnvironmentOptions(BundleEnvironmentOptions.Create()
        .ForDebug(builder =&amp;gt; builder
            .EnableCompositeProcessing()
            .EnableFileWatcher()
            .SetCacheBusterType())
        .Build()
    );
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For this example the “my-application” bundle will do the following when being rendered in debug:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Still process the files in the bundle and minify, combine, compress into a composite file&lt;/li&gt;
&lt;li&gt;Attach file watchers to all files in the bundle&lt;/li&gt;
&lt;li&gt;Change the cache buster for this bundle to only survive the lifespan of the current app domain&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And what’s cool is that if you edit any of the source files in this bundle it will auto cache bust to a new value and re-process the bundle when it’s next requested.&lt;/p&gt;
&lt;h2&gt;Debug vs Production?&lt;/h2&gt;
&lt;p&gt;There’s a few ways that you could render assets in either debug or production mode but this is probably the easiest and uses ASP.NET Core’s environment tag helpers. Notice the debug attribute on the script/link tags and that the src/href attributes just include the bundle name … this is using Smidge’s tag helpers to define which bundle to render and if it’s in debug mode.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-html"&gt;&amp;lt;environment names="Development"&amp;gt;
	&amp;lt;link rel="stylesheet" href="my-css" debug="true" /&amp;gt;
	&amp;lt;script src="my-js" debug="true"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/environment&amp;gt;

&amp;lt;environment names="Staging,Production"&amp;gt;
	&amp;lt;link rel="stylesheet" href="my-css" /&amp;gt;
	&amp;lt;script src="my-js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/environment&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Thanks!&lt;/h2&gt;
&lt;p&gt;Big thanks to &lt;a rel="noopener noreferrer" href="https://github.com/dazinator" target="_blank"&gt;@dazinator&lt;/a&gt; for all the help, recommendations, testing, feedback, etc… and for the rest of the community for filing bugs, questions, and comments. Much appreciated :)&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:27 Z</pubDate>
      <a10:updated>2023-03-23T15:08:27Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1269</guid>
      <link>https://shazwazza.com/post/introducing-smidge-an-aspnet-5-runtime-jscss-pre-processor/</link>
      <category>ASP.Net</category>
      <category>Web Development</category>
      <title>Introducing ‘Smidge’ – an ASP.NET 5 runtime JS/CSS pre-processor</title>
      <description>&lt;p&gt;During the past month I decided to dive deep into learning ASP.NET 5, and what better way to learn than to start a new OSS project :)&lt;/p&gt;
&lt;p&gt;I chose to make a new new simple and extensible Javascript/CSS &lt;span style="text-decoration: underline;"&gt;runtime&lt;/span&gt; pre-processor for ASP.NET 5. It does file minification, combination and compression, has a nice file caching layer and it’s all done in async operations. I ported over a few ideas and code snippets from &lt;a href="https://github.com/Shazwazza/ClientDependency/" target="_blank"&gt;CDF (client dependency framework)&lt;/a&gt; but with a more modern approach. I’ve called it ‘Smidge’ = &lt;em&gt;something really small&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/Shazwazza/Smidge" target="_blank"&gt;The project is on GitHub&lt;/a&gt;, it’s still a work in progress but its functional and there’s even some documentation! In the next few weeks I’ll get more of the code and docs updated and hopefully have a beta release out. In the meantime, you can clone the source, browse the code, build it and of course use it if you like.&lt;/p&gt;
&lt;h2&gt;Project details&lt;/h2&gt;
&lt;p&gt;It’s currently only targeting &lt;em&gt;aspnet50 &lt;/em&gt;and not the Core CLR… I didn’t start with Core CLR because there was some legacy code I had to port over and I wanted to get something up and working relatively quickly. It shouldn’t be too much work to convert to Core CLR and Mono, hopefully I’ll find time to do that soon. It’s referencing all of the beta-* libraries from the ASP.NET 5 nightly myget feeds since there’s some code I’m using that isn’t available in the current beta1 release (&lt;em&gt;like Microsoft.AspNet.WebUtilities.UriHelper&lt;/em&gt;). The target KRE version is currently &lt;em&gt;KRE-CLR-amd64 1.0.0-beta2-10760.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;p&gt;I’ve put up an Alpha 1 release on Nuget, so you can install it from there:&lt;/p&gt;
&lt;div class="nuget-badge"&gt;
&lt;p&gt;PM&amp;gt; Install-Package Smidge -Pre&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;There’s some &lt;a href="https://github.com/Shazwazza/Smidge/blob/master/README.md#install" target="_blank"&gt;installation instructions here&lt;/a&gt;, you’ll need to add the smidge.json file yourself for now, can’t figure out how to get VS 2015 (kpm pack) to package that up … more learning required!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;There’s certainly a lot of detective work involved in learning ASP.NET 5 but with the code being open source and browse-able/searchable on GitHub, it makes finding what you need fairly easy.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:15 Z</pubDate>
      <a10:updated>2023-03-23T15:08:15Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1232</guid>
      <link>https://shazwazza.com/post/using-aspnet5-optionsmodel/</link>
      <category>ASP.Net</category>
      <category>Web Development</category>
      <title>Using AspNet5 OptionsModel</title>
      <description>&lt;p&gt;If you’ve used AspNet5 then you’ve probably been using some MVC, in which case you’ve probably seen something like this in your Startup class:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Add MVC services to the services container&lt;/span&gt;
services.AddMvc(configuration)
    .Configure&amp;lt;MvcOptions&amp;gt;(options =&amp;gt;
    {
        &lt;span class="rem"&gt;//Configure some MVC options like customizing the &lt;/span&gt;
        &lt;span class="rem"&gt;// view engines, etc...&lt;/span&gt;
        options.ViewEngines.Insert(0, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(TestViewEngine));
    });&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;It turns out this syntax for specifying ‘options’ for a given service is a generic pattern that you can use in your own code. In fact the OptionsModel framework is it’s own code repository: &lt;a title="https://github.com/aspnet/Options" href="https://github.com/aspnet/Options"&gt;https://github.com/aspnet/Options&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I’ve implemented custom options in my AspNet5 project called &lt;a href="https://github.com/Shazwazza/smidge" target="_blank"&gt;Smidge&lt;/a&gt; (a runtime JavaScript/CSS pre-processing engine) and wanted to share the details since as far as I’ve seen there isn’t any documentation about this.&lt;/p&gt;
&lt;h2&gt;What are options?&lt;/h2&gt;
&lt;p&gt;Probably the simplest way to describe the options framework is that: Options allow you to configure your application via code during startup.&lt;/p&gt;
&lt;p&gt;Options are just a POCO class that can contain configuration options to customize the behavior of your library. These option classes can be injected into any of your services with IoC using an interface called &lt;em&gt;&lt;a href="https://github.com/aspnet/Options/blob/dev/src/Microsoft.Framework.OptionsModel/IOptions.cs" target="_blank"&gt;Microsoft.Framework.OptionsModel.IOptions&lt;/a&gt;&lt;/em&gt;. There’s a caveat to this POCO class however: It must contain an parameter-less/empty constructor which means you cannot have services injected into the your options class via it’s constructor.&amp;nbsp; This options framework also allows for ‘named’ options. So for example, perhaps you have a single options class that you would like to have configured in 2 different ways, one for ‘staging’ and one for your ‘live’ website.&lt;/p&gt;
&lt;h2&gt;Creating options&lt;/h2&gt;
&lt;p&gt;Here’s a really simple example of a POCO options class:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CustomMessageOptions
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; CustomMessage()
    {
        Message = &lt;span class="str"&gt;""&lt;/span&gt;;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Message { get; set; }
}&lt;/pre&gt;
&lt;p&gt;In order to use this options class you need to create an options configuration class. For example:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CustomMessageOptionsSetup : ConfigureOptions&amp;lt;CustomMessageOptions&amp;gt;
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; CustomMessageOptionsSetup() 
    : &lt;span class="kwrd"&gt;base&lt;/span&gt;(ConfigureMessageOptions)
    {
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// Set the default options&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ConfigureMessageOptions(CustomMessageOptions options)
    {
        options.Message = &lt;span class="str"&gt;"Hello world"&lt;/span&gt;;
    }
}&lt;/pre&gt;
&lt;p&gt;Then you need to add this class to your IoC container of type &lt;a href="https://github.com/aspnet/Options/blob/dev/src/Microsoft.Framework.OptionsModel/IConfigureOptions.cs" target="_blank"&gt;&lt;em&gt;Microsoft.Framework.OptionsModel.IConfigureOptions&lt;/em&gt;&lt;/a&gt;:&lt;/p&gt;&lt;pre class="csharpcode"&gt;services.AddTransient&amp;lt;IConfigureOptions&amp;lt;CustomMessageOptions&amp;gt;, CustomMessageOptionsSetup&amp;gt;();&lt;/pre&gt;
&lt;h2&gt;Using options&lt;/h2&gt;
&lt;p&gt;To configure your options during startup, you do so in the &lt;em&gt;ConfigureServices &lt;/em&gt;method like:&lt;/p&gt;&lt;pre class="csharpcode"&gt;services.Configure&amp;lt;CustomMessageOptions&amp;gt;(options =&amp;gt;
{
    options.Message = &lt;span class="str"&gt;"Hello there!"&lt;/span&gt;;
});&lt;/pre&gt;
&lt;p&gt;Now you can have these options injected into any of your services using the &lt;em&gt;IOptions&lt;/em&gt; interface noted previously:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MyCoolService 
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; MyCoolService(IOptions&amp;lt;CustomMessageOptions&amp;gt; messageOptions)
    {
        &lt;span class="rem"&gt;//IOptions exposes an 'Options' property which resolves an instance&lt;/span&gt;
        &lt;span class="rem"&gt;//of CustomMessageOptions&lt;/span&gt;
        ConfiguredMessage = messageOptions.Options.Message;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ConfiguredMessage {get; &lt;span class="kwrd"&gt;private&lt;/span&gt; set;}
}&lt;/pre&gt;
&lt;h2&gt;Named options&lt;/h2&gt;
&lt;p&gt;As an example, lets say that you want a different message configured for your ‘staging’ and ‘live’ websites. This can be done with named options, here’s an example:&lt;/p&gt;&lt;pre class="csharpcode"&gt;services
    .Configure&amp;lt;CustomMessageOptions&amp;gt;(options =&amp;gt;
    {
        options.Message = &lt;span class="str"&gt;"Hi! This is the staging site"&lt;/span&gt;;
    }, &lt;span class="str"&gt;"staging"&lt;/span&gt;)
    .Configure&amp;lt;CustomMessageOptions&amp;gt;(options =&amp;gt;
    {
        options.Message = &lt;span class="str"&gt;"Hi! This is the live site"&lt;/span&gt;;
    }, &lt;span class="str"&gt;"live"&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;Then in your service you can resolve the option instance by name:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MyCoolService 
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; MyCoolService(IOptions&amp;lt;CustomMessageOptions&amp;gt; messageOptions)
    {
        &lt;span class="rem"&gt;//IRL This value would probably be set via some environment variable&lt;/span&gt;
        var configEnvironment = &lt;span class="str"&gt;"staging"&lt;/span&gt;;

        &lt;span class="rem"&gt;//IOptions exposes an 'GetNamedOptions' method which resolves an instance&lt;/span&gt;
        &lt;span class="rem"&gt;//of CustomMessageOptions based on a defined named configuration&lt;/span&gt;
        ConfiguredMessage = messageOptions.GetNamedOptions(configEnvironment);
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ConfiguredMessage {get; &lt;span class="kwrd"&gt;private&lt;/span&gt; set;}
}&lt;/pre&gt;
&lt;h2&gt;Configuring options with other services&lt;/h2&gt;
&lt;p&gt;Since your options class is just a POCO object and must have a parameter-less/empty constructor, you cannot inject services into the options class. However, there is a way to use IoC services in your options classes by customizing the &lt;em&gt;ConfigureOptions&lt;/em&gt; class created above.&amp;nbsp; In many cases this won’t be necessary but this really depends on how you are using options.&amp;nbsp; As a (bad) example, lets say we wanted to expose a custom helper service called SiteHelper on the &lt;em&gt;CustomMessageOptions&lt;/em&gt; class that can be used by a developer to create the message. The end result syntax might look like:&lt;/p&gt;&lt;pre class="csharpcode"&gt;services.Configure&amp;lt;CustomMessageOptions&amp;gt;(options =&amp;gt;
    {
        var siteId = options.SiteHelper.GetSiteId();
        options.Message = &lt;span class="str"&gt;"Hi! This is the staging site with id: "&lt;/span&gt; + siteId;
    });&lt;/pre&gt;
&lt;p&gt;In order for that to work the &lt;em&gt;options.SiteHelper&lt;/em&gt; property needs to be initialized. This is done with the &lt;em&gt;CustomMessageOptionsSetup &lt;/em&gt;class (created above) which has been added to the IoC container, this means it can have other services injected into it. The resulting class would look like:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; CustomMessageOptionsSetup : ConfigureOptions&amp;lt;CustomMessageOptions&amp;gt;
{
    &lt;span class="rem"&gt;//SiteHelper gets injected via IoC&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; CustomMessageOptionsSetup(SiteHelper siteHelper) 
    : &lt;span class="kwrd"&gt;base&lt;/span&gt;(ConfigureMessageOptions)
    {
        SiteHelper = siteHelper;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; SiteHelper SiteHelper { get; &lt;span class="kwrd"&gt;private&lt;/span&gt; set; }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// Set the default options&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ConfigureMessageOptions(CustomMessageOptions options)
    {
        options.Message = &lt;span class="str"&gt;"Hello world"&lt;/span&gt;;
    }

    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
    &lt;span class="rem"&gt;/// Allows for configuring the options instance before options are set&lt;/span&gt;
    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Configure(Bundles options, &lt;span class="kwrd"&gt;string&lt;/span&gt; name = &lt;span class="str"&gt;""&lt;/span&gt;)
    {
        &lt;span class="rem"&gt;//Assign the site helper instance&lt;/span&gt;
        options.SiteHelper = SiteHelper;

        &lt;span class="kwrd"&gt;base&lt;/span&gt;.Configure(options, name);
    }
}&lt;/pre&gt;
&lt;p&gt;IRL to give you an example of why this might be useful, in my &lt;a href="https://github.com/Shazwazza/smidge" target="_blank"&gt;Smidge&lt;/a&gt; project I allow developers to create named JavaScript/CSS bundles during startup using options. In some cases a developer might want to manipulate the file processing pipeline for a given bundle and in that case they need access to a service called PreProcessPipelineFactory which needs to come from IoC. The usage might look like:&lt;/p&gt;&lt;pre class="csharpcode"&gt;services.AddSmidge()
    .Configure&amp;lt;Bundles&amp;gt;(bundles =&amp;gt;
    {                   
        bundles.Create(&lt;span class="str"&gt;"test-bundle-3"&lt;/span&gt;, 
            bundles.PipelineFactory.GetPipeline(
                &lt;span class="rem"&gt;//add as many processor types as you want&lt;/span&gt;
                &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(DotLess), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(JsMin)), 
            WebFileType.Js, 
            &lt;span class="str"&gt;"~/Js/Bundle2"&lt;/span&gt;);
    });&lt;/pre&gt;
&lt;p&gt;In the above, the bundles.PipelineFactory is a property on the bundles (options) class which gets initialized in my own &lt;em&gt;ConfigureOptions&lt;/em&gt; class.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hopefully this helps anyone looking to use custom options in their AspNet5 libraries!&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:15 Z</pubDate>
      <a10:updated>2023-03-23T15:08:15Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1329</guid>
      <link>https://shazwazza.com/post/petapoco-may-cause-high-memory-usage-with-certain-queries/</link>
      <category>ASP.Net</category>
      <category>Web Development</category>
      <title>PetaPoco may cause high memory usage with certain queries</title>
      <description>&lt;p&gt;If you are using &lt;a href="https://github.com/toptensoftware/PetaPoco" target="_blank"&gt;PetaPoco&lt;/a&gt;, or &lt;a href="https://github.com/schotime/NPoco" target="_blank"&gt;NPoco&lt;/a&gt; (&lt;em&gt;which seams to be the most up-to-date fork of the project&lt;/em&gt;), the title of this post might be a bit scary… but hopefully you won’t have to worry. This really depends on how you create your queries and how many different query structures you are executing.&lt;/p&gt;
&lt;h2&gt;High memory usage&lt;/h2&gt;
&lt;p&gt;Here is the code in relation to the memory growth when using PetaPoco:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/toptensoftware/PetaPoco/blob/master/PetaPoco/PetaPoco.cs#L1836" title="https://github.com/toptensoftware/PetaPoco/blob/master/PetaPoco/PetaPoco.cs#L1836"&gt;https://github.com/toptensoftware/PetaPoco/blob/master/PetaPoco/PetaPoco.cs#L1836&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What is happening here is that every time a POCO needs to be mapped from a data source, this will add more values to a static cache, specifically this one:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/toptensoftware/PetaPoco/blob/master/PetaPoco/PetaPoco.cs#L2126" title="https://github.com/toptensoftware/PetaPoco/blob/master/PetaPoco/PetaPoco.cs#L2126"&gt;https://github.com/toptensoftware/PetaPoco/blob/master/PetaPoco/PetaPoco.cs#L2126&lt;/a&gt;  (&lt;em&gt;m_PocoDatas&lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;This isn’t a bad thing… but it can be if you are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;using non-parameterized where clauses&lt;/li&gt;
&lt;li&gt;you have dynamically generated where clauses&lt;/li&gt;
&lt;li&gt;you use a lot of sql ‘IN’ clauses – since the items in the array being passed to the ‘IN’ clauses is dynamic&lt;/li&gt;
&lt;li&gt;you have tons of differently statically unique where clauses&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each time a unique SQL query is sent to PetaPoco it will store this SQL string and associate it to a delegate (which is also cached). Over time, as these unique SQL queries are executed, the internal static cache will grow. In some cases this could consume quite a lot of memory.&lt;/p&gt;
&lt;p&gt;The other thing to note is how large the ‘key’ that PetaPoco/NPoco uses:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;var key = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0}:{1}:{2}:{3}:{4}"&lt;/span&gt;, sql, connString, ForceDateTimesToUtc, firstColumn, countColumns);&lt;/pre&gt;
&lt;p&gt;Considering how many queries might be executing in your application, the storage for these keys alone could take up quite a lot of memory! An SQL statement combined with a connection string could be very long, and each of these combinations gets stored in memory for every unique SQL query executed that returns mapped POCO objects.&lt;/p&gt;
&lt;h2&gt;Parameterized queries vs. non-parameterized&lt;/h2&gt;
&lt;p&gt;Here’s some examples of why non-parameterized queries will cause lots of memory consumption. Lets say we have a simple query like:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;db.Query&amp;lt;MyTable&amp;gt;(&lt;span class="str"&gt;"WHERE MyColumn=@myValue"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; {myValue = &lt;span class="str"&gt;"test"&lt;/span&gt;})&lt;/pre&gt;
&lt;p&gt;Which results in this SQL:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; MyColumn = @myValue&lt;/pre&gt;
&lt;p&gt;This query can be used over and over again with a different value and PetaPoco will simply store a single SQL key in it’s internal cache. However, if you are executing queries without real parameters such as:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;db.Query&amp;lt;MyTable&amp;gt;(&lt;span class="str"&gt;"WHERE MyColumn='hello'"&lt;/span&gt;);
db.Query&amp;lt;MyTable&amp;gt;(&lt;span class="str"&gt;"WHERE MyColumn='world'"&lt;/span&gt;);
db.Query&amp;lt;MyTable&amp;gt;(&lt;span class="str"&gt;"WHERE MyColumn='hello world'"&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;Which results in this SQL:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; MyColumn = &lt;span class="str"&gt;'hello'&lt;/span&gt;;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; MyColumn = &lt;span class="str"&gt;'world'&lt;/span&gt;;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; MyColumn = &lt;span class="str"&gt;'hello world'&lt;/span&gt;;&lt;/pre&gt;
&lt;p&gt;Then PetaPoco will store each of these statements against a delegate in it’s internal cache since each of these string statements are not equal to each other.&lt;/p&gt;
&lt;p&gt;Depending on your application you still might have a very large number of unique parameterized queries, though I’d assume you’d have to have a terrifically huge amount for it to be a worry.&lt;/p&gt;
&lt;h2&gt;Order by queries&lt;/h2&gt;
&lt;p&gt;Unfortunately even if you use parameterized queries, PetaPoco will store the SQL query key with it’s &lt;em&gt;Order By&lt;/em&gt; clause which isn’t necessary and will again mean more duplicate SQL keys and delegates being tracked. For example if you have these resulting queries:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; MyColumn = @myValue &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; SomeField;
&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; * &lt;span class="kwrd"&gt;FROM&lt;/span&gt; MyTable &lt;span class="kwrd"&gt;WHERE&lt;/span&gt; MyColumn = @myValue &lt;span class="kwrd"&gt;ORDER&lt;/span&gt; &lt;span class="kwrd"&gt;BY&lt;/span&gt; AnotherField;&lt;/pre&gt;
&lt;p&gt;PetaPoco will store each of these statements in it’s internal cache separately since the strings don’t match, however the delegate that PetaPoco is storing against these SQL statements isn’t concerned about the ordering output, it’s only concerned about the column and table selection so in theory it should be stripping off the last &lt;em&gt;Order By &lt;/em&gt;clause&lt;em&gt; (and other irrelevant clauses) &lt;/em&gt;to avoid this duplication.&lt;/p&gt;
&lt;h2&gt;A slightly better implementation&lt;/h2&gt;
&lt;p&gt;First, if you are using PetaPoco/NPoco, you shouldn’t use dynamic queries for the point’s mentioned above. If you need this functionality then I suppose it might be worth these libraries adding some sort of property on the Database object or a parameter in either the Fetch or Query methods to specify that you don’t want to use the internal cache (this will be slower, but you won’t get unwanted memory growth). I’d really just suggest not using dynamically created where clauses ;-)&lt;/p&gt;
&lt;p&gt;Next, there’s a few things that could be fixed in the PetaPoco/NPoco core to manage memory a little better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The size the the key that is stored in memory doesn’t need to be that big. A better implementation would be to use a hash combiner class to combine the &lt;em&gt;GetHashCode&lt;/em&gt; result of each of those parameters that make up the key. This is a very fast way to create a hash of some strings that will result in a much smaller key. An example of a hash combiner class is here (which is actually inspired by the various internal hash code combiner classes in .Net): &lt;a href="https://github.com/umbraco/Umbraco-CMS/blob/7.2.0/src/Umbraco.Core/HashCodeCombiner.cs" title="https://github.com/umbraco/Umbraco-CMS/blob/7.2.0/src/Umbraco.Core/HashCodeCombiner.cs"&gt;&lt;em&gt;https://github.com/umbraco/Umbraco-CMS/blob/7.2.0/src/Umbraco.Core/HashCodeCombiner.cs&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Instead of storing all of this cache in static variables, have them stored in an &lt;em&gt;ObjectCache/MemoryCache (&lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.caching.objectcache(v=vs.110).aspx" title="http://msdn.microsoft.com/en-us/library/system.runtime.caching.objectcache(v=vs.110).aspx"&gt;&lt;em&gt;http://msdn.microsoft.com/en-us/library/system.runtime.caching.objectcache(v=vs.110).aspx&lt;/em&gt;&lt;/a&gt;&lt;em&gt;) with &lt;/em&gt;a sliding expiration so the memory can get collected when it’s unused&lt;/li&gt;
&lt;li&gt;The Order By clause should be ignored based on the point mentioned above&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I’ve created a PR for NPoco &lt;a href="https://github.com/schotime/NPoco/pull/134" target="_blank"&gt;here&lt;/a&gt;, and also created an issue on the original PetaPoco source &lt;a href="https://github.com/toptensoftware/PetaPoco/issues/185" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:15 Z</pubDate>
      <a10:updated>2023-03-23T15:08:15Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1300</guid>
      <link>https://shazwazza.com/post/a-problem-using-sifr-for-menus-that-link-to-databound-forms-in-ie7/</link>
      <category>Web Development</category>
      <title>A problem using sIFR for menus that link to databound forms in IE7</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;This is quite possibly the most interesting/annoying/crazy quirk/bug I have ever come across.&lt;/p&gt;&lt;h1&gt;Scenario&lt;/h1&gt;&lt;p&gt;Your site has a sIFR menu. One of the links goes to a typical databound form (in our case an update user details form). &lt;/p&gt;&lt;h1&gt;Problem &lt;br /&gt;&lt;/h1&gt;&lt;p&gt;The user modifies a field and submits. The database table shows the change. However, when you navigate back to the form using your sIFR menu link, you notice the old value(s) in the fields. The correct values only appear once you clear your cache. This problem only occurs in IE7.&lt;/p&gt;&lt;h1&gt;Reason &lt;br /&gt;&lt;/h1&gt;&lt;p&gt;It turns out that the sIFR link is not a normal link. It is essentially like hitting the enter key in the address bar of a page that is already loaded. The browser merely loads from its cache. No matter how many times you click that link!&lt;/p&gt;&lt;h1&gt;Solution &lt;br /&gt;&lt;/h1&gt;&lt;p&gt;In the code behind of your form on page load call this: &lt;/p&gt;&lt;p&gt;Response.Cache.SetCacheability(HttpCacheability.NoCache);&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1202</guid>
      <link>https://shazwazza.com/post/excluding-pages-with-url-rewriting/</link>
      <category>Web Development</category>
      <title>Excluding pages with URL Rewriting</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;Today we had a mini site which the promotion had completed, but the site was to stay live with a few of the content pages staying live for people who come to view it.&lt;/p&gt;  &lt;p&gt;Because the site was only a few pages there isn’t a CMS back-end, it’s just flat ASPX pages are stored in a single folder.    &lt;br /&gt;The problem is, that the pages which need to be available are also in the folder which the pages which are not longer accessible are.&lt;/p&gt;  &lt;p&gt;There is a few ways in which I can take &lt;em&gt;down&lt;/em&gt; the pages which people aren’t meant to access, firstly I could just delete them. That’d work, but that’d be a 404 error which isn’t really a good user experience (I could set the 404 redirect to be the home page, but the browser would still receive a 404 HTTP status).&lt;/p&gt;  &lt;p&gt;So the next option is URL Redirection, lets crack out our UrlRewriting.config file and set up a rule. We’ll start with a rule like this:&lt;/p&gt;  &lt;pre&gt;&amp;lt;add name=&amp;quot;RedirAllIndexedPagesToDefault&amp;quot; 
   virtualURL=&amp;quot;^(.*)/pages/(.*)&amp;quot; 
   destinationUrl=&amp;quot;$1/default.aspx&amp;quot; 
   redirectMode=&amp;quot;Permanent&amp;quot; 
   redirect=&amp;quot;Domain&amp;quot; 
   ignoreCase=&amp;quot;true&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;There, that’ll handle &lt;strong&gt;everything&lt;/strong&gt; in our pages folder, but it doesn’t help with the pages which I want accessible. Say the pages I want accessible are TermsAndConditions.aspx and PrivacyPolicy.aspx, but I don’t want Entry.aspx accessible. 

  &lt;br /&gt;It’s just a matter of modifying my &lt;strong&gt;virtualURL&lt;/strong&gt; to be a bit stricter, so now it looks like this:&lt;/p&gt;

&lt;pre&gt;&amp;lt;add name=&amp;quot;RedirAllIndexedPagesToDefault&amp;quot; 
   virtualURL=&amp;quot;^(.*)/pages/&lt;strong&gt;(?![TP.*])&lt;/strong&gt;(.*)&amp;quot; 
   destinationUrl=&amp;quot;$1/default.aspx&amp;quot; 
   redirectMode=&amp;quot;Permanent&amp;quot; 
   redirect=&amp;quot;Domain&amp;quot; 
   ignoreCase=&amp;quot;true&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;Now you’ll not be able to get to Entry.aspx, but the other two pages will still work just fine.&lt;/p&gt;

&lt;p&gt;Sure it’s not great if you’ve got lots of pages (and if you did have lots of pages I’d hope there was a CMS to deal with it), but it’s good for mini sites which you want some pages but not others in a folder accessible.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1203</guid>
      <link>https://shazwazza.com/post/tsql-case-statement-in-where-clause-for-not-in-or-in-filter/</link>
      <category>Web Development</category>
      <category>etc...</category>
      <category>Hosting</category>
      <category>Servers</category>
      <title>TSQL CASE statement in WHERE clause for NOT IN or IN filter</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;There’s a ton of articles out there on how to implement a case statement in a WHERE clause but couldn’t find one on how to implement a CASE statement in a WHERE clause that gives you the ability to use a NOT IN or IN filter. I guess the only way to explain this is to use an example, and I am fully aware that the use of this may not be the best practice and is most likely required because of poor database design/implementation but hey, when you inherit code, there’s really no other choice :)  &lt;p&gt;Suppose I have a stored proc that has an optional value:&lt;/p&gt; &lt;p&gt;@OnlyNonExported bit = 0&lt;/p&gt; &lt;p&gt;I want to return all items from MYTRANSACTIONS table if @OnlyNonExported&amp;nbsp; = 0, but if this value is 1 I want to return all items from MYTRANSACTIONS that have not been tracked in my TRACKEDTRANSACTIONS table. The original theory is to use a NOT IN clause to acheive the latter requirement:&lt;/p&gt;&lt;pre&gt;SELECT * FROM mytransactions m 
WHERE mytransactions.id NOT IN (SELECT id FROM trackedtransactions)&lt;/pre&gt;
&lt;p&gt;So if I wanted to use a case statement for this query, one would think you could do something like this:&lt;/p&gt;&lt;pre&gt;SELECT * FROM mytransactions m 
WHERE mytransactions.id NOT IN 
	CASE WHEN @OnlyNonExported = 0 
		THEN&amp;nbsp; (SELECT -1) 
		ELSE&amp;nbsp; (SELECT id FROM trackedtransactions) 
	END&lt;/pre&gt;
&lt;p&gt;But SQL doesn’t like this syntax and it turns out that you cannot use IN or NOT IN conditions with CASE statement in a WHERE clause, you can only use = or != conditions. So how do you achieve the above? Well the answer is even more dodgy that the above:&lt;/p&gt;&lt;pre&gt;SELECT * FROM mytransactions m 
WHERE mytransactions.id != 
	CASE WHEN @OnlyNonExported = 0 
		THEN&amp;nbsp; (SELECT -1) 
		ELSE&amp;nbsp; COALESCE((SELECT id FROM trackedtransactions t WHERE t.id = m.id), -1)
	END&lt;/pre&gt;
&lt;p&gt;So basically, when we want to return all transactions, return all rows where the id equals –1 (assuming that your IDs start at 1) and when we want to filter the results based on whether or not these IDs exist in another table, we only return rows who’s IDs don’t match the same ID in the tracked table. BUT if this ID doesn’t exist in the tracked table, then an empty result set is returned and the id won’t be matched against it, so we need a COALESCE function will will return a –1 value if there is an empty result set.&lt;/p&gt;
&lt;p&gt;Hopefully you’ll never have to use this but if you do, hope this saves you some headaches :)&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1210</guid>
      <link>https://shazwazza.com/post/super-easy-jquery-events/</link>
      <category>Web Development</category>
      <title>Super easy jQuery events</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;&lt;p&gt;I've been using &lt;a title="jQuery" href="http://www.jquery.com"&gt;jQuery &lt;/a&gt;for a while but haven't really been using it much in the form of building custom classes or libraries. I've been working on re-developing &lt;a title="Umbraco" href="http://www.umbraco.org"&gt;Umbraco&lt;/a&gt;'s JavaScript tree using &lt;a title="jsTree" href="http://www.jstree.com/"&gt;jsTree&lt;/a&gt; (which is great by the way!) and have been writing a JavaScript library to support it. As with most code libraries, events play an important role in writing clean and effective code. In the past I've always used simple callback methods for &amp;quot;event handling&amp;quot; in JavaScript, but this isn't really an event system since it doesn't allow more than one subscriber. After some quick research, jQuery has this all built into the core, and by adding a couple very simple methods to your JavaScript classes, they will instantly support an event model! &lt;/p&gt;  &lt;p&gt;Quick example:&amp;#160; &lt;/p&gt;  &lt;pre&gt;var myObject = {
	addEventHandler: function(fnName, fn) {
		$(this).bind(fnName, fn);
	},
	removeEventHandler: function(fnName, fn) {
		$(this).unbind(fnName, fn);
	},
	doSomething: function() {
		$.event.trigger(&amp;quot;somethingHappening&amp;quot;, [this, &amp;quot;myEventArgs&amp;quot;]);
	}
}&lt;/pre&gt;

&lt;p&gt;The above example is an object defining 2 functions to manage it's event model and another method which raises an event called &amp;quot;somethingHappened&amp;quot; with an array of arguments that will get bubbled to the event handlers. &lt;/p&gt;

&lt;p&gt;To subscribe to the events is easy: &lt;/p&gt;

&lt;pre&gt;function onSomethingHappening(EV, args) {
	alert(&amp;quot;something happened!&amp;quot;);
	alert(&amp;quot;sender: &amp;quot; + args[0]);
	alert(&amp;quot;e: &amp;quot; + args[1]);
}
//subscribe to the event:
myObject.addEventHandler(&amp;quot;somethingHappening&amp;quot;, onSomethingHappening);&lt;/pre&gt;

&lt;p&gt;You'll notice that the above event handler function has 2 arguments, one called &amp;quot;EV&amp;quot; and one called &amp;quot;args&amp;quot;. The EV parameters is the &lt;a title="jQuery Event Object" href="http://docs.jquery.com/Events/jQuery.Event"&gt;jQuery event object&lt;/a&gt; and the second one is the custom arguments object that was created when raising the event. &lt;/p&gt;

&lt;p&gt;Since Umbraco's admin section uses an iframe approach, i though that managing events between the iframes would be an issue since they are all using seperate jQuery instantiations, but by raising and consuming events with the above method, this is no problem. &lt;/p&gt;
&lt;a title="jQuery" href="http://www.jquery.com"&gt;&lt;img alt="" src="/image.axd?picture=2009%2f3%2flogo_jquery.png" /&gt;&lt;/a&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1173</guid>
      <link>https://shazwazza.com/post/jquery-vertical-align/</link>
      <category>Web Development</category>
      <title>jQuery Vertical Align</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;UPDATED! (2009-04-29) &lt;/p&gt;  &lt;p&gt;An easy way to vertical align elements with one line of code: &lt;/p&gt;  &lt;pre&gt;$('.innerText').VerticalAlign();&amp;#160; &lt;/pre&gt;

&lt;p&gt;&lt;em&gt;I've removed the parameters as it turns out if you pass in a negative offset using padding, IE6 throws an error and JavaScript fails to continue executing. If you get the following error in IE6 debugging, it may be due to passing in a negative value to a padding css attribute, or similar:&lt;/em&gt; &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;&lt;strong&gt;invalid argument jquery J[G]=K&lt;/strong&gt;&lt;/em&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;It's fairly easy to structure your html to not require a vertical align offset so it's really not needed anyways.&lt;/em&gt; 

  &lt;br /&gt;

  &lt;br /&gt;&lt;strike&gt;It also supports a couple of parameters:&lt;/strike&gt; 

  &lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strike&gt;offset = the number of pixels to offset the vertical alignment&lt;/strike&gt; 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strike&gt;usePadding = true/false. the default is false which uses a margin to align, if set to true, it uses padding &lt;/strike&gt;

    &lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;&lt;strike&gt;$('.innerText').VerticalAlign({offset:-20, usePadding:true})&lt;/strike&gt;&lt;/pre&gt;

&lt;p&gt;Get the source:&amp;#160; &lt;a href="/file.axd?file=2009%2f4%2fVerticalAlign.zip"&gt;VerticalAlign.zip (290.00 bytes)&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1158</guid>
      <link>https://shazwazza.com/post/testing-outgoing-smtp-emails-so-simple/</link>
      <category>Web Development</category>
      <category>etc...</category>
      <category>Hosting</category>
      <category>Servers</category>
      <title>Testing Outgoing SMTP Emails - So Simple!</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;At the &lt;a href="http://www.umbraco.org" target="_blank"&gt;Umbraco&lt;/a&gt; retreat before &lt;a href="http://www.codegarden09.com/" target="_blank"&gt;CodeGarden 09&lt;/a&gt; in Denmark, &lt;a href="http://www.aaron-powell.com/" target="_blank"&gt;Aaron&lt;/a&gt; had told me an extremely handy tip about testing outbound emails in your .Net applications. I'm not sure why I've never heard about this before and the funny thing is all of the .Net developers working in our office (including contractors) had never seen this before either! It's so incredibly simple and built into .Net, so if you don't know about this already you'll want to be using this in the future.&lt;/p&gt;  &lt;p&gt;If you application needs to send emails for whatever reason and you’re testing locally, you generally have to make sure that you're only sending emails to your address(es) so you’re not spamming a bunch of random people. This is an easy way to get around that and lets you view all of the emails sent. Just change (in our case add) a &lt;em&gt;deliveryMethod&lt;/em&gt; attribute to your &lt;em&gt;smtp&lt;/em&gt; settings to &lt;em&gt;SpecifiedPickupDirectory:&lt;/em&gt;&lt;/p&gt;  &lt;pre&gt;&amp;lt;system.net&amp;gt;
  &amp;lt;mailSettings&amp;gt;
    &amp;lt;smtp from=&amp;quot;noreply@localhost&amp;quot; deliveryMethod=&amp;quot;SpecifiedPickupDirectory&amp;quot;&amp;gt;
      &amp;lt;specifiedPickupDirectory pickupDirectoryLocation=&amp;quot;c:\maildrop&amp;quot; /&amp;gt;
    &amp;lt;/smtp&amp;gt;
  &amp;lt;/mailSettings&amp;gt;
&amp;lt;/system.net&amp;gt;&lt;/pre&gt;

&lt;p&gt;Now, all emails that are sent, just get saved to the specified folder and you can view them with Windows Live Mail, Outlook express, Thunderbird, or whatever.&lt;/p&gt;

&lt;p&gt;Nice!! &lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1164</guid>
      <link>https://shazwazza.com/post/styling-xml-with-css/</link>
      <category>Web Development</category>
      <title>Styling XML with CSS</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;I’m sure you’ve heard of XSLT (DON'T GO AWAY I'M NOT SUPPORTING XSLT!). XSLT is used to transform XML into different XML – for example, rendering XML as HTML.&amp;nbsp; An example:  &lt;h2&gt;The XSLT method&lt;/h2&gt;&lt;pre&gt;&amp;lt;album&amp;gt;
	&amp;lt;title&amp;gt;Funkentelechy Vs. The Placebo Syndrome&amp;lt;/title&amp;gt;
	&amp;lt;artist&amp;gt;Parliament&amp;lt;/artist&amp;gt; 
	&amp;lt;year&amp;gt;1976&amp;lt;/year&amp;gt; 
	&amp;lt;funkativity&amp;gt;10&amp;lt;/funkativity&amp;gt; 
&amp;lt;/album&amp;gt;
&lt;/pre&gt;
&lt;p&gt;can be transformed (using XSLT) to this:&lt;/p&gt;&lt;pre&gt;&amp;lt;div class="album"&amp;gt;
	&amp;lt;h1&amp;gt;Funkentelechy Vs. The Placebo Syndrome&amp;lt;/h1&amp;gt;
	&amp;lt;p class="artist"&amp;gt;Parliament&amp;lt;/p&amp;gt;
	&amp;lt;p class="year"&amp;gt;1976&amp;lt;/p&amp;gt;
	&amp;lt;p class="funkativity"&amp;gt;This album has a funkativity rating of 10/10&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Now the question is, "is &lt;code&gt;h1&lt;/code&gt; a better tagname for the artist of the album than &lt;code&gt;artist&lt;/code&gt;?". I'm pretty sure the answer is no. However, the HTML engine has no idea how to display an &lt;code&gt;artist&lt;/code&gt; tag - it treats every unknown tag like a &lt;code&gt;span&lt;/code&gt; tag.&lt;/p&gt;
&lt;h2&gt;The pure CSS method&lt;/h2&gt;
&lt;p&gt;So display information has to come from somewhere else. Some people may find the idea of markup depending entirely on CSS for display abhorrent. I do not. I maintain that reading the source of the &lt;code&gt;album&lt;/code&gt; XML block makes just as much sense as reading the rendered HTML version. And screenreaders...if I was a screenreader I'd want concise and descriptive XML, rather than having to wade through a bunch of HTML crap. And let's be real: everyone's web client supports CSS.&lt;/p&gt;
&lt;p&gt;Styling XML with CSS is actually very simple and very robust. The first thing to understand is that HTML is just a custom &lt;a href="http://www.w3.org/TR/REC-xml-names/#scoping-defaulting" target="_blank"&gt;namespace&lt;/a&gt; of XML. The second thing to understand is you can have multiple namespaces present in any XML document. That means you can use both HTML and, say, a custom namespace...which you can define and set styling rules.&lt;/p&gt;
&lt;p&gt;I won't blather much more. I'll just fill you in on how &lt;a href="http://www.w3.org/TR/css3-namespace/#declaration" target="_blank"&gt;CSS targets namespaces&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;The CSS @namespace declaration&lt;/h3&gt;
&lt;p&gt;In short, I can write up a stylesheet which targets a specific namespace and only a specific namespace. My XML file would look like this:&lt;/p&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" ?&amp;gt;
&amp;lt;albums xmlns="http://jdiacono.org/music"&amp;gt;
	&amp;lt;album&amp;gt;
		&amp;lt;title&amp;gt;Funkentelechy Vs. The Placebo Syndrome&amp;lt;/title&amp;gt;
		&amp;lt;artist&amp;gt;Parliament&amp;lt;/artist&amp;gt; 
		&amp;lt;year&amp;gt;1976&amp;lt;/year&amp;gt; 
		&amp;lt;funkativity&amp;gt;10&amp;lt;/funkativity&amp;gt; 
	&amp;lt;/album&amp;gt;
&amp;lt;albums&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Here I declare that the XML inside and including the &lt;code&gt;albums&lt;/code&gt; block is of the namespace &lt;code&gt;http://jdiacono.org/music&lt;/code&gt;. Don't be misled by the namespace looking like a URL...I haven't even registered &lt;strong&gt;jdiacono.org&lt;/strong&gt; and this is still valid. This is because namespaces are actually just unique, case-sensitive strings, and URLs tend to be unique and full of information. Let it be known that this block is &lt;em&gt;all there is&lt;/em&gt;. It is a completely self descriptive block of pure data, which references nothing external.&lt;/p&gt;
&lt;p&gt;Now to style this...here is my CSS:&lt;/p&gt;&lt;pre&gt;@namespace url("http://jdiacono.org/music");

albums {
	display:block;
	}
	
album {
	display:list-item;
	list-style-type:decimal;
	margin-bottom:0.5em;
	padding:0.5em;
	border:1px solid;
	}
	
album title {
	display:block;
	font-size:2em;
	font-weight:bold;
	border-bottom:1px dashed;
	}
	
album artist {
	display:block;
	font-size:0.9em;
	}
	
album year {
	display:block;
	font-weight:bold;
	letter-spacing:0.4em;
	color:Green;
	}
	
album funkativity {
	display:block;
	font-style:italic;
	}
	
album funkativity:before {
	content: "This album has a funkativity rating of ";
	}
	
album funkativity:after {
	content: "/10";
	}
&lt;/pre&gt;
&lt;p&gt;Now I have another example that is much more nourishing, which uses HTML and a custom XML namespace in the same page. You will need a browser other than IE to view this.&lt;/p&gt;
&lt;p&gt;&lt;a href="/sourcecode/sourcecode/cssNamespaces/cssNamespaces.xml" target="_blank"&gt;farmcode.org/sourcecode/sourcecode/cssNamespaces/cssNamespaces.xml&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;UPDATE: &lt;a href="http://ie.microsoft.com/testdrive/"&gt;Looks like IE9 is supporting this!&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1244</guid>
      <link>https://shazwazza.com/post/jquery-popup-bubble-extension/</link>
      <category>Web Development</category>
      <title>jQuery popup bubble extension</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;UPDATED (2009-05-25)! &lt;/p&gt; &lt;p&gt;Here's a quick and extensible framework to enable popup windows, popup bubbles, or popup anything. Currently the framework doesn't create extra DOM elements or style anything differently. It relies on the developer to create the DOM element that will be the popup bubble (or whatever). This extension give you the flexibility to bind any number of events to show or hide the bubble. It also supports having the bubble hide on a timer and comes with a complete event model allowing you to intercept the hide and show bubble events (and cancel them if needed) and fire your own methods upon completion. &lt;/p&gt; &lt;p&gt;I've included a full demo html page to demonstrate some different implementations. &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Here's the code: &lt;a href="/file.axd?file=2009%2f5%2fAlertBubble.zip"&gt;AlertBubble.zip (20.74 kb)&lt;/a&gt; &lt;/li&gt; &lt;li&gt;Here's a &lt;a href="/sourcecode/sourcecode/jquerypopupbubble/AlertBubble.htm" target="_blank"&gt;demo&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Here's an example of the usage: &lt;/p&gt;&lt;pre&gt;$(".bubble").AlertBubble(
{
	fadeTime: 500,
	hideEvent: [
		{selector: $("#hideButton"), event: "click"}
	],
	showEvent: [
		{selector: $("#showButton"), event: "click"}
	],
	showOnStart: true,
	text: "I am a bubble",
	hideTimer:2000
});
&lt;/pre&gt;The above code turns the elements with the class of .bubble into an AlertBubble. The parameters passed in are the parameters that are supported by this class: &lt;br&gt;
&lt;ul&gt;
&lt;li&gt;fadeTime: the milliseconds to fade in/out. Default = 200&amp;nbsp; &lt;li&gt;text: the text to show in the html element. If set to false (by default) it will use the markup that currently exists in the element. 
&lt;li&gt;hideEvent/showEvent 
&lt;ul&gt;
&lt;li&gt;Allows you to add/remove as many event handlers to show or hide the alert bubble &lt;/li&gt;&lt;/ul&gt;
&lt;li&gt;showOnStart: if the bubble should show on page load or only when showOnStart exists 
&lt;li&gt;hideTimer: If set, then the bubble will hide after the set number of milliseconds after shown. Default is false. 
&lt;li&gt;onBeforeShowCallback: a function to call before the bubble is shown. If a callback is specified, it must return true for the code to proceed to show the bubble. 
&lt;li&gt;onBeforeHideCallback: a function to call before the bubble is hidden. If a callback is specified, it must return true for the code to proceed to hide the bubble. 
&lt;li&gt;onAfterShowCallback: a function to call after the bubble is shown. 
&lt;li&gt;onAfterHideCallback: a function to call after the bubble is hidden. &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The extension also has a simple API that can be accessed to show/hide the bubble on demand as well as using events. This is done by storing the API object for the popup bubble extension in the jQuery data object for the popup bubble selector. &lt;/p&gt;
&lt;p&gt;API methods: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;showBubble() 
&lt;li&gt;hideBubble() &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;To access the API, you can retrieve it from the jQuery data object with the key "AlertBubble": &lt;/p&gt;&lt;pre&gt;var api = $(".myselector").data("AlertBubble"); 
&lt;/pre&gt;
&lt;p&gt;Example: &lt;/p&gt;&lt;pre&gt;$(".bubble").each(function() {
	var api = $(this).data("AlertBubble");
	if (api != null) {
		api.hideBubble();
	}
});
&lt;/pre&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1246</guid>
      <link>https://shazwazza.com/post/wildcard-mapping-in-iis-7-classic-pipeline-webconfig/</link>
      <category>Web Development</category>
      <category>etc...</category>
      <category>Hosting</category>
      <category>Servers</category>
      <title>Wildcard mapping in IIS 7 classic pipeline = web.config!</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;After foolishly pulling out my hair trying to find out why my wildcard mapping was disappearing in IIS 7 using classic pipeline mode, i realized it was my own fault!! I followed the instructions on this site: &lt;a title="http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/" href="http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/"&gt;http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/&lt;/a&gt; and unfortunately just skipped over the message about how this modifies your web.config… oops! So basically, every time I deployed my handler mapping would be removed… Doh!&lt;/p&gt;  &lt;p&gt;Unfortunately, the method to add a wildcard mapping in this article will actually remove the inheritance of standard handlers from the root of IIS and your machine.config and just make copies of them. This might not be the best approach, but i suppose sometimes it’s necessary. We only need the wildcard mapping for URL Rewriting so i decided to see if i could just simply add the isapi wildcard mapping only, have the rest of the handlers inherit from the root and see if it works… turns out it does!&lt;/p&gt;  &lt;p&gt;So instead of having to modify IIS itself, i just needed to add this to my web.config:&lt;/p&gt;  &lt;pre&gt;&amp;lt;handlers&amp;gt;
	&amp;lt;remove name=&amp;quot;ASP.Net-ISAPI-Wildcard&amp;quot; /&amp;gt;
	&amp;lt;add name=&amp;quot;ASP.Net-ISAPI-Wildcard&amp;quot; path=&amp;quot;*&amp;quot;
	verb=&amp;quot;*&amp;quot; type=&amp;quot;&amp;quot; modules=&amp;quot;IsapiModule&amp;quot;
	scriptProcessor=&amp;quot;C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll&amp;quot;
	resourceType=&amp;quot;Unspecified&amp;quot;
	requireAccess=&amp;quot;None&amp;quot;
	allowPathInfo=&amp;quot;false&amp;quot;
	preCondition=&amp;quot;classicMode,runtimeVersionv2.0,bitness64&amp;quot;
	responseBufferLimit=&amp;quot;4194304&amp;quot; /&amp;gt;
&amp;lt;/handlers&amp;gt;&lt;/pre&gt;

&lt;p&gt;Too easy! No fussing around with IIS and now at least i won’t override my changes accidentally.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1249</guid>
      <link>https://shazwazza.com/post/sifr-vs-cufon-text-replacement-and-you/</link>
      <category>Web Development</category>
      <title>sIFR vs. cufón: Text replacement and you</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;There are two reasons I use dynamic text replacement:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Plain text in a browser window is never as smooth as it is in the design (except in Safari),&lt;/li&gt;
&lt;li&gt;The designs I'm given almost always use fancy (non-&lt;a href="http://web.mit.edu/jmorzins/www/fonts.html"&gt;web based&lt;/a&gt;) fonts for headings, intro text etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Currently I subscribe to two solutions, both client-side: &lt;a href="http://www.mikeindustries.com/blog/sifr"&gt;sIFR&lt;/a&gt; and  &lt;a href="http://wiki.github.com/sorccu/cufon"&gt;cuf&amp;oacute;n&lt;/a&gt;.  If you want a quick answer to "what should I use?" then here it is: if you want replacement for long sentences and headings, use sIFR.  If you want replacement for a few words on a button or in a menu, use cuf&amp;oacute;n.  If you want to know more, read on...&lt;/p&gt;
&lt;h2&gt;&lt;a href="http://www.mikeindustries.com/blog/sifr"&gt;sIFR&lt;/a&gt;&lt;/h2&gt;
&lt;h3&gt;How sIFR works&lt;/h3&gt;
&lt;p&gt;sIFR uses javascript to dynamically embed a Flash object in the place of specified HTML text elements.  The Flash object is essentially an empty SWF (compiled Flash file) which includes the characters of the font you want to use.  When javascript embeds the SWF in the HTML, it passes the SWF arguments such as text-content, font-size, color, rollover behaviour and many more.  Some of these properties javascript takes from the CSS applied to the text, and some are overridden by &lt;code&gt;sifr-config.js&lt;/code&gt;, which is a human-readable config file containing additional formatting tweaks.&lt;/p&gt;
&lt;h3&gt;How to use sIFR&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://dev.novemberborn.net/sifr3/nightlies/"&gt;Download the source&lt;/a&gt; (only &lt;code&gt;sifr.js&lt;/code&gt;, &lt;code&gt;sifr-config.js&lt;/code&gt; and &lt;code&gt;sifr.css&lt;/code&gt; are actually needed).&lt;/li&gt;
&lt;li&gt;Generate a font SWF from a True Type Font file.  You can do this manually with Adobe Flash (like &lt;a href="http://wiki.novemberborn.net/sifr3/How+to+use"&gt;this&lt;/a&gt;) but it is easier to use &lt;a href="http://www.sifrgenerator.com/wizard.html"&gt;this online generation tool&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Link to &lt;code&gt;sifr.css&lt;/code&gt; in the head of your HTML page.&lt;/li&gt;
&lt;li&gt;Link to both scripts in the head of your HTML page, first &lt;code&gt;sifr.js&lt;/code&gt;, then &lt;code&gt;sifr-config.js&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Edit &lt;code&gt;sifr-config.js&lt;/code&gt; to read in the font SWF you created and use CSS selector syntax to select the HTML text elements you want to replace.&lt;/li&gt;
&lt;li&gt;Tweak away in &lt;code&gt;sifr-config.js&lt;/code&gt; until the text looks right when sIFR is both enabled and disabled, in case the user is missing Flash (iPhones don't have Flash as of early 2010!).&lt;/li&gt;
&lt;/ol&gt; 
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.mikeindustries.com/blog/sifr"&gt;sIFR 2.07&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://wiki.novemberborn.net/sifr3/"&gt;sIFR 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;a href="http://wiki.github.com/sorccu/cufon"&gt;cuf&amp;oacute;n&lt;/a&gt;&lt;/h2&gt;
&lt;h3&gt;How cuf&amp;oacute;n works&lt;/h3&gt;
&lt;p&gt;cuf&amp;oacute;n is entirely javascript and works in all major browsers (including IE6).  You still need to generate a font file, but this is output to a javascript file similar in size to the equivalent sIFR SWF font file.  cuf&amp;oacute;n looks at selected blocks of text and replaces each word with a dynamically generated image (using the HTML &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; tag), or in IE's case, a VML object (&lt;a href="http://en.wikipedia.org/wiki/Vector_Markup_Language"&gt;Vector Markup Language&lt;/a&gt;).  As a consquence of this, increasing the text size of the page either doesn't affect cuf&amp;oacute;n-replaced text or expands the image, blurring it.  Except in IE, which scales the text perfectly.&lt;/p&gt;
&lt;h3&gt;How to use cuf&amp;oacute;n&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Download the source (all you need is &lt;code&gt;&lt;a href="http://cufon.shoqolate.com/js/cufon-yui.js"&gt;cufon-yui.js&lt;/a&gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Generate a font file from a True Type Font.  You are unfortunately dependent on &lt;a href="http://cufon.shoqolate.com/generate/"&gt;this online generator&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Link to &lt;code&gt;cufon-yui.js&lt;/code&gt; in the head of your HTML page.  Beneath it, link to any font files you've generated.&lt;/li&gt;
&lt;li&gt;You may also want to create another file, &lt;code&gt;cufon-config.js&lt;/code&gt;, to hold selector information much the same way as &lt;code&gt;sifr-config.js&lt;/code&gt; does.&lt;/li&gt;
&lt;li&gt;Populate &lt;code&gt;cufon-config.js&lt;/code&gt; with what HTML text elements you want to replace.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Legality&lt;/h2&gt;
&lt;p&gt;Font foundaries are seemingly run by people who are very freaked out that their fonts are going to leak for free.  Hence, the vast majority of fonts can't legally be embedded directly into the CSS (what, you didn't know about that?  It's been around a while in some form or another - the &lt;a href="http://www.w3.org/TR/css3-fonts/#the-font-face-rule"&gt;@font-face&lt;/a&gt; directive allows you to supply the font file for obscure font-families - but it's only legal with open source fonts).&lt;/p&gt;
&lt;p&gt;Because sIFR uses Flash, and Adobe has a cordial agreement with the font foundaries in Switzerland (or wherever) which allows anyone to embed pretty much any font in a .swf, sIFR is totally legal.  cuf&amp;oacute;n... cuf&amp;oacute;n not so much.  Although both supply a compiled/obfuscated font resource in &lt;code&gt;.swf&lt;/code&gt;/&lt;code&gt;.js&lt;/code&gt; format respectively, and are basically the same from the font foundaries' point of view, they haven't got around to adding "Allows embedding using javascript methods" to their fonts' terms of use agreements.  And I wouldn't count on it...&lt;/p&gt;
&lt;p&gt;So in short, use cuf&amp;oacute;n. Go on, it's young and fresh and rad!  Push the font foundaries to legalise it!  But remember: you read that in a blog post...I'm not going to be your lawyer if they come after you.&lt;/p&gt;
&lt;h2&gt;Comparison&lt;/h2&gt;
&lt;table border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;sIFR&lt;/th&gt; &lt;th&gt;cuf&amp;oacute;n&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Core file-size (not including fonts)&lt;/td&gt;
&lt;td&gt;30KB&lt;/td&gt;
&lt;td&gt;18KB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent of Flash&lt;/td&gt;
&lt;td&gt;&amp;times;&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resizes nicely&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;td&gt;&amp;times;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cursor-selectable text&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;td&gt;&amp;times;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Doesn't flicker on load&lt;/td&gt;
&lt;td&gt;&amp;times;&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Independent of online font-generator&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;td&gt;&amp;times;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Online font-generator supports Open fonts (.otf)&lt;/td&gt;
&lt;td&gt;&amp;times;&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supported in all browsers&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Degrades gracefully&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Legal&lt;/td&gt;
&lt;td&gt;&amp;radic;&lt;/td&gt;
&lt;td&gt;&amp;times;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1313</guid>
      <link>https://shazwazza.com/post/jquery-fade-bug-in-ie-background-transparent-png-image/</link>
      <category>Web Development</category>
      <title>jQuery fade bug in IE – background transparent PNG image</title>
      <description>&lt;div class="imported-post"&gt;This post was imported from FARMCode.org which has been discontinued. These posts now exist here as an archive. They may contain broken links and images.&lt;/div&gt;&lt;p&gt;&lt;em&gt;&lt;strong&gt;(I’ve found a ‘solution’ to this… see bottom of post)&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;Problem&lt;/h2&gt;  &lt;p&gt;I’ve been trying to figure this out for the whole day today and have finally succumbed to the realization that I’m pretty sure I’ve found a bug in jQuery, even the latest version.&lt;/p&gt;  &lt;p&gt;The example link is below. The mark-up is very simple and all that is being done is:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Create a box with a single pixel semi transparent PNG image &lt;/li&gt;    &lt;li&gt;Call either fadeIn or fadeOut on any HTML element on the page… suddenly (and strangely) the box magically has a semi transparent gradient on it! &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So if anyone out there know how to fix this, I’m all ears. I’m about to go searching on the net for an alternative fade in/fade out library that doesn’t produce these results but would obviously like to just use the built in jQuery methods.&lt;/p&gt;  &lt;p&gt;&lt;a href="/jqueryfadebug/PNGTest.html" target="_blank"&gt;Click here to see the bug and source!&lt;/a&gt; (You’ll have to view in IE 7/8 to see the bug)&lt;/p&gt;  &lt;p&gt;Before fade out on the black box:&lt;/p&gt;  &lt;p&gt;&lt;a href="/image.axd?picture=WindowsLiveWriter/jQueryfadebuginIEbackgroundtransparentPN/7B4070A7/image.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/image.axd?picture=WindowsLiveWriter/jQueryfadebuginIEbackgroundtransparentPN/2B1B1269/image_thumb.png" width="109" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After fade out on the black box:&lt;/p&gt;  &lt;p&gt;&lt;a href="/image.axd?picture=WindowsLiveWriter/jQueryfadebuginIEbackgroundtransparentPN/0B0005AC/image.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/image.axd?picture=WindowsLiveWriter/jQueryfadebuginIEbackgroundtransparentPN/7D4D49A3/image_thumb.png" width="117" height="164" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;VERY STRANGE!!!!&lt;/p&gt;  &lt;h2&gt;Solution&lt;/h2&gt;  &lt;p&gt;I knew this had to be an issue with IE’s stupid DXImage transform stuff but didn’t really want to go down the route of fiddling with it but in the end, had to do it. And also had to add a stupid little hack to target IE directly.&lt;/p&gt;  &lt;h3&gt;Step 1:&lt;/h3&gt;  &lt;p&gt;Create a IE conditional div wrapper around everything under body:&lt;/p&gt;  &lt;p&gt;&amp;lt;!--[if IE]&amp;gt;&amp;lt;div id=&amp;quot;ieWrap&amp;quot;&amp;gt;&amp;lt;![endif]—&amp;gt;&lt;/p&gt;  &lt;p&gt;(the rest of the page html goes here)&lt;/p&gt;  &lt;p&gt;&amp;lt;!--[if IE]&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;![endif]—&amp;gt; &lt;/p&gt;  &lt;h3&gt;Step 2:&lt;/h3&gt;  &lt;p&gt;Target the elements in CSS for IE that have the background PNG transparent image:&lt;/p&gt;  &lt;pre&gt;#ieWrap .productView .productThumbnail a
{
	background-image: none;
	filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='grey_overlay.png',sizingMethod='scale');
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="/jqueryfadebug/PNGTest2.html" target="_blank"&gt;Click here for solution&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, a day later i found out this isn’t working as expected in IE 7… great… so figured out i had to add: width:100% to the style with the DXImageTransform. &lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1323</guid>
      <link>https://shazwazza.com/post/using-an-iphone-with-the-visual-studio-development-server-charles/</link>
      <category>Web Development</category>
      <title>Using an iPhone with the Visual Studio development server &amp; Charles</title>
      <description>&lt;p&gt;&lt;a href="http://encosia.com"&gt;Dave Ward&lt;/a&gt; did a good post recently on how to use the &lt;a href="http://encosia.com/2010/06/10/using-an-iphone-with-the-visual-studio-development-server/"&gt;Visual Studio development server from a mobile devise such as an iPhone&lt;/a&gt;. But there’s a problem for us here, we use &lt;a href="http://www.charlesproxy.com/"&gt;Charles&lt;/a&gt; which I have found to be a better than Fiddler (it’s also cross-platform so I can use it both on my Mac and Windows machines).&lt;/p&gt; &lt;p&gt;So after reading Dave’s post I decided to have a look at how to do it if you’re using Charles, and well it’s pretty darn simple.&lt;/p&gt; &lt;p&gt;I’d suggest that you read Dave’s post first as I’m going to assume that you have, I’m just going to point out what you need to do different for Charles.&lt;/p&gt; &lt;h2&gt;Charles Configuration&lt;/h2&gt; &lt;p&gt;The first thing you need to do is find out on what port Charles is running on, by default Charles is on port &lt;strong&gt;8888&lt;/strong&gt;, but you can find the settings under &lt;em&gt;Proxy &amp;gt; Proxy Settings&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="/image.axd?picture=charles-proxy-config.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="charles-proxy-config" border="0" alt="charles-proxy-config" src="/image.axd?picture=charles-proxy-config_thumb.png" width="573" height="531"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Next we need to configure the external access to the HTTP Proxy that Charles is running. This is something that Charles handles differently to Fiddler, it’s actually a lot more configurable as you can define individual IP’s or IP ranges for access.&lt;/p&gt; &lt;p&gt;To do this you need to navigate to &lt;em&gt;Proxy &amp;gt; Access Control Settings&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="/image.axd?picture=charles-access-control.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="charles-access-control" border="0" alt="charles-access-control" src="/image.axd?picture=charles-access-control_thumb.png" width="559" height="517"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Then you just need to click &lt;strong&gt;Add&lt;/strong&gt; and enter the IP (or range) which you want to allow access to. I’ve just allowed access to the IP of my iPhone, which is &lt;strong&gt;192.168.1.44&lt;/strong&gt;. &lt;/p&gt; &lt;h2&gt;&lt;/h2&gt;  &lt;h2&gt;Conclusion&lt;/h2&gt; &lt;p&gt;The rest of Dave’s post is all you need to get this working, you connect to your computer from your external device in just the same way.&lt;/p&gt; &lt;p&gt;Hopefully this helps you out if you’re not a Fiddler user but want to be able to use a mobile device with Visual Studio’s development server.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1325</guid>
      <link>https://shazwazza.com/post/css3-using-the-fun-stuff-in-real-life/</link>
      <category>Web Development</category>
      <title>CSS3: Using the fun stuff in real life</title>
      <description>&lt;h2&gt;Sweep IE6 under the carpet&lt;/h2&gt; &lt;p&gt;Do whatever you can to remove IE6 support from your website’s build spec. Proper CSS selectors like the direct child (&lt;code&gt;ul &amp;gt; li&lt;/code&gt;), the &lt;code&gt;:hover&lt;/code&gt; state for elements other than anchors, and attribute selectors (&lt;code&gt;a[href*=”http://”]&lt;/code&gt;)&amp;nbsp; &lt;strong&gt;do not work &lt;/strong&gt;in IE6. Then, add &lt;a href="http://ie6update.com/"&gt;ie6update&lt;/a&gt;in a &lt;a href="http://www.quirksmode.org/css/condcom.html"&gt;conditional comment&lt;/a&gt; and voila! IE6 users see a totally legit looking alert bar across the top of their screen telling them that the page below looks horrible because they have an old browser and need to upgrade. Now you are ready to begin.&lt;/p&gt; &lt;h2&gt;CSS3 is only sort of supported&lt;/h2&gt; &lt;p&gt;&lt;a href="http://www.css3.info/preview/"&gt;CSS3&lt;/a&gt; is currently a &lt;a href="http://www.w3.org/TR/css3-roadmap/"&gt;working draft&lt;/a&gt;. Microsoft hence decided to implement barely any of its features in IE8, and as a result your CSS3 magic is restricted to ‘modern’ (real) rendering engines, like &lt;a href="http://webkit.org/"&gt;WebKit&lt;/a&gt; (Google Chrome, Safari) and &lt;a href="https://developer.mozilla.org/en/Gecko"&gt;Gecko&lt;/a&gt; (Firefox). However, the developers of these engines understand that CSS3 is a draft and as such the interface can be changed without warning. As a safeguard they apply a prefix to the drafted properties they want to support. These are known as:&lt;/p&gt; &lt;h3&gt;&lt;a href="http://www.w3.org/TR/CSS2/syndata.html#vendor-keywords"&gt;Vendor-specific extensions&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;If you’ve ever seen anything like &lt;code&gt;-moz-border-radius: 6px;&lt;/code&gt; you know what I mean. Vendor-specific extensions are a standardised and accepted (however &lt;a href="http://www.css3.info/vendor-specific-extensions-to-css3/"&gt;occasionally non-validating&lt;/a&gt;) way of implementing future rules without fear of breaking anything. If you want to use CSS3 properties you will most likely have to include the same property with a prefix right after (excepting the few properties like &lt;code&gt;opacity&lt;/code&gt; and &lt;code&gt;border-radius&lt;/code&gt;). Your rules will look something like this:&lt;/p&gt;&lt;pre&gt;.box {
	-webkit-box-shadow:2px 2px 5px gray;
	-moz-box-shadow:2px 2px 5px gray;
	box-shadow:2px 2px 5px gray;
	}&lt;/pre&gt;
&lt;p&gt;I know that hurts, but at least your repitition of code is localised.&amp;nbsp; And it is future-friendly – as browsers start supporting CSS3 your advanced styles will begin to appear!&amp;nbsp; A shadow on a header here, a rounded corner there, an opacity somewhere. Patience.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;You’ll notice there’s no &lt;code&gt;-ie-border-radius&lt;/code&gt; property above. This is very sad. This leads us to our next restriction in using CSS3:&lt;/p&gt;
&lt;h3&gt;Don't force a design&lt;/h3&gt;
&lt;p&gt;Think about it - why must the design for a site look the same in IE as Chrome? What if they looked different? Someone who sees the site in IE is not going to know what they're missing. If a design feature can't be implemented in IE that's no reason not to implement it in WebKit, so long as it degrades gracefully.&lt;/p&gt;
&lt;p&gt;For this to work you need to be close to the designers (or be the designer) and have laid back superiors - it can't really be done when you're dealing with long chains of design approval. Convince everyone that the site is going to look &lt;em&gt;better&lt;/em&gt; in Chrome (happy face!), not &lt;em&gt;worse&lt;/em&gt; in IE (ANGRY FACE). &lt;/p&gt;
&lt;h3&gt;Validating CSS3&lt;/h3&gt;
&lt;p&gt;By default, the W3C's &lt;a href="http://jigsaw.w3.org/css-validator/"&gt;CSS Validator&lt;/a&gt; does not recognise CSS3. You must specify that you are validating CSS3 by clicking "More Options" on the validator page and selecting the &lt;em&gt;CSS level 3&lt;/em&gt; profile.&lt;/p&gt;
&lt;p&gt;That’s it! Go forth and play:&lt;/p&gt;
&lt;h2&gt;CSS3 Goodies you have &lt;em&gt;got&lt;/em&gt; to check out: &lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.css3.info/preview/rgba/"&gt;Colours with alpha values!&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://www.css3.info/preview/multiple-backgrounds/"&gt;Multiple background images!&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/"&gt;New selectors!&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://www.w3.org/TR/css3-fonts/#font-resources"&gt;Embedded fonts!&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://developer.apple.com/safari/library/documentation/InternetWeb/Conceptual/SafariVisualEffectsProgGuide/Transforms/Transforms.html"&gt;3D transforms!&lt;/a&gt; 
&lt;li&gt;&lt;a href="http://webkit.org/blog/138/css-animation/"&gt;Animations!&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;
&lt;h2&gt;Note on this site&lt;/h2&gt;
&lt;p&gt;This post is pretty much a press release for the recent redesign of &lt;strong&gt;FARMCode.org&lt;/strong&gt; – CSS3 allowed me to code the site exactly how I wanted in Google Chrome, translate it across to Firefox in like 5 minutes and then conduct quick damage control for IE (no rounded corners there).&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:14 Z</pubDate>
      <a10:updated>2023-03-23T15:08:14Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1156</guid>
      <link>https://shazwazza.com/post/net-open-source-blog-comparison/</link>
      <category>Web Development</category>
      <category>Umbraco</category>
      <title>.Net Open Source Blog Comparison</title>
      <description>&lt;p&gt;When I started creating this site this morning, the first thing i though to myself was that I wasn’t going to use &lt;a title="BlogEngine.Net" href="http://www.dotnetblogengine.net/" target="_blank"&gt;BlogEngine.Net&lt;/a&gt; for yet another blog. So I went on a mission to find some other open source blogging systems written in ASP.Net. One of the things I needed the codebase to support was to work seamlessly with Live Writer, so after some quick research I found that the new &lt;a title="Orchard Project" href="http://www.orchardproject.net/" target="_blank"&gt;Orchard&lt;/a&gt; project support Live Writer and so does &lt;a title="SubText" href="http://subtextproject.com/" target="_blank"&gt;SubText&lt;/a&gt;. So using WebPI, I decided to give them each a quick test run.&lt;/p&gt;  &lt;p&gt;I’m sure the Umbracians out there are asking: Why wouldn’t you just use &lt;a title="Blog 4 Umbraco" href="http://our.umbraco.org/projects/collaboration/blog-4-umbraco" target="_blank"&gt;Blog 4 Umbraco&lt;/a&gt; considering I’m on the core development team. Well, i guess it’s because all I really want is a very simple blogging tool and really just wanted to try out some new tools. &lt;/p&gt;  &lt;p&gt;So I started with Orchard and was kind of excited to see what it offered since it’s newcomer to the CMS scene and has a bit of hype behind it. The admin UI was nice and is was very easy to install. Setting up a new blog was pretty straight forward as well… just click on Create Blog. It' also has a couple nice skins you can test out. So far so good (even though this is still a alpha/beta product). So I tried plugging in Live Writer to it and it turns out that Orchard really hasn’t implemented some of the much needed features of the &lt;a title="MetaWeblog API" href="http://en.wikipedia.org/wiki/MetaWeblog" target="_blank"&gt;MetaWeblog API&lt;/a&gt; such as categories &amp;amp; tags! ouch. On a side note, i tried looking at creating new content types in Orchard, thinking it would be similar to how Umbraco works. Turns out it’s not quite the same and looks as though this functionality is in its infancy in Orchard. There was really only one data type to choose from which was text and it appeared as though i couldn’t delete a content type either. We’ll see how the project looks in a few months.&lt;/p&gt;  &lt;p&gt;Next I went on to SubText. This was also pretty easy to install (not as easy as Orchard though) but the admin UI isn’t so pretty. SubText has pretty much every feature that you could want out of a blogging system and comes with a bunch of skins as well. One thing i noticed which looked pretty cool is that you can add text filters so the SubText will automatically create links for you in your posts. So I plugged in Live Writer and everything is pretty good, except that they haven’t implemented tagging in their MetaWeblog API either.&lt;/p&gt;  &lt;p&gt;As you’ve probably noticed, I’ve settled back on BlogEngine.Net. It has better Live Writer integration than either of these other two blogging systems, the admin UI is nice enough and it’s pretty damn easy to use. I really wish they’d implement non ASPX page extensions sometime soon though!&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:13 Z</pubDate>
      <a10:updated>2023-03-23T15:08:13Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1205</guid>
      <link>https://shazwazza.com/post/how-to-embed-asmx-web-services-in-a-dll/</link>
      <category>Web Development</category>
      <category>Umbraco</category>
      <title>How to embed ASMX web services in a DLL</title>
      <description>&lt;p&gt;The development of &lt;a href="http://uComponents.codeplex.com" target="_blank"&gt;uComponents&lt;/a&gt; for &lt;a href="http://umbraco.org" target="_blank"&gt;Umbraco&lt;/a&gt; is still ongoing but is probably close to a v1.0 release. During the development of the Multi-node tree picker data type, I’ve spotted a bug in the Umbraco core in regards to the ASMX web service the existing tree uses to render out it’s initial node. The bug basically won’t allow the tree to render an individual tree, only a full app. Since the Multi-node tree picker requires rendering of an individual tree, i needed to fix this. To do this was a bit of a work around but i had to override the tree’s ASMX web service with my own (I’ll write a post about this one later). It then occurred to me that I’ve never embedded an ASMX web service into a DLL without a physical file and I didn’t want to go updating the web.config with custom handlers, etc… So I came up with a way to embed ASMX web services in your DLL without modifying web.config’s, etc… here’s how:&lt;/p&gt;  &lt;p&gt;First, create your web service as a standard class and add all of the functionality that your require your web service to have:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate-import/image.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://shazwazza.com/media/articulate-import/image_thumb.png" width="436" height="155" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In your class library project, create a new text file but give it the extension .asmx:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate-import/image_1.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://shazwazza.com/media/articulate-import/image_thumb_1.png" width="440" height="255" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Set the file to be a non compiled file:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate-import/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://shazwazza.com/media/articulate-import/image_thumb_2.png" width="352" height="82" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Create an resource file:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate-import/image_3.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://shazwazza.com/media/articulate-import/image_thumb_3.png" width="439" height="251" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Double click on your new RESX file, then drag your ASMX file into the editor to add the file as a property of your RESX file:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate-import/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://shazwazza.com/media/articulate-import/image_thumb_4.png" width="391" height="177" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Double click your ASMX file to edit it and set it to inherit from your custom web service class:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://shazwazza.com/media/articulate-import/image_5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://shazwazza.com/media/articulate-import/image_thumb_5.png" width="425" height="48" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now, we need to register this ASMX web service into the web application that it’s being deployed to. This is easily done by just checking if the ASMX file exists where it needs to be before it needs to be called and if it doesn’t, we just create the file. In the case of uComponents and the multi-node tree picker requires the ASMX web service for the CustomTreeControl, so we’ll do this check in the CustomTreeControl’s static constructor:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:8465a3ee-ce08-442b-998a-9b6f3398db04" class="wlWriterEditableSmartContent"&gt;&lt;pre style=" width: 672px; height: 430px;background-color:White;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; CustomTreeControl()
{
    var filePath &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; HttpContext.Current
                    .Server.MapPath(&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000;"&gt;~/CustomTreeService.asmx&lt;/span&gt;&lt;span style="color: #800000;"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #000000;"&gt;);
            
    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;check if it exists&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #000000;"&gt;File.Exists(filePath))
    {
        &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;lock the thread&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;lock&lt;/span&gt;&lt;span style="color: #000000;"&gt; (m_Locker)
        {
            &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;double check locking....&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #000000;"&gt;            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; (&lt;/span&gt;&lt;span style="color: #000000;"&gt;!&lt;/span&gt;&lt;span style="color: #000000;"&gt;File.Exists(filePath))
            {
                &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;now create our new local web service&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #000000;"&gt;                &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;using&lt;/span&gt;&lt;span style="color: #000000;"&gt; (var sw &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; StreamWriter(File.Create(filePath)))
                {
                    &lt;/span&gt;&lt;span style="color: #008000;"&gt;//&lt;/span&gt;&lt;span style="color: #008000;"&gt;write the contents of our embedded resource to the file&lt;/span&gt;&lt;span style="color: #008000;"&gt;
&lt;/span&gt;&lt;span style="color: #000000;"&gt;                    sw.Write(CustomTreeServiceResource.CustomTreeService);
                }
            }
        }
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;That’s it! &lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:13 Z</pubDate>
      <a10:updated>2023-03-23T15:08:13Z</a10:updated>
    </item>
    <item>
      <guid isPermaLink="false">1229</guid>
      <link>https://shazwazza.com/post/and-it-begins/</link>
      <category>Web Development</category>
      <category>Umbraco</category>
      <title>And it begins</title>
      <description>&lt;p&gt;For the last couple of years I've been blogging on &lt;a title="FARMCode" href="http://farmcode.org" target="_blank"&gt;FARMCode.org&lt;/a&gt; and today decided that I was going to start up my own blog as well. This doesn't mean that I won't still be blogging on FARMCode, it just means that I have a new place to post up information that may not directly relate to &lt;a href="http://thefarmdigital.com.au" target="_blank"&gt;TheFARM&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the coming weeks I'll start posting up some new content, code snippets, some info on the up and coming Umbraco project we've been working on called &lt;a title="uComponents" href="http://uComponents.codeplex.com" target="_blank"&gt;uComponents&lt;/a&gt; and maybe some portfolio work as well.&lt;/p&gt;</description>
      <pubDate>Thu, 23 Mar 2023 15:08:13 Z</pubDate>
      <a10:updated>2023-03-23T15:08:13Z</a10:updated>
    </item>
  </channel>
</rss>