Missing Hibernate option in Windows 10 Power Options?

Is Hibernate option missing from the Power Options in the Control Panel like in the screenshot below?

Here is a way to restore the missing Hibernate option back to the Power Options.

How to Fix?

Click the Cortana Search box on your taskbar, type cmd, right-click on the Command Prompt and select Run as administrator.

Once the Command Prompt is launched, type in the following command to enable the Hibernate feature.

powercfg /hibernate on

Next, run the following command to change the hibernation file type to full.

powercfg /h /type full

Reboot your computer. You should see the Hibernate option show up in the Power Options now.

Enjoy!

Mounting NFS Share on Windows 10 & 11 with Write Access

It is easy to mount a drive from Linux NFS share on Windows 10 & 11 machines. To do that make sure you have NFS Client (Services for NFS) is installed from Programs and Features. Following is the command to mount the NFS drive. Note that this command will run on cmd (Command Prompt) and not on PowerShell.

mount \<IP_ADDRESS>\<PATH_TO_DIR>\ drive:

For example, if the IP address of the NFS share is 10.235.0.10 and the directory you want to share is /var/www and you want to mount it to your Z drive, then you can run the following command.

mount \\10.235.0.10\var\www z:

But when you mount the drive you can browse the files using your Windows Explorer but you cannot create new files nor edit any files. To get write access on NFS share you have to make a small change in Windows registry before mounting the drive. Follow these steps.

  1. Open regedit by typing it in the search box end pressing Enter.
  2. Browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default.
  3. Create a new New DWORD (32-bit) Value inside the Default folder named AnonymousUid and assign the UID found on the Linux directory as shared by the NFS system. This is the UID of the user that has the write access to that directory on Linux system.
  4. Create a new New DWORD (32-bit) Value inside the Default folder named AnonymousGid and assign the GID found on the Linux directory as shared by the NFS system. This is the GID of the group that has the write access on the directory on Linux system.Windows 10: Regedit NFS AnonymousUid and AnonymousGid
  5. Restart the NFS client or reboot the machine to apply the changes.

Now run the mount command and you will get the write access.

Visual Studio 2017 is coming in March

Microsoft has announced that Visual Studio 2017 will be available for download on Tuesday, March 7, 2017. Microsoft is also celebrating a launch event. You can join at 8:00 AM PST on March 7th and 8th for a two-day online event celebrating the launch Visual Studio 2017 and the 20-year anniversary of Visual Studio.

Let’s see what comes with newer version of Visual Studio 2017.

List of FREE services Startups should be using

I have curated a list of free tools, services, and apps that startups could and in fact should use to grow at the initial stage. Free doesn’t mean they lack quality, instead these free tools are from top-notch companies like RedHat, Google, Asana, GitHub and in all areas from infrastructure to version controlling to marketing and sales to project management.

Have a look at this list here and don’t forget to give your feedback.

I compiled this list a long time ago and recently updated it but it still might have some outdated links that I didn’t get chance to update yet. Feel free to let me know and I’ll update it.

Enjoy!

Deploy your first ASP.Net MVC App to AppHarbor

If you’ve been developing ASP.Net MVC apps lately you might be thinking some online or cloud based app hosting platform available as PaaS for Microsoft technologies specially for hosting ASP.Net MVC apps just like OpenShift, Heroku and other platforms are available for technologies like Ruby, Python, PHP, Node.js and even supporting CMS like WordPress. The good news for ASP.Net developers is that there is a PaaS platform available which you might already know. The platform is AppHarbor. AppHarbor runs over Amazon AWS and has some nice features that I won’t go into the details of. If you are interested in knowing how AppHarbor works you can see their page here.

Regardless of AppHarbor provides a decent service, new developers might still face some difficulty in deploying their applications to AppHarbor. Specially, if you are developing apps based on new Visual Studio 2015 templates like MVC. Their are different ways to deploy but I would follow below approach which in my opinion is good and provide auto deployment or in other words Continuous Integration (CI).

What you need?

