A Quick Reference to Creating NuGet Packages

All of the following commands should be executed in the folder containing the project from which you want to create a package.

nuget spec – Create a .nuspec file which contains meta-data about the package such as author, description, and title. You will need to edit some of the values in this file when you first create it.

nuget pack <.csproj file name> -Prop Configuration=Release – Create a .nupkg file containing the compiled contents of the project specified in the first parameter. Optionally target a specific configuration.

nuget push <.nupkg file name> – Push the NuGet package up to your NuGet.org account.

More complete documentation here.… Read more

Security, insurance, encryption, and your expensive belongings

People these days tend to buy a lot of gadgets and electronics. Between our smart phones, televisions, cars, computers, tablets, and e-readers, the expense can add up. Many times, we overlook the importance of cataloging everything that we own for various reasons.

First, it keeps us honest. Do we really need another iPhone if we just bought one a year ago? Probably not. Your stash in our service will remind you of when you purchased something (provided you are honest).

Second, theft and loss are real things. We like to pretend that bad things will never happen to our expensive stuff, but it can and probably will. A phone that costs $600 is not something to take lightly, especially if your daily activities require a lot of movement. Documenting the condition of your belongings, when you purchased them, the purchase receipts, and any other details about them can help with police reports and your home or rental insurance.

Third, it’s quite convenient and safe to store your information in online stash. You can pull up your stash on any device that you own immediately. You don’t have to go searching through paper receipts, pulling out the TV to find out what model you have, or go digging through your file cabinets. Everything in your stash is ready for you and secured with multiple levels of security.

Get started for free at https://www.saferstash.com.… Read more

The misguided nature of redesigning a user interface every year

I am what I would consider tech-savvy. I tend to dabble in different technologies, semi-early adopt the latest operating systems and versions of software, and generally enjoy testing out new features in computer-based environments. With all that said, even I find it annoying when “designers” find the need to redesign and restructure a product’s user interface on a yearly basis.

Here’s a series of tweets from Google’s VP of Product Design which perfectly illustrate his approach to how things work.

Despite what he says about “having no beef with how Windows looks”, he contradicts himself by first stating that he dislikes the fact that it is “basically XP with a flat design skin.” Obviously the guy is allowed to have his own opinion, but his opinion will spill over into his work on Google’s product designs. That isn’t too surprising given the number and frequency of user interface changes to Google’s products and services every year.

And therein lies the problem. The vast majority of Google’s products occur on the web and on their Android platform. What do these two platforms have in common? Minimal control over which version of a product you’re currently using. This is especially true on the web where you literally have no idea what a website will look one day to the next because you aren’t informed of any “pending upgrades.” On Android, you’re stuck with nagging updates which may or may not completely change your workflow due to a redesigned user interface.

I realize that modern age personal computing is less than 30 years old, and that mobile computing is even newer. There’s plenty of room for improvement. I don’t want to be “that guy” who wants everything to stagnate and never move forward. That said, I see no good or compelling reason to make radical user interface as seen in Windows 8 and Google’s Material design. Why not ease people into a new design rather than dropping a huge set of changes on everyone?

Many people are resistant to change. That much is obvious just by talking to users of a system or reading the reviews of a product directly after launching a new version. And while much of the grievance is simply because of change itself, there are legitimate concerns from people regarding changes which affect their lifestyle and workflow. Changes should be eased in and tested on people at large scales to get perspectives from beyond the “Silicon Valley Bubble” which tends to act as an echo chamber.… Read more

How to Rollback Entity Framework Code First Migration

The code first approach to using the Entity Framework can be extremely helpful in creating a new database while staying entirely within your C# code base. If you’re more comfortable with creating plain old class objects (POCO) and then having those translated into SQL driven structures, code first is for you. That said, the process by which updates to the code base are pushed to the database (migrations) can be a bit frustrating to use at times. Not all SQL Server features are supported in a code first approach. In addition, migrating your structures in Azure has its own set of problems.

If you want to roll back to a previous migration due to an error in the current migration or wanting to rewind and start over, the following command can be used from the Package Manager Console in Visual Studio. This will rewind and undo any migrations between the current and the “migration-name” migration.

For example, if you have the following history of migrations in your project where the * indicates the current migration:

  • 201506042221067_RemoveColumn1
  • 201507031735200_AddColumn2
  • 201507044516322_CreateNewPersonTable
  • *20150731124746_SomeBrokenMigration

Use this command to roll back to the “AddColumn2” migration. Notice that the timestamp on the migration name is not included in the command.

The migration history will then look like:

  • 201506042221067_RemoveColumn1
  • *201507031735200_AddColumn2
  • 201507044516322_CreateNewPersonTable
  • 20150731124746_SomeBrokenMigration

