Redefine WordPress publishing with Markdown and code prettify

The code snippet horror

Till now embedding code snippets in a WordPress blog post was a painful process for me. I’ve tried several plugins but in the end all have a major downside when it comes to editing, I just couldn’t edit a single line of code because the original code block was transformed into HTML.

For a while I was using Live Writer, it was way better than fighting with TinyMCE, but code editing had the same downside, every time I wanted to make an edit, I had to paste the original snippet in Visual Studio, made the edit there and then override it in Live Writer. Another inconvenient for me with Live Writer was the preview feature that didn’t quite work with my WordPress theme. After I realize that posting from Live Writer makes it impossible to edit the post in WordPress editor because the code blocks loose padding, I’ve given up the Live Writer.

As a GitHub user I grow found of Markdown, it felt natural to document my projects with it but embedding gists in blog posts felt wrong. Making a gist for every snippet was messy, not to mention that it doesn’t work with RSS readers since the code blocks are not stored in the blog post content.
Read More…

Introducing ASP.NET MVC Throttling Filter

With MvcThrottle you can protect your site from aggressive crawlers, scraping tools or unwanted traffic spikes originated from the same location by limiting the rate of requests that a client from the same IP can make to your site or to specific routes. MvcThrottle is compatible with ASP.NET MVC 5.1 and can be installed via NuGet, the package is available at nuget.org/packages/MvcThrottle.

You can set multiple limits for different scenarios like allowing an IP to make a maximum number of calls per second, per minute, per hour or per day. You can define these limits to address all requests made to your website or you can scope the limits to each Controller, Action or URL, with or without query string params.

Read More…

WebApiThrottle 1.0.8

New features

  • - added per Week rate limit that can be used with Redis, Azure caching or any other caching service that can hold data more then 24h
  • - added TracingThrottleLogger to publish throttling messages to the native web api ITraceWritter if one is supplied
  • - allow override of throttle key computation ComputeThrottleKey
  • - allow override of HTTP Status code when requests are rate limited

Code refactoring

  • - short-circut large control statements
  • - move whitelist checking to separate method
  • - use member ThrottlePolicy instead of passing it around
  • - RequestIndentity renamed to RequestIdentity

You can install it from NuGet or get the source code from GitHub.

Introducing ASP.NET Web API Throttling handler

ASP.NET Web API Throttling handler is designed to control the rate of requests that clients can make to a Web API based on IP address, client API key and request route. WebApiThrottle is compatible with Web API v2 and can be installed via NuGet, the package is available at nuget.org/packages/WebApiThrottle.

Web API throttling can be configured using the built-in ThrottlePolicy. You can set multiple limits for different scenarios like allowing an IP or Client to make a maximum number of calls per second, per minute, per hour or even per day. You can define these limits to address all requests made to an API or you can scope the limits to each API route.

Read More…

ASP.NET Web API v2 Cross-origin resource sharing made easy

Building web apps that rely on several data endpoints located at different locations are a common practice these days. By default, due to security concerns like XSS attacks, CORS requests are blocked. That means that if your JavaScript code tries to make an Ajax call to a different location, other then the domain it originated from, it will fail with HTTP error code 405 (Method not allowed).

Let’s suppose you have an ASP.NET app that is relying on Ajax calls to fetch data from server and uses some sort of JavaScript templating for rendering and displaying data as HTML. At some point in time you’ll feel the need to expose data not only for your web app but also for a partner app or maybe for a JavaScript widget that can reside on a multitude of websites. In order to have a single data endpoint to handle all these requests a wise decision is to decouple this function from your original web app into a separate project that uses ASP.NET Web API engine. Calling the API from different .js modules and locations will be possible only if you enable CORS on the server-side and the browser that makes the calls can handle cross-origin request, luckily all modern browsers have CORS support.

Read More…

With the new App Suspend feature in IIS 8.5 you’ll get a 90% reduction in start-up time, this reason is enough for me to upgrade to Windows Server 2012 R2

1 2 3 5  Scroll to top