We will be using following tools and accounts.

  • Visual Studio 2015 (any edition, I used Professional version)
  • ASP.Net MVC app created from VS2015 MVC template
  • GitHub repo for the app/project
  • Local git repo for app with remote repo set as your GitHub app repo
  • AppHarbor app

What’s not covered?

Our focus today is deployment of our ASP.Net MVC app to AppHarbor. Therefore, we won’t be going into the details of how application is created or its architecture, what’s new in Visual Studio 2015, what is MVC, what is Git and GitHub, and how to connect your GitHub repo to AppHarbor etc. We will assume that you already have all the pre-requisites and we will just focus what problems can we come across during deployment and how to fix them.

Deployment Steps

  1. Initialize a Git repo and connect it with your GitHub repo.
  2. Create AppHarbor app from your GitHub repo. Whenever we commit/push our changes to our GitHub repo AppHarbor will automatically fetches the latest push and build it. Upon successful build it will deploy the app on its server otherwise it will keep last successful build. This makes things very easy.
  3. Create an ASP.Net MVC application using Visual Studio 2015 MVC template.
  4. Add the packages folder to .gitignore
  5. Enable NuGet Package Restore. In VS2015 click Tools>Options and then select NuGet Package Manager and make sure both checkboxes are checked in this section.
  6. In VS2015 right click on project and click properties, then goto Build Events tab. In the Post-build event command line text area paste the following command.
    1. if not exist “$(WebProjectOutputDir)\bin\Roslyn” md “$(WebProjectOutputDir)\bin\Roslyn”
      start /MIN xcopy /s /y /R “$(OutDir)roslyn\*.*” “$(WebProjectOutputDir)\bin\Roslyn”
  7. Now commit and push your changes to GitHub.
  8. That’s it! AppHarbor will automatically fetch the latest version changes and build it and you can check your AppHarbor application on its URL.

What’s Next?

There are few things that you need to take care of specially related to security. This MVC app uses SQL Server Compact which isn’t a good option for production level apps. Secondly, your connection string or password to database must not be committed to public GitHub repo.

This post will just give you smooth start without any difficulties which I faced among other people that you can see in the resources section below.

If you think this was helpful or if I have missed anything please do let me know in the comments below.

Happy coding!

Resources

  1. https://blog.appharbor.com/2012/02/06/use-nuget-package-restore-to-avoid-pushing-packages-to-appharbor
  2. https://support.appharbor.com/discussions/problems/79727-error-msb3202-when-building
  3. https://support.appharbor.com/discussions/problems/78633-cant-build-aspnet-mvc-project-generated-from-vstudio-2015-enterprise#comment_37577678

How to Find a Stored Procedure in all the Databases?

When working with MS SQL Server sometimes you need to find a stored procedure in the databases and all that you know is the name of the stored procedure that your teammate told you that he had used but couldn’t remember in which database it was. All the information about the stored procedures created is saved in the master database. So, if you have access to master database that you probably have then you can run the following query to get information about the stored procedure.

select * 
from 
   sys.procedures 
where 
   name like '%name_of_proc%'

This will tell you in which schema you will find the stored procedure in. Even, if you want to look into the code you can do so by running the following query.

select text 
from 
    syscomments c
    inner join sys.procedures p on p.object_id = c.id
where 
    p.name like '%name_of_proc%'

The text field contains the code of the stored procedure.

Let me know in the comments if you find this helpful or if you have any other ways to find the stored procedures.

Searching Lowercase data in MS SQL Server

Few days back I came across a requirement to fetch the records from the table having all lowercase letters. This was interesting scenario. The SQL Server database by default is set for case-insensitive. But, I need to do case-sensitive search. Case sensitive search in SQL Server can be achieved in two ways. Either by using COLLATE or by using BINARY_CHECKSUM().

  • COLLATE is the T-SQL clause used to define collation.
  • BINARY_CHECKSUM() is a built-in system function used to compare the binary check-sum value.

In this article I will show you how to use both the options. In addition to lowercase search, I’ll show you the uppercase search and mixed case search as well. 