Notice that the migrations which were rolled back were not deleted. The next time you perform an update-database command, the migrations will be re-executed. You will need to delete the migration from your project entirely if you want to avoid this.… Read more

Change excerpt length in WordPress

Some themes have hard coded (built in without options) lengths for excerpts on the home page, search results, and archive pages. Without the ability to change this easily, you’re left with a theme that may not suit your needs. The two choices that I find to be the easiest are to edit your functions.php file to include a filter or to install a plugin to handle this for you. Either way is fine, though you may use one over the other based on your experience with WordPress internals.

Plugin

This is by far the easiest method, though not the most customizable. You’re bound by whatever the plugin allows you to change, and there’s no guarantee that the plugin will work with whatever version of WordPress is installed on your host.

  1. Search for the Advanced Excerpt plugin.
  2. Go to its settings page and choose your options.
  3. The first setting is the excerpt length (based on words or characters).
  4. The rest allows you to change what is being filtered, what text you want to show when the user can read more, and other options.

Functions.php

If you’re more comfortable with coding, changing WordPress internals, and have general access to the source code of your host’s WordPress installation, then this is the best option for you.

  1. Using a FTP client (I use FileZilla), connect to your host’s WordPress installation.
  2. Download and edit the functions.php file.
  3. Add the following to the file, where “20” is the length of the excerpt. Change that to whatever you want to use.
  4. Save and upload the file back to your WordPress installation.

One thing to keep in mind is that the above advice is editing the theme directly and is not the best approach. If you update the theme from the author, all changes that you made will be lost. Instead, you should look into creating a child theme and performing the above steps on that.… Read more

Remove and disable “Get Windows 10” icon

Microsoft seems to have pushed an automatic update to Windows 7/8/8.1 machines with an annoying popup in the notification tray exclaiming that you need to reserve your copy of Windows 10 immediately. If you’re like me, you wanted to figure out how to kill this thing for good. There’s a few ways you can do it. There’s a temporary until reboot way and a permanent way.

Temporary

On Windows 8.1, go to the Task Manager (right click the Task Bar, click Task Manager) or CTRL+ALT+DEL and then click Task Manager. The process you want to kill under the “Details” tab is called GWX.exe. Once you stop that process, the icon will go away. Be warned that it will come back when you reboot your machine.

Permanent

  1. Open the Control Panel and click Windows Update.
  2. Click Installed Updates in the lower left.
  3. Find the update named “KB3035583”, right click it, and uninstall.
  4. Go to “C:\Windows\System32\” in an Explorer window
  5. Right click the “GWX” folder, click Properties and then the Security tab
  6. Click Advanced and then click the “Change” button next to the Owner
  7. Change the user to your account or group that you use on the computer
  8. Click OK/Apply and then delete the “GWX” folder

Your computer is now free from that annoying popup, but make sure to hide the update in the Windows Update window if it ever comes back asking to be installed. This is a good time to remind everyone that they should set their Windows Update settings to Manual Installation so that you don’t get stuck with these botched updates automatically.… Read more

Setup a blank WordPress site in Azure

One of the reasons WordPress is hugely popular is because it’s super easy to setup and has a large developer base around it which is responsible for creating many useful plugins. If you’re interested in setting up WordPress in Azure, look no further! Make sure you understand the pricing structure of Azure before you go this route. Often, the cost isn’t really worth the return unless you have 5+ blogs that you want to setup on Azure. You can stick to the Free or Shared ($10/mo) tiers, but the performance can suffer quite a bit depending on your site’s popularity and you may not get certain features like custom domains and SSL support.

Azure can be a little confusing for newcomers who don’t realize that some functionality is split across two different portal/management sites. One of these (the “new” portal) is in Preview status while the other (the “old” portal) is the status quo which should be used for most operations. You can follow either section below to achieve the same result, though one may be simpler than the other depending on your use cases.

“Old” Azure Portal

  1. Login to the “old” Azure Portal with your Microsoft Account.
  2. In the lower left, click New > Computer > Web App > Quick Create.
  3. Enter the URL name that you want. If you end up selecting the Shared pricing tier or above (Basic, Standard, Premium) you will have the option of setting up a custom domain. See my guide to doing this with Namecheap. Other domain name services have similar features.
  4. Choose an App Service Plan to under which the web app will be setup. This is important because it could determine how much you pay since each App Service Plan has an associated pricing tier. App Service Plans are basically collections of apps and services that you own in Azure. These will share the same resources setup by the plan and under the same pricing tiers. Read more about App Service Plans.
  5. In the lower right, click Create Web App.CreateBlankWordpress1
  6. Under the Web Apps section of the portal, you should see your new web app being setup or running.
  7. Click the web app that you just created.
  8. Click the “Download publish profile” link under the “Publish your app” section.CreateBlankWordpress2
  9. Download and install your favorite FTP software (I use FileZilla).
  10. Download the latest WordPress version.
  11. Open the publish profile file and pull out the “publishUrl”, “userName”, and “userPWD” under the “publishMethod=FTP” section.
  12. Use the above credentials with your FTP software to connect to the web app’s FTP folders.
  13. Extract the downloaded WordPress zip and upload them to the /site/wwwroot/ folder.CreateBlankWordpress3

