C++ - std::sort with a non-static compare method

Usually when you want to sort a std::vector or another container thats holds objects of a custom datatype, you just write a compare function that takes two such objects, does something to find out if one is less than the other, and returns true if it is. Then you pass the address of this function to std::sort and voila.

C++ - Discovering Memory Leaks

If you are working on a serious project, you will propably use a sophisticated memory manager which will also discover memory leaks (along with their exact position in the code), but if you just want to do a quick test in a small program, there is an easy way to let the debugger check for memory leaks:
- Include crtdbg.h in your project (this file is included in the Microsoft Platform SDK)
- At the beginning of main() or WinMain () put this code:

int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flag |= _CRTDBG_LEAK_CHECK_DF; 
_CrtSetDbgFlag(flag);
This works in Visual C++ ( i don't know about other compilers though ) and, if you run the programm in debug mode, it will report memory leaks in the debug output window ("Immediate Window" in the latest Visual Studio version).

C++ - Bitmap Tutorial: Loading and Saving Bitmaps


1. Introduction

The windows bitmap file format (.bmp) is the most widely used image file format on windows (next to .jpg), and there are many occasions a program or game has to be able to load or save bitmaps ( raytracers and other non-realtime renderers should be able to save their output in .bmp format, games might have to load them as textures etc. ).
Unfortunately .bmp files are not as straightforward as for example .png image files and provide quite a problem for newbies since it's not that easy to figure out how to use them when without a library or API.

Two notes before we start:
1) In this tutorial we're dealing with 24 bit bmps only. But it shouldn't be hard to change the code to support other formats.
2) For clarity's sake i'm only showing the code important to the task at hand, with only minimal error checking. If you want to use this code in a real program, you should add some exception handling.

C# - Non-blocking Per-Pixel Painting in Windows Forms