To start with the experiment, lets create a table.

CREATE TABLE [dbo].[MyTecBits_Table_1](

[Sl_no] [int] IDENTITY(1,1) NOT NULL,

[Name] [varchar](50) NULL,

[Description] [varchar](500) NULL

) ON [PRIMARY]

GO

Insert records some with all lowercase, some with all uppercase and some with mixed case.

insert into MyTecBits_Table_1 values (‘MYTECBITS’,’THISWEBSITEHASBITSANDPIECESOFTECHNICALINFORMATION’)

insert into MyTecBits_Table_1 values (‘mytecbits’,’thiswebsitehasbitsandpiecesoftechnicalinformation’)

insert into MyTecBits_Table_1 values (‘MyTecBits’,’ThisWebSiteHasBitsAndPiecesOfTechnicalInformation’)

insert into MyTecBits_Table_1 values (‘MY TEC BITS’,’THIS WEB SITE HAS BITS AND PIECES OF TECHNICAL INFORMATION’)

insert into MyTecBits_Table_1 values (‘my tec bits’,’this web site has bits and pieces of technical information’)

insert into MyTecBits_Table_1 values (‘My Tec Bits’,’This Web Site Has Bits And Pieces Of Technical Information’)

SQL Server Case-Sensitive Search

 

Now our test table with test strings with different case types are ready for our experiment.

Fetching all lowercase records:

Fetching only the rows having all lowercase in one of the column using COLLATE method.

select * from MyTecBits_Table_1 where Name COLLATE Latin1_General_CS_AI = Lower(Name)

Fetching only the rows having all lowercase in one of the column using BINARY_CHECKSUM() method.

select * from MyTecBits_Table_1 where BINARY_CHECKSUM(Name) = BINARY_CHECKSUM(Lower(Name))

See the results for lower case search:

SQL Server Case-Sensitive Search

 

Fetching all uppercase records:

Similar to fetching the lowercase string, we can search for uppercase string just by changing the LOWER string function to UPPER string function. See the example below.

Fetching only the rows having all uppercase in one of the column using COLLATE method.

select * from MyTecBits_Table_1 where Name COLLATE Latin1_General_CS_AI = Upper(Name)

Fetching only the rows having all uppercase in one of the column using BINARY_CHECKSUM() method.

select * from MyTecBits_Table_1 where BINARY_CHECKSUM(Name) = BINARY_CHECKSUM(Upper(Name))

See the results for upper case search:

SQL Server Case-Sensitive Search

Fetching only the mixed case records:

Just like uppercase and lowercase sensitive search, we can search for mixed case records by combining upper and lowercase search conditions.

Fetching only the rows having mixed case in one of the column using COLLATE method.

select * from MyTecBits_Table_1 where Name COLLATE Latin1_General_CS_AI != Upper(Name) and Name COLLATE Latin1_General_CS_AI != Lower(Name)

Fetching only the rows having all mixed case in one of the column using BINARY_CHECKSUM() method.

select * from MyTecBits_Table_1 where BINARY_CHECKSUM(Name) != BINARY_CHECKSUM(Upper(Name)) and BINARY_CHECKSUM(Name) != BINARY_CHECKSUM(Lower(Name))

See the results for mixed case search:

SQL Server Case-Sensitive Search

See my other articles on Database at https://mjawaid.wordpress.com/category/database/

[This article originally published here]

Resolving error in installing any gem by Ruby

After installing Ruby installer you might need to install some gems. For example if you are developing with RedHat OpenShift you want to install ‘rhc’ gem to access remote files on OpenShift. To install ‘rhc’ you would run following command.

>gem install rhc

But you might get following error specially on Windows machine.

>gem install rhc
ERROR:  Could not find a valid gem 'rhc' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur
ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
https://rubygems.global.ssl.fastly.net/quick/Marshal.4.8/rhc-1.15.6.gemspec.rz)
ERROR:  Possible alternatives: rhc

Solution