“New” Azure Portal

  1. Login to the “new” Azure Portal with your Microsoft Account.
  2. In the upper left, click New > Web + Mobile > Web App.
  3. Enter the URL name that you want. If you end up selecting the Shared pricing tier or above (Basic, Standard, Premium) you will have the option of setting up a custom domain. See my guide to doing this with Namecheap.
Read more

Custom authorization with ELMAH and ASP.NET Identity Framework

If you’re using any of the most recent ASP.NET MVC 5 project templates with authentication and authorization built in, then you’re probably using the ASP.NET Identity Framework. With any ASP.NET project, it’s smart to add references to the ELMAH library just in case any unhandled exceptions occur. You can use both of these libraries together to restrict access to the remote ELMAH page with custom authorization.

First, install the Elmah.MVC package from NuGet. This should download the correct libraries and add the necessary lines to your web.config.

Substitute the “your_user_name” entry with your own username that you’ve setup in the ASP.NET Identity Framework backend. For example, the AspNetUsers table in SQL Server contains your usernames. It appears that ELMAH does get the authentication information from the current thread principal, which the ASP.NET Identity Framework will establish on your behalf upon login.… Read more

The required anti-forgery cookie “__RequestVerificationToken” is not present.

In your ASP.NET MVC adventures, you may come across the following error when loading a view.

The required anti-forgery cookie “__RequestVerificationToken” is not present.

After searching Google for awhile, you might become desperate with the many different solutions presented. Normally, the solution to this issue is related to the ValidateAntiForgeryToken attribute on actions. When accessing a GET action, you don’t need to use the anti-forgery token.

However, this is not the only solution. In my case, my web.config had this entry:

Checking the project settings in Visual Studio revealed that my project was not set to use SSL which caused a conflict. Either comment out the above line or set the project to always use SSL.

See more solutions to this issue on this StackOverflow answer..… Read more

3 Types of Questions You Should Never Ask During an Interview

So your boss came to you and told you to conduct an interview for a new hire. Or maybe you’re actually the hiring manager. Guess what? These suggestions apply to everyone! Based on my experiences with many technical interviews, avoiding these 3 types of questions applies to anyone wanting to steer clear of legal issues and attract the best candidates with the most accurate predictions of success.

I won’t make any claims about being able to predict applicant performance in specific scenarios. This is mainly because studies have shown such predictions to be difficult to obtain regardless of the type of measure utilized during the interview process. While interviews can be a good predictor of how an applicant will apply knowledge in a general and broad scope, it’s extremely difficult to judge whether or not said applicant will succeed with a specific technology for a specific project that your company has in mind. It’s even more difficult to predict when you’re using bogus, irrelevant, and nonsensical questions as a measure.

My advice is to stick to standardized, measurable, specific, and proven questions that are directly relevant to the job position and company as a whole.

1. Personal Questions

I’ve already discussed this one in an article about learning to conduct interviews, but I want to repeat it because it’s an important one. I’ve personally experienced and heard stories about some interviewers who feel that it’s appropriate to ask the applicant about their personal life including hobbies, what they do in their spare time, family life, age, birthdays, religion, and more. These topics just aren’t relevant to whether or not the applicant is fit for the position. In fact, asking about age and marriage can land you in legal hot water if an applicant decides to use that against you in a discrimination case.

Spare time and family life can be indicators of how available an applicant will be after hours. Someone who has a lot of hobbies and a few children probably isn’t willing to work tons of overtime. Without being able to ask about these, I can already hear the slave drivers screaming that they won’t be able to judge whether or not an applicant will be available 24/7 because they have a family to support. While that’s a topic for another day, rest assured that morale and overall productivity at a company with such policies is doomed to stay in the pits.

Making comments about age and asking about birthdays is just asking for trouble. It’s common for companies to look for the youngest possible applicants in the name of so-called “culture fit.” What they really want is someone who is still in “college mode” with no responsibilities beyond work and someone who is willing to take rock bottom pay out of either desperation or naivety. Silicon Valley and Wall Street will often call these people “passionate” to place a positive spin on the fact that they’re trading their free time for a slim chance at riches.… Read more