Tuesday, November 26, 2013

Zooming

If you have been doing public presentation using projector and laptop, you may want to zoom an area or region to make the audience pay attention for some details in your screen. Usually, the presenter will change zoom level of projector, or the presenter will change the font size of the presentation document.

Actually, Windows has a built-in zoom feature that you can activate it easily with single keystroke. The built-in zoom tool is Magnifier and you can activate it by pressing Windows and Plus key. The plus key usually placed beside backspace button.

image

If you press Windows-Plus once, you will activate Magnifier and your screen has not zoomed yet. Press it for the second time will zoom your screen.

You can bring your screen to normal size (zoom out), either by pressing Windows – Minus or close the Magnifier window.

The other tool to zoom your screen is ZoomIt from SysInternals tool, and you can download and using it freely. With ZoomIt, you can define your own keystroke for zooming-in and zooming-out.

image

The Ctrl-1 is the default keystroke for toggle zooming.

Friday, November 22, 2013

Removing USB Drive

Sometimes I’m too lazy to remove USB drive using taskbar. We can remove USB drive from taskbar by clicking Safely Remove Hardware and Eject Media.

image                image

but as I said, sometimes I’m too lazy to do it and I prefer remove it by using command line since I can do it immediately rather than moving my pointing device.

The command line tool can be downloaded from here.

Using this tool, I can remove my USB drive or other removable drive from command prompt:

image

we can also invoke it using PowerShell:

image

Thursday, November 21, 2013

Say goodbye to Winamp

This is very sad news. Winamp will be discontinued and no longer available for download officially, except from unofficial sites. I had always install this software when I used Windows 95 and Windows 98. It is well known as a lightweight software to play MP3 and it has great visualizations and equalizers. I also have used Winamp to rip CDs.

This sad news came from winamp.com:

image

Wednesday, November 20, 2013

How to Create CLR Stored Procedure

Since SQL Server 2005, developers can write stored procedures using .NET languages. In this post, I will show you how to create stored procedure using C# using SQL Server 2008 R2 and Visual Studio 2012. If you use newer version of SQL Server, the solution should also be applied. I will create factorial function as applied in Math such as:

5! = 5 * 4 * 3 * 2 * 1 = 12

First, we have to download SQL Server Data Tools (SSDT). At this time of writing, I use SSDT for Visual Studio 2012 October Release which can be downloaded from here.

Then, launch SSDT setup and wait until finished.

Launch Visual Studio 2012, create new project, select SQL Server template, and select SQL Server Database Project.

image

Since I’m using SQL Server 2008R2, I have to change target framework to .NET Framework 3.5. Change the name to SPFaktorial and click OK to create the project, Visual Studio 2012 will create the Database Project for you.

In Solution Explorer, right click in project, click AddNew Item, select SQL CLR C#, then select SQL CLR C# User Defined Function.

image

Change the name to Faktorial and click Add, Visual Studio will create a C# file contains some dummy codes. We can change this code to our factorial function:

   1:  using System;
   2:  using System.Data;
   3:  using System.Data.SqlClient;
   4:  using System.Data.SqlTypes;
   5:  using Microsoft.SqlServer.Server;
   6:   
   7:  public partial class Matematika
   8:  {
   9:      [Microsoft.SqlServer.Server.SqlFunction]
  10:      public static SqlInt64 Faktorial(int f)
  11:      {
  12:          if (f == 1)
  13:              return f;
  14:   
  15:          return f * Faktorial(f - 1);
  16:      }
  17:  }



Our factorial function is a recursive function, it will call itself until the factorial number turns 1.


Let’s build the project! Select Build menu, then select Build Solution. If you see in project folder, Visual Studio will create Debug folder which contains compiled .NET assembly inside.


Actually, we can directly deploy our project to SQL Server, but in this post I will show you how to manually deploy our .NET assembly to SQL Server.


Lets launch the SQL Server Management Studio and connect to the Database Engine and open New Query window, then issue this command:

exec sp_configure 'clr enabled', 1
go
reconfigure
go



The command above will enabling CLR feature (which is disabled by default).


At this point, we are ready to deploy the .NET assembly to SQL Server using CREATE ASSEMBLY:

create assembly SPFaktorial
from 'D:\Docs\visual studio 2012\Projects\SPFaktorial\SPFaktorial\bin\Debug\SPFaktorial.dll'



Press F5 to run the command, then we have to create T-SQL function to wrap the CLR method:

create function Faktorial(@i int) returns bigint
as external name SPFaktorial.Matematika.Faktorial



Press F5 to run the command.


At this point, the .NET assembly has been deployed successfully to SQL Server, the next step is to test it:


image


Voilla….our C# method has been successfully executed inside SQL Server.


The sample code can be downloaded from here.

Friday, November 15, 2013

Windows 8.1 Shut Down Behaviors

I just noticed that in Windows 8.1 there’s different behavior between shutting down using Charm Bar and Power User menu.

As you know, Power User menu can be opened using Windows + X keystroke. There’s Shut Down option in “Shut Down or Sign Out” menu.

image

If I shut down using Charm Bar, Windows 8.1 will shut down using hybrid-mode. This behavior is also default shut down behavior in Windows 8.

But if I shut down using Power User menu, Windows 8.1 will perform “full shut down”, it acts like prior Windows 7 shut down behavior.