The problem is due to running over a secure (https) connection to rubygems.org. Look at the help for “gem sources –h”, remove the https version and add http://rubygems.org

Run the following commands to do this.

 

>gem sources --remove https://rubygems.org/
>gem sources --add http://rubygems.org/

And now you can easily install any gem.

Microsoft Windows 10 Great UI Changes

My first experience with Windows 8 inspired bafflement and frustration. But I walked away from my first few minutes with Windows 10 with a sense of jealousy. It looks like a significant improvement, and I want it on my PC right now.

Microsoft is launching Windows 10 as the new face of both Windows and eventually Windows Phone. At one point during Microsoft’s Tuesday press event, Terry Myerson, the executive vice president in charge of Microsoft’s OS group, called the new OS “our most open, collaborative OS project ever.” Collaborative, indeed. Microsoft is looking for user feedback, and what I demo’d on Tuesday may not be the same OS that customers receive next year.

Microsoft executives didn’t even characterize the system as an alpha; they referred to it as a “build.” So with Windows 10 tentatively scheduled to be launched around the middle of 2015, there’s quite a bit of time to change, remove or add features before the system launches.

windows10 tech preview start menuIMAGE: MICROSOFT
The Windows 10 Start Menu fues Windows 7 icons and Windows 8 Live Tiles.

That said, we can still point to various features that embody the new Windows 10 experience, and will almost certainly make the cut. These include the revamped Start menu; the new “task view,” virtual desktops and ALT-TAB features; windowed apps; and the new “snap assist” capability. Granted, I had a just a few moments to play around with each. But I quite liked what I saw, and if you sign up for the new Windows Insider program, you’ll have a chance to form your own impressions beginning on Wednesday.

The revamped Start Menu: clean, intuitive

I’m not wholeheartedly in love with the new Start Menu. Aesthetically, it looks like someone surgically conjoined the Windows 7 and Windows 8 experience. Move past that inelegance, however, and it’s darn useful. On the left, there’s a list of frequently used apps, along with shortcuts to PC settings, as well as your documents and pictures folders. At the bottom, there’s a shortcut to launch an “all apps” view.

On the right, the Live Tiles reproduce the functionality of the Windows 8 Start screen, with resizeable tiles that can dynamically show you how much unread mail is left. It appears that you should think of Live Tiles more like notifications rather than app shortcuts, although you can use them either way. Microsoft’s demo station had a large oversize tile showing the current calendar appointment, which seemed appropriate.

windows 10 start menu longMARK HACHMAN
If you want, you can resize the Start menu, increasing or decreasing its size and adjusting its position.

Also, if you want to resize the Start menu itself, you’re free to do so.

As some leaked videos foreshadowed, you can revert to the Windows 8 Start page, if you so choose. But that option wasn’t checked off, leading me to believe that most people would prefer the desktop experience.

A new Windows world: Task view, virtual desktops, and ALT-TAB

One of the Microsoft executives I talked to referred to the new “task view” as a “poor man’s multimonitor setup.” I can understand why.

Virtually all Windows users use ALT-TAB to quickly shuffle between windows. It’s a great way to move from one task to the next. That capability is still available in Windows 10.

windows 10 alt tabMARK HACHMAN
Using Alt-TAB to cycle through windows isn’t that different than Windows 8, but you can see more of what each window holds.

What’s different, however, is the new “task view” button. Down in the Windows 10 taskbar, third from the left, is a button that, when clicked, brings up an array of “virtual desktops.”

What’s a virtual desktop? Think of it as a virtual display.

If you’re running a multimonitor set-up, chances are you’re already allocating different applications to different screens: a browser window on one display, Outlook on another, and maybe a chat app on your docked notebook. But with Windows 10, Microsoft allows you to snap more than one app to a screen. So if you choose, you could fill a secondary monitor with an Outlook pane and a PowerPoint file that you’re referencing in an email to the colleague.

windows 10 taskbarMARK HACHMAN
The Windows 10 taskbar includes the Windows button, which launches the Start menu, the new Task View button, and the Search button. To the far right, the “underlined” apps show that they’re located inside a virtual desktop.

