mySQL Statement Monitor in DataGrid

2011.05.23

Working around lately with MySQL and C# I created a small and quite simple application that visualizes MySQL Commands to a DataGrid.

With SQL Statement Monitor v. 0.0.0.1 you can connect to a MySQL Database, execute MySQL commands and see the result straight on the DataGrid. For example, when you can execute a “Select” command and only the selected columns will be visible in the DataGrid. Similarly, you can add Tables, Entries, Columns etc.

In this Beta version of SQL Statement Monitor v. 0.0.0.1 are two buttons. One “Select” and one “Execute”. The “Select” button is used to filter the data (i.e. the Select example above). While the “Execute” button is used when an alteration to the Database is required (i.e. add an entry).
In addition, the code of some basic SQL Commands is included. Just select the command from the “Common SQL Commands” drop down menu and the code will be inserted for you in the commands field.

In order to use SQL Statement Monitor v. 0.0.0.1 MySQL Community Server is required. Personally, I suggest you to download MySQL Workbench (GUI Tool) too, so that you can manage your databases easily from a GUI. Both of these tools can be downloaded for free from MySQL official website.

How to use:
1. Download SQL Statement Monitor v. 0.0.0.1, unzip it and run the executable
2. Download MySQL Community Server and install it
3. Download MySQL Workbench and install it
4. Create a Database (write down the Username, Password and Hostname)
5. Start SQL Statement Monitor v. 0.0.0.1 (some errors may pop up that it cannot connect to Database)
6. Click ‘Connect to Database’ and give the correct information (Database name, Username, Password, Hostname and Table Name)
7. If the database has no tables yet an error will pop up. You should create a table
8. You are ready! Add some data and play around with SQL commands

If you have any question/suggestion please comment below.

If you need a copy of the source code do not hesitate to contact me.

Categories : Programming  C#  Programming

Random Password Generator in C#

2011.05.12

With Give Me a Password v. 1.0 you can create strong random passwords difficult to crack or guess, because of the combination of lower and upper case letters, numbers and special characters.

Give Me a Password v. 1.0 is written in C# and does not need install. However, to run the application, Microsoft .NET Framework 4 Client Profile must be installed.

Just download Give Me a Password v. 1.0, unzip it and run the executable. Select what characters should be included in the password(s) (i.e. lower/upper case letters, numbers, special characters), the length of the password(s) and the quantity of passwords to generate.

The code for Random Password Generation is based on the copyrighted sample code of Obviex™, which can be found here. Some alterations have been made to the initial code, in order to implement it with GUI and enhance the group of available characters.

If you need a copy of the source code please contact me.

If you find any bug or have any suggestion please contact me.

For more projects visit the Programming Section.

Categories : Programming  C#  Programming

BlackJack Card Counting in Java version 2.0

2011.05.10

The updated version of BlackJack Card Counting (True Count) Java application, CardCounting v. 2.0, comes with some new features.

In this version the True Counter is calculated for two ways of play, Conservative and Aggressive. With the Aggressive way the player tries to increase his/her profit, by increasing the bet as soon as possible. So, as one can see from the graphs generated from CardCounting v. 2.0, in Aggressive play the True Counter changes only by +1 or -1.
Reminding that the player is assumed to increase the bet every time the True Counter increases by 1 (as the advantage of the player is increased by 0.5%) and decrease the bet every time the True Counter decreases by 1, Aggressive play can lead to loss or profit faster…

In addition, with CardCounting v. 2.0 one can compare the True Counter for the two ways of playing for any of the seven Card Counting strategies (Wizard Ace/Five, KO, Hi-Lo, Hi-Opt I, Hi-Opt II, Zen Count and Omega II).

Download CardCounting v. 2.0, unzip the file, open a command prompt window, navigate to the directory where the jar file is located and write:

java -jar CardCounting.jar

For help write:

java -jar CardCounting.jar help

Note, that the Java Runtime Environment (JRE) is required to run the application.

For any question/suggestion you can comment. Have fun!

For the full list of Projects check the Programming Page.

Categories : Programming  Java  Programming

Standard, Automatic (auto_ptr) and Scoped (scoped_ptr) (Boost Library) pointers in C++

2011.05.09

A (potential) “drawback” in C++ is the lack of a built-in garbage collector. However, there is a variety of techniques that help you get over with that.

To follow that post and the attached example (keep reading…) you must have a familiarity with pointers in C++. If you do not you can read an introduction here.
In addition, if you do not know what an automatic pointer is in C++ you can read here (you will need it)
Finally, if you have not heard the Boost Libraries in C++ before, then you can find more information in the official website.

Cpp Pointers Example v. 1.0 is a small C++ project in Visual Studio that will help you to understand better all the above concepts about pointers.

The code is fully commented but let me explain the main concept of the example.
We have a class (called myClass) and three different functions, where each one uses a different kind of pointer to point to myClass.
As it can be easily seen from the example when the standard C++ pointer goes out of scope, it does not call the destructor of the class. So, the object which was initially created is never destroyed.
With automatic pointer (auto_ptr) and scoped pointer (scoped_ptr) the destructor is called and the initially created object is destroyed.

The big difference between the automatic pointer and the scoped pointer is that scoped_ptr is not Transferable. On the other hand, auto_ptr is Transferable, which as you can see from the example code can lead you to have references to null.

Download Cpp Pointers Example v. 1.0, play around with the code (read the comments inside the code) and if you have any question feel free to comment here.
If you are using Visual C++ Express you can double click SmartPointerBoostLib.sln. Otherwise, the file containing all the C++ code is SmartPointerBoostLib.cpp

Note: In order to run the example of scoped_ptr, Boost Libraries must me installed. For help how to install (and compile if needed) the Boost Library files read the official documentation here (it is quite straight forward).
If you want you can comment the code referring to Boost Library and run the example normally (only the standard and automatic pointer examples will be shown)

For any suggestion and/or question you can comment bellow ;)

Search in ZIP files (Python script)

2011.05.03

Search in ZIPs v. 1.0 is a script written in Python that allows you to search for files inside ZIP archives.

A GUI developed with the AutoIT Scripting Language is provided, to make the use of the script easier (not use of command prompt is required). However, the more advanced users can run the executable Python script from command line, giving the appropriate command arguments.

How to use:
1. Download Search in ZIPs v. 1.0
2. Unzip the archive
3. Run the SearchInZIPs.exe
4. Set the directory containing the ZIP files to search
5. Give the search string to search in the filenames
6. A text file search.txt will be created in the script directory (where the initial zip was extracted) containing the returned search results

For a complete user guide read the included help file.

Note 1: You can run the script without Python installed (look Note 2 for an important dll)

Note 2: Microsoft Visual C runtime DLL is required to run the compiled Python script.
You must install Microsoft Visual C++ 2008 Redistributable Package published 29/11/2007 either by running the vcredist_x86.exe contained in Search in ZIPs v. 1.0 package, either by downloading it from Microsoft here.

For any question feel free to comment.

If you need a copy of the source code (Python and/or AutoIT) feel free to contact me.

Enjoy ;)

Categories : Programming  Programming  Python