Wednesday, July 9, 2008

Some Stuff You Should Know About Windows XP - Part1

In this article we will discover some secrets about Windows XP. I believe most of you know some of these stuff or even all of it but I think it's very useful to know it anyway. If you have any new stuff just send it to me and I will add it in a new post.

1 - Rename Folders or/and Files in one step

a-Select all the Folders and Files that you want to rename them.
b-Press right click on the first Folder or file and choose Rename then rename it with any name for example "MyDoc".
c-Now Windows XP will rename the rest of the Folders and files automatically.
d-The name of the Folders and Files will be like this (MyDoc1,MyDoc2,...)

2 - Bigger size for Thumbnails

When you set the View of any folder to Thumbnails, the names of the files appear underneath it. You can show the files without their names underneath it, just press the Shift key and hold while you open the folder which contains the Thumbnails files.

3 - Get rid of "Thumbs.db" files

When you open a Folder with Thumbnails View Windows XP create a file named Thumbs.db, which contains some information about the folder, in order to accelerate the performance next time you open the Folder.

If you want to make Windows XP to stop creating these files do the following:

a-Open My Computer.
b-From Tools choose Folder Options.
c-Choose View Tab.
d-Advanced Settings -> Files and Folders -> Do Not Cache Thumbnails.
check it and press OK, this would prevent Windows XP from creating the Thumbs.db files again.

4 - Choose the Details of the Details

When you choose to show a Folder with Details View, you can specify which details to show and which to hide. To do so go to View and click on Choose Details.

5 - More Windows Components

For unknown reason Windows XP hides some of the Windows Components, in the Add/Remove Program.
To show all the Windows Components go to Windows Folder then open Inf Folder.

Look for sysoc.inf file open it and delete the word Hide from it save it then go to Control Panel open Add/Remove Programs then click on Add/Remove Windows Components.

Now you can see there are some new components you can see.

Please visit my Blog frequently to see Part 2.

Monday, July 7, 2008

Five rules of variable naming

1. Make your variable names long and descriptive

Visual Studio has IntelliSense, Eclipse has its own code completion, and I'm sure whatever IDE you're using can finish your variable names off for you, too. Using long names prevents the ambiguity of short or cryptic names.

2. Put units in your variable names

If you are writing an engineering application you are going to be using variables with units. Embed the unit name in the variable, for example, distanceInMM.

3. If you are using Camel Case, don't capitalize commonly hyphened, or combined words

Let me explain.Callback is normally spelt as one word. So, pretty please, don't call your variable callBack.

4. Never, ever use the variable name temp

The only perfectly valid exception to this rule, is when you're writing a swap function.

5. int i is perfectly valid in a small loop

I've met programmers who would crucify me for saying this, but when your loop is half a dozen lines of code long or less, int i is perfectly valid as a loop counter. It's so widely used, it's almost expected.


Saturday, July 5, 2008

JavaScript Code In Address Bar!

Go to choose Images and type Flowers, press search images button then copy and past this code in your browser Address Bar then press enter and Enjoy!

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px";*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);

You can do this with any page has photos in it.

Thursday, July 3, 2008

Kill Database Connections

In some cases you want to delete or detach database in order to move it to another place.
But you can't do it if there are connections open with this database so you can use this procedure to kill all the connections with the database.
CREATE PROCEDURE [dbo].[killDataBaseConnections] @DatabaseName VARCHAR(50), @WithMessage BIT=1 
    DECLARE @spidstr VARCHAR(8000)
    DECLARE @ConnectionKilled SMALLINT 
    SET @ConnectionKilled=0 
    SET @spidstr = '' 
    IF DB_ID(@DatabaseName) < 4 
        PRINT 'No can do...'
    SELECT @spidstr = COALESCE(@spidstr,',' ) + 'KILL ' + CONVERT(VARCHAR, spid) + '; ' 
    FROM [master]..sysprocesses
    WHERE dbid = DB_ID(@DatabaseName) IF LEN(@spidstr) > 0
        EXEC(@spidstr) SELECT @ConnectionKilled = COUNT(1) FROM [master]..sysprocesses
        WHERE DBID = DB_ID(@DatabaseName)
    IF @WithMessage = 1 
    PRINT CONVERT(VARCHAR(10), @ConnectionKilled) + ' Connection(s) killed for DB ' + @DatabaseName
Note: Don't do this if the database on a production server.

Tuesday, July 1, 2008

Fourteen ways to be a Creative Programmer

1. Learn a new language

Programmers are constantly learning new languages, either for fun or necessity. Don’t limit yourself to what just what you know and are comfortable with. Branch out and learn a new skill.