WinForms gives us the PictureBox control, into which we can easily load images of different formats, have them scaled for us, etc.
But, unfortunately, PictureBox gives us no obvious way to paint it ourself via some SetPixel method.
In this article i will thus show you how to implement your own SetPixel method. As you will know, when you directly execute a long-running function, the user interface will be unresponsive (you won't be able to move the window, or click anything on it) until the function has finished running. When painting something, your paint method might be very long running (for example if you do raytracing), so we will do our painting in a background thread. This will only add a few lines of code, but keep the application running smooth.
Also, since there are different ways to achieve our goals, i will split this article up into two parts, showing you different methods of how to achieve the same effect.

For the rest of this article, i assume that we have a Windows Forms project, and that the form contains a PictureBox named pictureBox1, and a Button (named button1), which will start our test-rendering.

C# - How to Reverse a Unicode String


Perhaps due to the lack of a built-in String.Reverse method in the .NET Framework, it's very common for implementations of such a method to be posted.
Unfortunately, most of these implementations do not handle characters outside Unicode's Basic Multilingual Plane correctly. These supplementary characters have code points between U+10000 and U+10FFFF and so cannot be represented with one 16-bit char. In UTF-16 (which is how .NET strings are encoded), these Unicode characters are represented as two C# chars, a high surrogatefollowed by a low surrogate. When the string is reversed, the order of these two chars has to be preserved.
Here's our method that reverses a string while handling surrogate code units correctly:

C# - How to Reverse a String

Unfortunately, C#'s string class is missing a Reverse() function, so here are three ways to reverse strings:

1. Manual Reversal

The most obvious way is to reverse a string by manually walking through it character for character and building a new string:

string input = "hello world";
string output = "";
for (int i = input.Length - 1; i >= 0; i--)
{
    output += input[i];
}
Note that if you take this approach in a serious program, you should use StringBuilder instead of string, since in the above code, a new temporary string is created each time you add a single character to the output string.

C# - Booleans Without Short-Circuiting

C# implements the boolean AND and OR operations like C/C++ with the operators && and ||.
The 'single character' versions of these (& and |) are used in both languages for bitwise AND and OR operations.
But in C# the single character versions can be used for boolean logic too, but with a twist.
The standard boolean operators (&& and ||) try to make your code as efficient as possible, by employing short-circuiting, to skip evaluation where possible.
If we have a boolean AND expression with two arguments, we know that the expression as a whole is false if one (or both) of the arguments is false. Thus when the first argument is false, the end result is known, and the second argument is never evaluated.
With OR it's the other way around: if one argument is true, the whole expression is true. Thus if the first argument evaluates to true, the second argument isn't evaluated.
Consider this sample class:

C# - Efficiently Looping Over An Array

This tip can improve the speed of programs that spend a lot of time looping over arrays.

Propably you know from experience, that when you try to access an invalid array element (say, index 11 in an array of size 10) you will get an IndexOutOfRangeException. To be able to generate this exception and prohibit the dangerous access of memory beyond your array storage, the runtime performs an array bounds check everytime you access an array, which checks that the index you supply is lower then the array size.
For example, take a look at this code:

How to Optimize a Wireless LAN Card

A wireless LAN card or wireless adapter is a device that allows a computer to connect to wireless Internet signals. Wireless Internet speeds can vary based on the strength of the wireless signal that the wireless adapter detects. You can take steps to optimize your wireless adapter to improve signal strength and to obtain a faster Internet connection. There are a few different ways to improve a wireless adapter’s connectivity.

10 Tips For Improving Your Wireless Network


Having trouble getting a good signal with your wireless network? Before you dropkick the kitty, consider these ten tips on how to improve your signal range and strength.


1. Position your wireless router (or wireless access point) in a central location.
When possible, place your wireless router in a central location in your home. If your wireless router is against an outside wall of your home, the signal will be weak on the other side of your home. Don't worry if you can't move your wireless router, because there are many other ways to improve your connection.



How to set Apache not to log requests for images or javascript


Having around 100 visitors per day could make your apache logs very large and this would not be very pleasant for any web server admin. One thing you could do is to configure apache not to log requests for Images, java scripts or any other extension.

How to prevent visitors from viewing .htaccess and .htpasswd files

Hide .htaccess file by disallowing access to .htaccess files to browsers
Every .htaccess file from any web server out there will have sensitive data inside it. If .htaccess files are not protected by default, they can be accessed by anyone (just type in your borwser: http://www.site.com/.htaccess and, if this restriction is in place, you'll get a 403 Forbidden error).

How to Bypass BIOS Passwords


BIOS passwords can add an extra layer of security for desktop and laptop computers. They are used to either prevent a user from changing the BIOS settings or to prevent the PC from booting without a password. Unfortunately, BIOS passwords can also be a liability if a user forgets their password, or changes the password to intentionally lock out the corporate IT department. Sending the unit back to the manufacturer to have the BIOS reset can be expensive and is usually not covered in the warranty. Never fear, all is not lost. There are a few known backdoors and other tricks of the trade that can be used to bypass or reset the BIOS

Before attempting to bypass the BIOS password on a computer, please take a minute to contact the hardware manufacturer support staff directly and ask for their recommended methods of bypassing the BIOS security. In the event the manufacturer cannot (or will not) help you, there are a number of methods that can be used to bypass or reset the BIOS password yourself. They include:

Reveal *****(Asterisk) Password of a Web Page Using Javascript


Want to Reveal the Passwords Hidden Behind Asterisk (****) ?
Here's a quick and simple way
  •  Open the Login Page of any website. (eg. http://www.facebook.com)


  • Type your 'Email' and 'Password'.
  • Use the built in browser tool for displaying the the web page HTML source.
  • Locate the id of the password text box ("pass" in this case).
  • Copy and paste the JavaScript code given below into your browser's address bar and press 'Enter'.
javascript: alert(document.getElementById('pass').value);
  • As soon as you press 'Enter', A window pops up showing Password typed by you..!



TOP 12 Basic On-Site SEO Tactics for Optimized Results

There are many aspects of off-site search engine optimization that almost every SEO is familiar and aware of, including link building, blog commenting and social bookmarking and tagging for external meta data. Let’s not forget however, that there is an entire practice of site structure, keyword density and on-page factors as well.
There are many tactics one can work with to optimize site pages for on-page SEO which may result in a higher rank for each of your site’s web pages.
Here are the following tactics of on-page SEO :

Reinstall Linux Grub Bootloader After Windows Wipes it Out

If you run a dual-boot system with Linux and Windows, this has happened to you. You had to do your monthly reinstall of Windows, and now you don’t see the linux bootloader anymore, so you can’t boot into Ubuntu, Fedor or whatever flavor of linux you prefer.
Here’s the quick and easy way to re-enable Grub.
1) Boot with a Linux LiveCD
2) Open a Terminal and type in the following commands, noting that the first 2 commands will acquire permission to configure grub and put you into the grub “prompt”, and the next 3 commands will be executed there. Also note that hd0,0 implies the first hard drive and the first partition on that drive, which is where you probably installed grub to during installation. If not, then adjust accordingly.To do this easily, go “Computer Icon” on your desktop of “fedora” for example and count drives from 0 until reach the drive where installed grub.

Google Dork for Best Proxy Sites {Unblocked, Simple, Fast And No Ads}

In this post I will show you how to get thousands of web proxy sites with a single Google search.
Most of these proxies will be unblocked, simple, fast and of course have no ads.
Here is the first Google dork:
intitle:"glype proxy" "© 2008 glype proxy : Powered by glype"
As I think you guessed this will find all sites running glype proxy script all over the world.
The following shot is an example


Look at the number of results...Yes it's 58,000 results !!!
And here is a screenshot of one the previous sites


Now we come to another proxy script "PHProxy"
Here is the Google dork
>>>
intitle:"PHProxy"  URL      Include Form    Includes a mini URL-form on every HTML page Remove Scripts    Remove client-side scripting (i.e. Javascript) Accept Cookies    Accept HTTP cookies Show Images    Show images Show Referer    Show referring website in HTTP headers Rotate13    Use rotate13 encoding on the URL Base64    Use base64 encoding on the URL Strip Meta    Strip meta HTML tags Strip Title    Strip Website title Session Cookies    Store cookies for this session only New Window    Open URL in a new window
<<<
I know it's very long but it do well.
Here's a screen shot of "PHProxy"


Now I want to clarify that most of these proxy sites won't be blocked by your ISP
as it was made for personal use !!!
By Alaa Jamal

Buy with VirtaPay

Earn $20 per day by joining as an EarlyBird user in VirtaPay


Why you should join today...
  • You start with $25 in your VirtaPay account and it's free.
  • VirtaPay will add up to $20 per day to your account for participating as  preparing to launch the new service.
  • You get $10 per person you refer to VirtaPay.
  • You'll be an EarlyBird user—before VirtaPay opens to the public.
  • You'll help shape the development of the best virtual currency and payment system ever designed for the Internet.
  • You could have hundreds or thousands of dollars in your account by the time VirtaPay launch, without ever making a deposit!

Is there is a way to call assembly instructions from perl on Linux?!!!

I wonder if there is a way to call assembly instructions from Perl on Linux
like calling assembly from c or c++.
I put this question on yahoo answers and I got two "NO" answers.
I know that the first question will jump to your mind is "Why the hell you want to do this?!!".
OK, here is the answer. Suppose you succeeded to get a non root Linux shell and unfortunately
there is no c or c++ compiler installed but luckily Perl is available. I think it would be very helpful if
you could write assembly in Perl !!!

I found this code which is very close of what we'r talking about.
This code work well on windows and of course doesn't work at all on Linux.
This is because it depends on win32 API.