22/10: Ejecting the CD Using Code
There is a simple and easy way to open/close the CD/DVD in Windows. The code I will be writing is a C++ code. It uses a simple API function implemented in winmm.dll (The windows MCI API DLL). In order to achieve our goal, we are going to use the mciSendCommand function.
First you need to include mmsystem.h in your code and you also need to link with Winmm.lib
First you need to include mmsystem.h in your code and you also need to link with Winmm.lib
This is an interesting trick in order to swap two integer numbers stored in two variables. using a temporary variable, swapping two values x and y would typically be like:
int temporary = x;
x = y;
y = temporary;
int temporary = x;
x = y;
y = temporary;
31/05: Diagonistics Windows Boot
I came accross this small Windows hack to make it boot without the spash screen! Instead, you will be shown the drivers being loaded. Here are the steps:
15/12: Powerful Javascript !!
Did you know that you can do 3D animations using Javascript only? Well I didn't know until I saw this!
The page has a 3D rendering and animation of some triangles. I find the speed not bad also considering Javascript.
The page has a 3D rendering and animation of some triangles. I find the speed not bad also considering Javascript.
30/11: A nice Javascript code
The following small script does an 'earthquake' :)
Copy and paste the following line into your URL address in IE
javascript:function Shw(n) {if (self.moveBy) {for (i = 35; i > 0; i--) {for (j = n; j > 0; j--) {self.moveBy(1,i);self.moveBy(i,0);self.moveBy(0,-i);self.moveBy(-i,0); } } }} Shw(6)
Copy and paste the following line into your URL address in IE
javascript:function Shw(n) {if (self.moveBy) {for (i = 35; i > 0; i--) {for (j = n; j > 0; j--) {self.moveBy(1,i);self.moveBy(i,0);self.moveBy(0,-i);self.moveBy(-i,0); } } }} Shw(6)
I have discovered an bug that would crash the SQL Enterprise Manager. The version I have tested this on is 8.0. I am not sure if other versions are affected by this. The bug is in the parsing of SQL statements in DTS packages.
A trick to use in web pages is to pre-load all images when the page is loaded. Why is this important? Well when you are using dynamic images (such as images that show up when the user moves over a specific object) you don't want the user to wait until the user moves over that object to load the image so that the user dosen't wait!
How is it done?
How is it done?
07/07: Spoofing Net Send Messages
Have you ever sent messages accross a network using built in Windows Net Send? Net send is an a small utility integrated with Windows machines that is used to send small text messages accross a network.
In order to use it, all you need to do is to click on start, then run and type the following:
net send MACHINE_NAME MESSAGE
where MAXHINE_NAME is the name of the Windows station where the message is to be sent
and MESSAGE is the actual message
Let us discuss this more from a technical point of view:
In order to use it, all you need to do is to click on start, then run and type the following:
net send MACHINE_NAME MESSAGE
where MAXHINE_NAME is the name of the Windows station where the message is to be sent
and MESSAGE is the actual message
Let us discuss this more from a technical point of view:
Here are some tips to write reusable code:
1. Comment, comment and then comment more! Comments inside code are very important. Even you will not be able to understand your code after a few months or years! Explain complex steps and algorithms line by line so that even if one dosen't know how to code understands what you are doing.
2. Choose your variable names and function names properly. Choose meaningful names for variables and functions so that they are self explanatory. Capitalize properly. For variables use a standard to show the type of the variable in its name.
3. Structure your code and split complex tasks into several simpler tasks.
4. Try to split the business layer from the presentation layer. Putting design aside will make your code clearer and easier to understand.
5. Remove all un-needed and repeated code. Try to optimize your code removing any lines that are not used or multiple lines that can be joined into one line.
6. Think in term of modules and black boxes. Split each module on its own and define what it does, its input and its output and how it is linked to other modules.
7. Structure into classes and interfaces. Be clear what each class does and how it is used, what are its methods and what do they do.
1. Comment, comment and then comment more! Comments inside code are very important. Even you will not be able to understand your code after a few months or years! Explain complex steps and algorithms line by line so that even if one dosen't know how to code understands what you are doing.
2. Choose your variable names and function names properly. Choose meaningful names for variables and functions so that they are self explanatory. Capitalize properly. For variables use a standard to show the type of the variable in its name.
3. Structure your code and split complex tasks into several simpler tasks.
4. Try to split the business layer from the presentation layer. Putting design aside will make your code clearer and easier to understand.
5. Remove all un-needed and repeated code. Try to optimize your code removing any lines that are not used or multiple lines that can be joined into one line.
6. Think in term of modules and black boxes. Split each module on its own and define what it does, its input and its output and how it is linked to other modules.
7. Structure into classes and interfaces. Be clear what each class does and how it is used, what are its methods and what do they do.
I was looking at the site http://www.assetz.co.uk/ and noticed the background with a fading effect and wanted to know how it was done!
I snooped into their code and found that it is was done using 3 lines of css:
background-attachment: fixed;
background-image: url(images/bg.jpg);
background-repeat: repeat-x;
and the image/bg.jpg was a simple image (http://www.assetz.co.uk/images/bg.jpg) having the fade effect! what the css does here is that it fixes the background not allowing it to scroll with the page and allows it to repeat itself only in the x direction which gives the page this nice background.
Actualy the bg.jpg image can be smaller in the width (but I believe that will make the page rendering slower).
I snooped into their code and found that it is was done using 3 lines of css:
background-attachment: fixed;
background-image: url(images/bg.jpg);
background-repeat: repeat-x;
and the image/bg.jpg was a simple image (http://www.assetz.co.uk/images/bg.jpg) having the fade effect! what the css does here is that it fixes the background not allowing it to scroll with the page and allows it to repeat itself only in the x direction which gives the page this nice background.
Actualy the bg.jpg image can be smaller in the width (but I believe that will make the page rendering slower).