I love my MacBook, and I'm always looking for new shortcuts to make my everyday experience even more pleasant and productive. Here are five shortcuts you should know.
Search Results for “”
As part of HTML5, the srcset attribute for img tags has been specified by W3C to provide an HTML extension for adaptive images. Because responsive images are a feature we all should start using today, I want to show you my approach for emitting adaptive
img tags in ASP.NET MVC.
I recently implemented a sticky header within a
UICollectionView that scrolls both horizontally and vertically. Here's how.
Learn how to keep your browser console organized by grouping related log messages using modern browsers' debugging tools.
I'm proud to present "Advanced Static Types in TypeScript", my second egghead.io course.
Angular 2 will be built on TypeScript, and the AtScript and TypeScript languages have been converged. Here's my take on this development.
I'm excited to announce TypeScript Weekly, a weekly e-mail round-up of news and articles from the TypeScript community.
Learn how you can manually bootstrap AngularJS applications and initialize them with asynchronously loaded JSON data.
Instead of manually incrementing the
tabindex value of several input fields, use a variable in your Razor views to make your life a little easier.
Many AngularJS applications require initial data on startup. Here's how you can pass server-side C# data from ASP.NET to HTML.
Here's a compilation of my favorite session recordings from Build 2015. They're all about ASP.NET 5, C# 6, and TypeScript.
This is an introduction to bundling and minification, two techniques which help improve a website's performance by reducing page load time and asset size.
Bundling and minifying a website's scripts and stylesheets reduces page load time and asset size. Here's my project setup for bundling and minifying scripts of an AngularJS application hosted within an ASP.NET MVC site.
TypeScript can now independently transpile module formats and language targets. This way, Rollup can bundle ES2015 modules with ES5 code.
The Chrome Developer Tools let you store values logged to the console as global variables for further debugging. Super handy from time to time!
This post outlines how to set up code splitting in a client-side web application using dynamic
import() expressions, TypeScript, and webpack.
Lodash defines two functions,
_.merge, for combining properties of multiple objects. Which one should be used for merging settings objects?
The Newtonsoft.Json library allows you to conditionally serialize object properties by looking for a method following a certain naming convention. Here's how that works.
const keyword declares a constant variable. However, its value can still change since it's not immutable. A clarification.
Using a custom convention, the
Date instances by default.
By designing your code for functional composition, you can keep it simple and targeted, making it easier to implement, understand, and test it. More sophisticated logic can be modeled by composing various building blocks of basic functionality — extension methods for collections, in the case of this post.
Destructuring assignments work perfectly together with regular expression matches as returned by the
exec function. Pattern matching helps assign matches and captures to local variables.
Here's a little helper class for detecting on which operating system a .NET Core application is currently running.
Learn how to use the
ng-strict-di attribute to detect unminifiable Angular code. It puts the dependency injector into strict mode to fail fast and fail early.
Dracula is a dark theme for many editors, IDEs, terminals, and other applications. It looks bloody good!
Array.prototype.includes method will be included in the upcoming ECMAScript 2016 specification. Here's how it works.
The destructuring syntax introduced by ECMAScript 2015 doesn't have to be used to declare new local variables. Plain assignments are supported, too.
I've written a library called ExtraLINQ, which provides additional extension methods for working with .NET collections.
I've created a NuGet package for my ExtraLINQ project. Go grab it!
Check out the free "30 Days to Learn jQuery" course on Tuts+ if you want to take your jQuery skills to the next level.
The collection initializer syntax of C# is a clean way to initialize a collection with values. The compiler will insert appropriate method calls which actually add those items. We can leverage the convention-based nature of this process to provide our custom collection initializers.
TypeScript allows us to specify multiple types for the same function. That way, we can accurately describe all possible overloads to the type system.
TypeScript 1.6 introduced the
--init flag for the
tsc executable to make it easier to set up new TypeScript projects. A short summary.
This post describes how I use a custom
RouteNames class together with
UrlHelper.RouteUrl to generate route URLs in ASP.NET Core MVC.
This post gives you some suggestions as to how to get started using the new ECMAScript 2015 features in your projects.
ASP.NET Core exposes an application's web and content root paths through the
IHostingEnvironment service, which is available via the built-in dependency injection system.
In this blog post, I want to share a small piece of ASP.NET Core middleware that implements antiforgery token validation for all POST requests.
ASP.NET MVC ships with the UrlHelper class that makes route URL generation very easy. Read about how to generate absolute URLs instead of relative ones.
If a database has a different name in production than on development machines, you can configure an alias to use the same name everywhere. Here's how to create such an alias for a SQL Server database instance.
Here's how to remove the yellow background that WebKit and Blink add when autofilling a value into a text field.
I use the Sublime Text editor to write Markdown fairly often. Read about my Sublime setup which includes two excellent packages for additional syntax highlighting.
Swift allows you to define custom operators to extend the language. Read about how to implement a forward pipe operator that passes values through a chain of transformation functions.
Read about a little exception helper class I've written which encapsulates parameter null checking and other validation functionality. By providing a concise and easily readable interface, it helps shorten and declutter your methods.
Lodash implements implicit function chaining, which allows you to write function chains without calls to
_.value. This allows for a concise and readable expression of typical map/reduce transformations.
ASP.NET Core MVC allows developers to specify inline route constraints directly within route templates. Finally, inline route constraints are no longer restricted to attribute routing!
Here's how to inline Angular view templates into the page HTML for better performance using ASP.NET MVC and Razor.
System.Web.Optimization framework using ASP.NET MVC.
Here is how to synchronize your Visual Studio and ReSharper settings across multiple development machines using Dropbox.
Get started with F# by solving math problems from Project Euler. You'll learn about functional programming concepts along the way.
The Enumerable class contains some lesser-known static members. Here's an overview over the Empty, Range, and Repeat methods.
The popular Lodash library will be even more natural to use with ECMAScript 2015. New language features like pattern matching, array destructuring, and arrow functions allow for writing terse yet readable code.
Here's how I use Feedly and Pocket to create a curated reading list from my RSS feed subscriptions and interesting links found while browsing.
The regular expression pattern
\d matches more than just the ten digits commonly used in programming. Here's a list of matches you might not have expected.
You can use the
merge-stream package to combine multiple gulp streams into a single stream that can be returned from a gulp task.
ReSharper offers a vast suite of refactoring methods, all of which have their own shortcut. Here's a list of 8 shortcuts I've found to be indispensable.
This is a list of some of my favorite tech-related books. I've enjoyed reading all of them, and maybe you will, too.
Here's how to use Babel to transpile npm packages written in ECMAScript 2015.
The Swift language designers made some interesting choices regarding static typing and numeric types. Read about how working with numbers in Swift differs from other languages.
Trying to hold unfinished tasks and unprocessed thoughts in your head impairs your ability to focus when programming. Instead, you should build your own trusted system.
ResX files allow you to easily localize an ASP.NET application. I'll show you how I manage resource strings containing placeholders with confidence at compile-time.
CommonMark.NET is a Markdown parser for .NET that efficiently transforms Markdown written in CommonMark dialect into HTML.
The popular Underscore.js library recently enhanced its capabilities to deal with partially applied functions. Starting with version 1.6.0 which was released in February 2014, the _.partial function is now a lot more flexible and allows for some interesting use cases.
An operator function in Swift can be passed to a higher-order function like any other. Here are some examples where that comes in handy.
This post summarizes various language features of Swift that allow you to concisely define closure expressions, namely type inference, shorthand argument names, trailing closure syntax, and operator functions.
The behavior of the .NET regular expression engine can be configured in a variety of ways. Here's a detailed look at all the different regex options.
When you're resizing images in .NET, you might get artifacts along the edges of the resized image, which are called ghost borders. Here's how you get rid of them.
Here's how to return an object literal from an expression-bodied arrow function as introduced by ECMAScript 2015.
If you're running multiple ASP.NET applications on the same the host, their forms authentication cookies need to be uniquely named. Here's how you can set those names.
Starting with the recently released version 4.5.2 of the .NET Framework, ASP.NET now supports the
HostingEnvironment.QueueBackgroundWorkItem method which lets you schedule small background work items. Here's a short write up how you can use it.
Let's take a look at how we can use the FluentSecurity library to secure ASP.NET MVC applications in a centralized place.
Authentication cookies have to be protected well. Here's how to only send them over HTTPS using the ASP.NET Core cookie authentication middleware.
The FluentSecurity library can resolve its policy violation handlers through a dependency injector such as Ninject, as this example shows.
When you share a highlighted range of lines in a GitHub file, those line numbers might be incorrect once the file changes. Here's how to obtain a permalink to the file blob.
A simple piece of ASP.NET Core middleware lets you simulate network latency to get a much better feeling for your web application's performance in production.
Practice makes perfect, and writing regular expressions is no exception to this. Check out Regex Tuesday for weekly challenges to improve your regex skills.
In C#, every variable of a reference type can hold a null value. Some types like collections and delegates, however, allow for much better default values. Reduce your bug surface area by following reasonable conventions when dealing with null.
TypeScript 1.8 introduced string literal types, which allow for describing a set of possible string values for a given variable. Here's how to use them.
This post summarizes my experience with switching from a German keyboard layout to an American one for programming and software development tasks.
Tag helpers are a new feature of ASP.NET MVC 6 which allow for server-side manipulation of HTML elements in Razor views. An introduction.
Sorting CSS properties by name is like sorting books in a library by size. Use a tool like CSScomb to sort the properties by function rather than name and to beautify your stylesheets.
Editorconfig helps enforce a consistent usage of whitespace within a project. You can specify how to deal with indentation, line endings, trailing whitespace, and more.
This is the first issue of Tasty Links, a list of articles and videos I came across that I found fascinating, helpful, or otherwise interesting.
This is the second issue of Tasty Links, a list of articles and videos I came across that I found fascinating, helpful, or otherwise interesting.
This is the third issue of Tasty Links, a list of articles and videos I came across that I found fascinating, helpful, or otherwise interesting.
This is the 4th issue of Tasty Links, a list of articles and videos I came across that I found fascinating, helpful, or otherwise interesting.
This is the 5th issue of Tasty Links, a list of articles and videos I came across that I found fascinating, helpful, or otherwise interesting.
The logical operators
ECMAScript 2016 will likely standardize the exponentiation operator
**. Babel and TypeScript 1.7 already support it today.
ECMAScript 5 introduced many useful array methods. Two lesser known of them,
every(), are explained in this post.
Here are my top 5 blog posts by views in 2014.
Here are my top 5 blog posts by page views in 2015.
TypeScript uses the
TypeScript 1.5 has been released and ships with excellent ECMAScript 2015 support. Check out this new version and start using ECMAScript 2015 language features today.
TypeScript 2.0 adds a "lib" compiler option that gives you more granular control over which built-in API declarations to include in your project.
TypeScript 2.0 implements control flow based type analysis to determine the most specific type for a variable or parameter at any given location. An explanation.
TypeScript 2.0 introduced more literal types. In addition to string literal types, we can now declare boolean, numeric, and enum literal types.
TypeScript 2.0 adds support for non-nullable types, which help prevent an entire category of nullability errors at compile-time.
In TypeScript 2.0, the
readonly modifier was added to the language. It provides compile-time checking for unintended property assignments.
TypeScript 2.0 implements tagged union types, a special kind of union types that share a common property. Here's how you can use them in practice.
TypeScript 2.0 introduced a new primitive type called
never, the type of values that never occur. It helps model the completion behavior of functions more accurately.
TypeScript 2.1 adds support for downleveling asynchronous functions to ES3/ES5. That way, you can run your
TypeScript 2.1 adds a compiler option for importing helper functions from an external library. The helpers aren't injected into every file, resulting in smaller bundle sizes.
TypeScript 2.1 improves inference for literal types. Constant variables and read-only properties with literal initializers are now inferred to be of a literal type.
TypeScript 2.1 introduced the
TypeScript 2.1 differentiates between widening and non-widening literal types. Here's the difference between the two.
TypeScript 2.1 introduced mapped types, a powerful type system feature which allows you to create new types from existing ones by transforming properties.
TypeScript 2.1 adds support for object rest and spread. You can work with rest/spread properties in a type-safe manner and downlevel both features to ES3.
TypeScript 2.1 makes it a lot easier to work with untyped imports. Previously an error, these imports are now typed as
any and can be consumed painlessly.
TypeScript 2.2 loosens a restriction around dotted property access for types with explicit string index signatures. Fewer type annotations, less awkward code!
TypeScript 2.2 introduced support for statically typed mixin classes. This post briefly explains mixins and shows how to use them in TypeScript.
With TypeScript 2.2, null checking is improved even further. TypeScript now flags expressions with nullable operands as compile-time errors.
TypeScript 2.2 introduced a new type called
object which represents any non-primitive type. Don't confuse it with the existing
TypeScript 2.3 introduced a new
--downlevelIteration flag that adds full support for the ES2015 iteration protocol and
for...of-loops for ES3 and ES5 targets.
TypeScript 2.3 implemented generic parameter defaults which allow you to specify default types for type parameters in a generic type.
TypeScript 2.3 introduced a new
--strict compiler option that enables a number of other compiler options related to stricter type checking.
TypeScript 2.4 added support for dynamic
import() expressions, which allow you to asynchronously load and execute ECMAScript modules on demand.
TypeScript 2.4 implemented a spelling correction mechanism. Even if you slightly misspell a name, TypeScript can suggest the correct spelling in many cases.
TypeScript 2.4 implemented one of the most requested features: string enums, or, to be more precise, enums with string-valued members.
TypeScript 2.4 introduced the concept of weak types. Here's how weak type detection can help you avoid silent bugs.
TypeScript 2.5 implemented the optional
catch binding proposal, which changes the ECMAScript grammar to allow for the omission of the variable binding within a
TypeScript 2.6 added support for JSX fragments. Within
.tsx files, you can now use the new
<>...</> syntax to create a fragment.
TypeScript 2.7 brought support for numeric separators. Within a numeric literal, you can now group digits by putting an underscore between them.
TypeScript 2.7 introduced a new compiler option for strict property initialization checks in classes.
ECMAScript 2015 allows a function to immediately destructure an object parameter. Here's the TypeScript syntax for typing the destructured properties.
In TypeScript, there are multiple syntaxes for typing a function: method signatures, function type literals, and object type literals with call or construct signatures.
C# defines plenty of modifiers for type and type member declarations, some of which can be combined. Learn about how "protected internal" and "override sealed" work.
Visual Studio Code lets you specify which TypeScript version to use for tooling. Here's how to install a nightly build of TypeScript within a workspace.
If you want to use integers rather than strings for document IDs in RavenDB, you need a little hack in order to get indexes working correctly. Here's what you have to do.
The IndentedTextWriter class allows you to output hierarchically structured data while preserving the nesting through indentation. Here's how.
ASP.NET MVC 6 introduces view components, a powerful mixture of child actions and partial views for building reusable components.
Read my thoughts on Microsoft's big announcement of open-sourcing .NET and officially supporting true cross-platform development on Windows, Linux, and Mac.
When I used the Enumerable.Except extension method, its behavior startled me. It creates a set difference, which might not be what you expected. We'll take a look at how Enumerable.Except is implemented in the .NET Framework.
.* in a regular expression doesn't yield the results you want. Read about how overly greedy quantifiers account for poor performance and even lead to incorrect matches.
Read about why you should use a favicon generator and nest the generated files using a Visual Studio extension to keep your Solution Explorer clean.
Read on for a description of how I work with Sass files in my ASP.NET MVC applications. This run-down is mainly about organizing, bundling, and minifying stylesheets.