But if you have one monitor, tapping the task view button—or more usefully, Windows+TAB—swaps between desktops, which are displayed on the bottom of the display. So if you have a “project screen” with PowerPoint, a browser window, and OneNote all contained within it, you can swap to an entirely different virtual desktop, or workspace, perhaps with Facebook and Xbox Music. You’ll also notice the apps themselves are shown above the desktops themselves, so if you can’t remember what virtual desktop actually owned that app, you can just jump into it regardless.

There’s also a feature that may or may not make it to final release: On your taskbar, you’re probably used to instances of multiple browser windows stacked on one another. But in Windows 10, you may also see that app “underlined” by a horizontal bar, showing that it’s in a virtual desktop.

windows10 tech preview virtual desktopIMAGE: MICROSOFT
The new task view shows you your virtual desktops, and the apps contained within them.

For now, virtual desktops are a convenience, but they could also emerge as a security feature, allowing users to assign permissions to different ones. Microsoft officials wouldn’t tell me if they’ll be isolated from one another or “sandboxed” over time.

Snap snaps with Snap Assist and windowed apps

And what about Snap, the nifty little feature that fills half of a Windows 8 screen? That’s been improved as well. Every app in Windows 10 can be dynamically resized in a window, although it remains to be see how well this works in practice.

Windows 10 snap assistMARK HACHMAN
Snap a document to one side of the screen, and Snap Assist will suggest some others.

In Windows 8, apps can be snapped by clicking the Windows key and the left or right arrow, snapping them to the left or right of the screen. That fills half the screen. With Windows 10, up to four apps can be snapped per screen, maximizing your productivity.

What’s neat, though, is that once you snap an app, Windows 10 suggests another, similar app that you might want to snap next to it, from a small collection of windows. The feature is intended to save you the hassle of hunting about through menus to actually construct a virtual desktop. Time will tell whether these suggestions will prove useful, but it’s a good start.

You can see, however, that a number of different features—Snap Assist, windowed apps, virtual desktops—all flow somewhat organically into one another. I’m honestly interested to see what difference they make in my own daily workflow.

Last but not least: Search improvements

Windows 10 also adds a search button to the taskbar, moving the other major functionality of the Windows 8 Start page to the desktop environment. If you’re like me, you really don’t click icons on the Start page any more (or use bookmarks when searching the Web). Instead, “searching” for recent apps or documents is often quicker.

windows10 windows product family 9 30 eventIMAGE: MICROSOFT
Microsoft promises consistent experiences over a variety of form factors and screen sizes.

That approach is also found in Windows 10. Microsoft officials say that Search and File Explorer now displays your recent files and frequently visited folders, making finding files you’ve worked on faster and easier.

Granted, Microsoft’s Windows 10 demonstration was somewhat orchestrated to put its best face forward. But with potentially millions of eager Windows users prepared to bang away on it beginning Wednesday, any flaws will be quickly exposed. What’s refreshing is Microsoft is actually encouraging this, similar to the way in which “developers”—i.e., fans—were encouraged to take its latest Windows Phone builds for a spin.

Love it or hate it? Microsoft wants to know. But I think you’ll quite like Windows 10.

[This article was first published on PCWorld]

How can I test if mod_rewrite on my server is enabled and working?

Note that mod_rewrite can only be used with web server Apache. Follow the instructions below to check whether module mod_rewrite is installed and correctly configured on your server.

Create the file .htaccess and add these two lines

RewriteEngine on
RewriteRule ^testing.php$ modrewrite.php

This tells the web server to load modrewrite.php when testing.php is requested.

Create the file modrewrite.php with this line

<?php echo "mod_rewrite works"; ?>

Create the file testing.php with this line

<?php echo "mod_rewrite does not work"; ?>

Now use your web browser to load testing.php. If you see “mod_rewrite works” your server has a working mod_rewrite instance. If you see anything else, including an internal server error, your server is not properly configured for mod rewrite.