Instant Payday Loan Lenders Instant Payday Loan Lenders

Auto formatting XML

Sometimes, I have to read unformatted XML. This always makes me angry, as I have to spend a lot of time pressing the enter key and what not. I found 2 tricks that could help you out.

Trick 1:
Use notepad++

Its a nice text editor, and it add itself to the right-click in windows, so you can open appropriate files with it very easily without changing your default editor.

Trick 2:
First, I just wanted to put everything onto a new line. I took the easy way. Press ctrl+H for Replace, or click Replace in search. Click on the option for “Regular Expressions”. Then, in the Search, put “><" and in the replace, put ">/n<"


That still doesn't help the indenting however, so I abandoned this approach.

Trick 3:
This is the best one. In notepad++, click Plugins -> Plugin Manager -> Show Plugin Manager. Scroll down and install “XML Tools”.

Once this is installed, select all on your text that you want to format, then click Plugins -> XML Tools -> Pretty Print (XML Only with Line Breaks)

Ahhh yes, this is what I wanted all along! Hope it helped!


ViewSwitchers revisited

ViewSwitchers revisited

Welcome to the shiny new blog!  I have decided to embrace my developer spirit and break free of the bonds of, and begin to maintain and hold my own data, rarrr!  In light of this, I am slightly modifying the most popular post of all time, the ViewSwitcher.

For far too long, the ViewSwitcher has eluded many people. It can be conceptually hard to tackle, as you still are only using one Activity, but you can essentially have 2 different layouts.

Why would you want to do this? Previously, I had used to ViewSwitcher to switch from a loading screen to the loaded screen. Since then, I have used the ViewSwitcher a few more times, but under different circumstances. I’ve also even found more switchers that I never even realized existed.

With this new example, I will reintroduce the ViewSwitcher, as well as a TextSwitcher, and an ImageSwitcher! O boy….

This is a one activity program, the entire activity is below. All fairly standard variable declaration and initialization, grabbing the ID from the id we give it in the xml file later.

One thing I have learned, is that if you don’t need global access to your buttons, don’t declare them globally! As you see in this example, the switchers are global, but the button is a local variable! Once applications get bigger, making these local declarations makes a smaller footprint for your application.

public class ViewSwitcherActivity extends Activity {

	ViewSwitcher mViewSwitcher;
	TextSwitcher mTextSwitcher;
	ImageSwitcher mImageSwitcher;

