Install VMware Workstation 9 on Ubuntu 12.10

Easy installation of VMware Workstation 9 on Ubuntu 12.10

Set an application to work with only one processor (Windows 8)

How to set affinity to one processor for an application

A method to check performance in Windows

Check performance of Windows with Performance Monitor

Connecting a C# program with a SQL Server Database (multiline text box)

Detailed tutorial to connect a C# application with a SQL Server database

Sunday, April 21, 2013

An awesome calculator for iDevices

Yesterday I wanted to download a calculator for my iPad. I reviewed some apps from the App Store and found MyScript Calculator. This is coolest idea for a calculator.  You can write any mathematical calculation by hand in the screen, and the app will know what you want. This is exactly what you need if you want to solve, for example, something like this:
You would have to perform some different steps in a normal calculator, but with MyScript Calculator, all you have to do is this:
And what you get is this:
Awesome, isn't it?? Download the app here. It's free!

Friday, April 19, 2013

How to connect a SQL Server database with a DataGridView with C# (Visual Studio)

Note: If you want to know how to use a SQL Server database with a multiline textbox, read this.

This tutorial will show you how to show data in a DataGridView from a SQL Server database. Pretty simple. Just in case, the screenshots show Visual Studio in Spanish. That's the only version I have, but I think you can deduce the names of the buttons in English. It's very easy watching the screenshots.