2. Start from the ground up

If you’re going to write software, you can’t just start halfway through the project. You have to start at square one. Sometimes this is the best way to find a creative solution for a problem is to go back to the beginning and work forward.

3. Question everything

Questioning everything means taking every assumption and making sure it’s correct. All programming starts with making the most basic assumptions, and then building on those basic assumptions. If something is wrong with the code at the base, then the software isn’t going to work well at all.
Sometimes creativity is limited by assumptions. New solutions arrive when we tear down assumptions and start with fresh perspectives.

4. Do it for fun

If you know any programmers, they’re constantly building something. Even when they’re done for the day on work-related projects, they’ll spend hours of time working on fun projects for themselves. Their work is also their hobby.

Continually mulling over new ideas and solutions is something that shouldn’t be a chore. It should be something that you find yourself doing constantly, like a reflex. And it should excite you.

5. Never stop testing ideas

Programmers are constantly benchmarking code to make sure that it’s as efficient as possible. Even the smallest change can bring a program or Web site to it’s knees, so constant testing and improvement is important to any bit of software.

Ideas should be tested rigorously and refined on a consistent basis. Your ideas will change over time, it just depends how much. Constantly evaluating them and just plain thinking them through is a great way to “benchmark” your idea.

6. Find a passion

If you’ve ever spent more than two minutes talking with a programmer about his work, you’ll find out very quickly that programmers have a passion for what they do. They eat, sleep and breathe programming.
Do you have a passion for your ideas and projects?

7. Master your tools

Programmers constantly improve their knowledge and usage of their tools. A great coder keeps tabs on software and is constantly finding ways to improve his usage of them. You’ll seldom find a programmer who doesn’t tweak his toolbox regularly.

No matter what your skill set, you’re limited to your skill with the tools you use to create. The more of an expert you are with your tools, the more you’ll be able to create.

8. Start making abstract associations

What if you used computers as telephones?
What would happen if you used a web site as a Word processor?
Would people care about what other people are doing right now?
The people behind projects like Skype, Google Docs and Twitter all have one thing in common: They fused seemingly abstract concepts together. Taking what-ifs and testing them is a great way to start thinking of things in a different, more creative light.

9. Think of structure as a tool, not a limitation

People associate creativity with taking a giant, blank canvas and letting our ideas flow without any sort of limiting structures. However, there’s a huge problem with this type of thinking: It’s a great big creativity myth.
See, limitations are everywhere.

We can’t avoid them, we can only hope to work with them. A programmer embraces the limitations of his programming language or tools and works around them. These limitations help him as they make a foundation to work from. Sometimes discovering a new workaround will lead to an even bigger idea. Necessity is the mother of invention.

10. Don’t rule anything out until you try it

Your kindergarten teacher was right: There is no such thing as a stupid question. If you’re adhering to #3 and dismissing all assumptions, you can’t be certain it’s not going to work until you’ve tested it. How do you know it won’t work unless you try it? You might be surprised. Even if the proposed solution doesn’t work, it may help you find a solution.

Sometimes it’s just best to start with a prototype and try it out. If your prototype doesn’t work, then trash it. If it does, you’ll have stumbled upon something that just might work.

11. Always look for a simpler and more elegant solution

A good programmer is one that understands that finding the simplest solution is always going to be better. Complicated solutions lead to… complications. A practical approach to programming always works best in the long run.

Our ideas sometimes become too complicated. We get caught up in the novelty of the idea that we ignore how practical it really is. The simplest way to solve a problem is often the best way to solve a problem.

12. Don’t be afraid to build off the code of others

The beauty of the Internet is that the solution your looking for has probably already been done by someone else. When building a new site I almost always use pre-existing open source code. Why recreate the wheel?
Putting a great idea into motion doesn’t mean you have to start from scratch to create it. Use existing ideas and turn them in to something better.

Sometimes a great idea is only modifying something that’s already been done. Gmail is a great example. They “reinvented” email by adding useful features to traditional email.

13. Don’t be afraid to collaborate

Some of the best coding — or any creative projects for that matter — are done not just by one coder but by many excellent people inspired to work toward the same goal. Assemble a great team, use the most brilliant ideas no matter who they come from, and let everyone contribute.

14. From the very basic, create the beautiful.

Programmers often use some very basic code over and over, and while those small bits of programming language aren’t necessarily beautiful in and of themselves, they can come together to create a final product that is amazing. No matter what creative project you’re working on, pay attention to the details, but most especially pay attention to the effect those details have on the overall picture.