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.

Monday, October 21, 2013

Skype Metro App Crash on Windows 8.1 RTM

After installing Windows 8.1, I just realized there’s no Messaging metro app. I always use Messaging app to chat with my friends in Facebook Chat. Microsoft said that Messaging app has been replaced by Skype metro app, which is installed by default when you install Windows 8.1 RTM.

Unfortunately, my Skype app had a problem. After I tried to log in to Skype (using Skype metro app, not the desktop version), it crashed each time I launched the app. Each time I launched, it tried to log in (the rolling circles animation appeared) and then…BAM! it crashed!

Have I done something wrong? I just have installed Windows 8.1 RTM for a day.

After finding out for solution in Skype community forum, someone also had this problem, and he suggested to disable the webcam. Then, I tried it. Disable the webcam, and launch the Skype metro app again…and there it is…I can log in successfully to Skype!

Sunday, September 1, 2013

Delete all rows in HTML table

I have a HTML table which needs to be refreshed each time an Ajax post occurs, the table has ID: history.

$get("history").innerHTML = ""

If you don’t understand what is $get above, it is a shorthand for document.getElementById. Function $get is defined in Microsoft AJAX Library, see this for more info.


Code above works well in Firefox and Chrome, both of them accept that code happily to delete all rows in table, but if I run that code in Internet Explorer 8, a javascript exception will occur : “Unknown runtime error”.


IE8 cannot delete rows in HTML table by using innerHTML property, read this for detail info.


 


The solution for this issue is to delete manually all rows in a table using javascript loop, or if you use JQuery, you can make it simpler, you can call empty() method:

$("#history").empty()

Wednesday, June 19, 2013

Telerik Components didn’t update VS2012 Toolbox

This happened after install Telerik Q2 2013 components. Tried to drag a component from toolbox, and it showed nothing. Previous components (Q1 2013) was still registered in toolbox.

I tried to fix it by launch Toolbox Configurator:

image

but still, I could not see Q2 2013 components in toolbox.

Here is the solution: Try to delete all .TBD files in
C:\Users\<user name>\AppData\Local\Microsoft\VisualStudio\11.0

Then, restart Visual Studio 2012. In my case, Visual Studio repopulated the toolbox and Q2 2012 components finally registered in toolbox and Q1 2013 components disappeared.