	public void onCreate(Bundle savedInstanceState) {

		mViewSwitcher = (ViewSwitcher) findViewById(;
		mTextSwitcher = (TextSwitcher) findViewById(;
		mImageSwitcher = (ImageSwitcher) findViewById(;

		Button button = (Button) findViewById(;
		button.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

Here, you can see the layout of the main.xml file. Each switcher can have a MAXIMUM of 2 parent views. You can try to add a 3rd, and you will see your program crash. That doesn’t mean you can’t have more than two views, it just means there can only be 2 parents, eg: 1 linear layout and 1 relative layout, and they can be filled with as many views as you’d like.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
    	android:text="Switch the view!"
    		android:text="This is the 1st view!"
    		android:text="This is the 2nd view!"
    		android:text="This is the 1st view!"
    		android:text="This is the 2nd view!"

Here are the 2 icon resources used in the demonstration


And that’s it! I hope you guys have enjoyed this little revisit of a classic post! Download the source below, post your comments!

Download the source!


Pizza box chassis

Pizza box chassis

Pizza box chassis

The top is a screenshot of a document from work outlining different chassis sizes and their byte value to set for programming. I thought it was a joke because engineers have the weirdest joke. The bottom is a picture of an actual pizza box computer. And it’s running Linux. *shudders* I’m not surprised though. Needs moar bell peppers.

Formatting and Styling Strings (C#)

We’ve discussed different ways to format a string using printf for C++ and string.format for Java/Android and since I’ve been working with C# recently I would add that to the blog as well.

In C#, it’s just like Java/Android: use string.Format(). Instead of dollar signs, you would use curly brackets with the parameter number. What’s nice is that you don’t really need to worry about the type. For example:

int foo = 9000;
string bar = "sparta";

string fubar = string.Format("This is {0}! It is over {1}!", bar, foo);

Would result with:

This is sparta! It is over 9000!"

See how I didn’t need to tell it {0} was a string and {1} was an integer? You can also add the format inside the curly bracket if you wish such as:


Where index is the index of the value to use; length is the amount of spaces you want this variable to take up; and formatString is a standard or custom string that can be used to do more formatting (such as setting up a date in US or EU format).

As usual, if you’d like to know more about the details, visit MSDN for more reading.

Android: Dialog Box with an EditText

Android: Dialog Box with an EditText

A simple code snippet I found over at, shows how to create a dialog box with an EditText in it. I needed it to save a user’s login name into the preferences when first starting a program, but it pretty much has a limitless amount of uses.

Try playing around with setting different types of views to your dialog boxes. You’ll be surprised! Combine this with the techniques used in the AddContentView example and you can start adding some really unique layouts and stylings to your dialogs.

AlertDialog.Builder alert = new AlertDialog.Builder(this);


// Set an EditText view to get user input
final EditText input = new EditText(this);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
  String value = input.getText();
  // Do something with value!

alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int whichButton) {
    // Canceled.

-Kevin Grant

Crypto++ and Linux

This week I’ve re-acquainted myself with Linux at work in order to port an app from Windows to Linux. Besides the aggravation of setting up the OS, IDE, and workflow, I had to use a 3rd party library called Crypto++. Well, it wasn’t obvious to set up or figure out so I’d put this out there in case someone has the same problem.

Basically I was able to include the files, but I got a linker error despite including the files in the project file in Qt. This is the error:

g++ -o encrypter -L/usr/lib -Lcryptopp -lcrypto++ -lQtGui -lQtCore -lpthread
encrypter.o: In function `CryptoPP::AllocatorWithCleanup::allocate(unsigned int, void const*)':
encrypter.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEjPKv[CryptoPP::AllocatorWithCleanup::allocate(unsigned int, void const*)]+0x2b): undefined reference to `CryptoPP::AlignedAllocate(unsigned int)'
encrypter.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEjPKv[CryptoPP::AllocatorWithCleanup::allocate(unsigned int, void const*)]+0x38): undefined reference to `CryptoPP::UnalignedAllocate(unsigned int)'
encrypter.o: In function `CryptoPP::AllocatorWithCleanup::deallocate(void*, unsigned int)':
encrypter.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvj[CryptoPP::AllocatorWithCleanup::deallocate(void*, unsigned int)]+0x25): undefined reference to `CryptoPP::AlignedDeallocate(void*)'
encrypter.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvj[CryptoPP::AllocatorWithCleanup::deallocate(void*, unsigned int)]+0x32): undefined reference to `CryptoPP::UnalignedDeallocate(void*)'
collect2: ld returned 1 exit status
make: Leaving directory `/home/alex/projects/encrypter'
make: *** [encrypter] Error 1
Exited with code 2.
Error while building project encrypter
When executing build step 'Make'

The proper way to include crypto++ is NOT to download it from the website. Use terminal to get the library:

sudo apt-get install libcrypto++8 libcrypto++8-dbg libcrypto++-dev

Then check if installed on system:

apt-cache pkgnames | grep -i crypto++

Which should result with:


If the information above is different (which is possible if it becomes out of date), check the Crypto++ Linux wiki for instructions.

Now add the library to project with the following linkage (written as a makefile macro, but just put the -L and -I parts in the command line if you’re compiling manually):

LIBS += -L/usr/lib/crypto++ -lcrypto++
INCS += -I/usr/include/crypto++

While is is rather specific, someone out there is probably searching for this so here ya go!

Want to learn C#?

I’ve been wanting to learn C# for a while so I finally started learning it a few weeks ago. I lightly touched C# back in the fall of 2009. We had a quick crash course trying to get a XNA game working thinking that was the best way to make a game in two weeks. That was a very terrible learning situation and I haven’t thought much about C# since then. Once I decided to take a shot at it again, I was definitely a lot wiser than I was 1.5 years ago. Now that I’ve got some good C++ programming, MFC UI development, and Visual Studio usage skills down, jumping into C# was not as hard as it was when I first came across it. Actually, working with C# in Visual Studio is so much easier than C++ and MFC that I feel like I’ve been converted to a new religion. Seriously, how did I live without this all my programming life?! String conversions, getting file paths/names/extensions, and capturing events are just one call away instead of some hackjob conversion and string parsing! C++ and MFC is like driving a Volvo 240: solid, reliable, and old, but hard to work on and possibly relies on hackjob repairs to make things work. C# with .NET is like a brand new Volvo S60: new, easy to use (from the driver’s seat), and safe with all the electro-nannies, but it’s a lot more complicated under the hood, but you’re not likely to go that deep anyways. I followed the tutorial at Home and Learn and got a nice primer on C#. The tutorials are very easy to read and understand so I recommend checking it out if you’re a beginner. It’s nice that Microsoft offers Visual Studio Express for free to play around with also. Get Visual Studio Express and start making some programs!