Requirements:
  • Visual Studio 2012 (it's what I used).  You can get the express version here.
  • SQL Server 2012.  Get the express version here.  This is not necessary, but I recommend to install SQL Server Management Studio. I'm more comfortable using that tools to manage my databases in SQL Server. To get SQL Server Management Studio along with the other components, download ENU\x86\SQLEXPRADV_x86_ENU.exe or ENU\x64\SQLEXPRADV_x64_ENU.exe, depending of the architecture of your computer.
Steps:

1. Create a new database and fill it with some data

1.1 Open SQL Server Management Studio and connect to it.
1.2 Expand [Server]>Databases
1.3 Right click Databases>New Database...
I'll call my new database "TestoolsDB". Press OK.
1.4 Create some a table with a couple of columns. Create 3 rows of data. Of course, this is just an example:
The was supoused to be called "dummy_data", with double m, but anyway...it doesn't matter for this example.

2. Create a Windows Form

2.1 Open Visual Studio
2.2 Click on New Project
2.3 Select "Windows Forms", set a name for the solution and press Accept.  I named mine "GridExample":
2.4 Add a DataGridView (look for it in the Tool Box) to the Form.
2.5 Give it a name you can recognize. For example, "testGrid".
3. Create a new connection

3.1 Go to Project>Add new data source...
3.2 Select Database and press Next twice.

3.3 Press New Connection
3.4 Press Browse and select the database you created. It is possible that it is located in the default folder: C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA






3.5 Select your database and press Open. If you have problems with permissions or messages saying that the database is in use, check this. Anyway, all you have to do is grant permission for the .mdf and .ldf files.  If you see a message indicating that the database is in use, just enable the "auto close" feature in the database properties with SQL Server Management Studio. You can see a detailed explanation in this video.
3.6 Press Accept
3.7 Press Next in this screen:
3.8 Now, you will see this (well, in English):
Press Yes to coy the database to the project folder, or No to use it where it is right now. It's up to you. In this example, I'll press Yes.

3.9 Press Next. Now just wait.
3.10 Check "Tables" and press Finish
3.11 Open Server Explorer.
3.12 Highlight your database.
3.13 Copy the connection string in the properties of the new connection.
4. Write the code

4.1 Double click on the form (not the grid). This means that the code will be executed when the form loads. If you want to use a button, double click the button.
4.2 Write the following code. I'm showing the complete code, just in case you have any doubt:

I'm not going to explain the code, but you can read the comments and I'm sure you'll understand what is all about.

Once you have written the code, press F5 to see the results:
And there you have it!!! This simple trick can lead you to make more complex programs.

Wednesday, April 17, 2013

Set an application to work with only one processor (Windows 8)

One of my favorite video games of all times is Silent Hill 2. As you might know, Silent Hill 2 for PC is full of bugs, and you occasionally have to deal with it.  For example, the classic sound loop bug causes the music to enter in an endless sound loop, ruining a major part of the experience, because the soundtrack of this game is magnificent.

I spent several hours searching for a solution to the sound loop glitch, until I finally found an almost permanent solution: Change the game to work only with one processor.

I don't know the technical details, but I guess Silent Hill 2 was programmed to work with just one processor, since it was created when computers had no more than one processor.

You can use this simple trick to troubleshoot problems with other old programs, or maybe when testing something.

Note: I'll use Silent Hill 2 as example in this article.

Requirements:

A Windows 8 machine.

Method 1:

1. Open the application. In this case, Silent Hill 2.

2. Press Alt+Tab or Control+Esc.  This will take you out of the program (or game).
3. Open Task Manager.
4. Open the "Details" tab.
5. Look for the program for which you want to set affinity. In this case, it's sh2pc.exe.
6. Right click the program.
7. Press on "Set affinity"
8. Select only CPU 0. Press OK.
9. Go back to the program or game and it will work with only 1 processor. This trick eliminates the sound loop most of the times in Silent Hill 2 for PC.

Method 2:

You can create a shortcut to start a program directly with the desired affinity:

1. Right click on the desktop>New>Shortcut
2. In "Type the location of the item" enter:

[path] /C start /affinity 1 [executable]

In my case:

"C:\Program Files\Konami\Silent Hill 2\sh2pc.exe" /C start /affinity 1 sh2pc.exe


Just in case, I'm using quotation marks because the path contains blank spaces. An error message will be displayed without the quotation marks.
3. Press Next
4. Give a name for the shortcut and press Finish.
5. To verify if this is working, double click the shortcut you just created.
6. Get out of the application by pressing Alt+Tab or Control+Esc.
7. Open the Task Manager and verify the affinity in the Details tab (just like in the first method).

I hope this is useful for everyone!

Monday, April 15, 2013

"Testing" Windows 8 on an iPad

If you want to develop for Windows 8, you'll notice that testing your app in a real tablet is essential. With this in mind, I found a great app a couple days ago. Its name is Win8 Metro Testbed.

What this app does is just amazing. It streams Windows 8 to the iPad, in order to get a real tablet impression with all the required details. The gestures work very smoothly in the iPad, and it feels like you have installed Windows 8 in your Apple tablet.

One of the best features of this app is that music, videos and everything work like you have the Microsoft OS in your hands. I tried some remote connectivity software before, like LogMeIn, but none of them works as you would wan them to.

For example, I wanted to watch some videos from my PC. I used LogMeIn, but the frame rate is lame. Then I tried VLC Streamer. The problem with this app is that video lose sound quality, so you have to convert your video to transfer them to the iPad anyway.

Unfortunately, Win 8 Metro Testbed only works with Windows 8.  But it's worth trying it, especially when you are developing some apps in Visual Basic or C#. Remember that you have to install a streamer in your PC. Get it here.

Sunday, April 14, 2013

Creating "batch" scripts for Linux (Ubuntu)

I'm sure that most of you have used a batch file at least once in Windows. They are simple but very convenient script files to automatize some tasks. Linux has an advantage: Its powerful bash. You can even make simple programs with it. And, since you have to write a lot of things all the time, a script is very, very useful as "shortcuts" for some tasks.

This tutorial will show you how to create bash scripts for Ubuntu, but I'm sure these can be used with other Linux distros too.

Requirements:

A Ubuntu machine. I'm using Ubuntu 12.10.
Before using the script that I'll use as an example, you need to install some packages. To do that, open a  terminal and type:

sudo apt-get install --no-install-recommends gnome-panel

Then press enter.

Steps:

1. Prepare a script you would like to use. I'll use a script to make shortcuts on the desktop:

gnome-desktop-item-edit --create-new ~/Desktop

2. Click on Dash Home
3. Type "gedit"
4. Click on "Text Editor"
5. The Text Editor will be opened.  Enter the following text in the Text Editor:


#!/bin/bash  
command

In my case, I typed:

#!/bin/bash  
gnome-desktop-item-edit --create-new ~/Desktop
As you can see in the last picture, I saved it on Home/Documents/Scripts and named it "createShortcut". Save the file somewhere you can access easily. Remember that you don't need to write any extension.

6. Open the terminal. Go to the folder that holds your script.
7. Type:

sh nameOfTheScript

In my case:

sh createShortcut

And that's it. The command will be executed and a simple dialog to make a new launcher on the desktop will be displayed. This is just a super simple example. You can discover your own possibilities!

Related Posts Plugin for WordPress, Blogger...

 
Hyper Smash