Archive for May, 2009

Java: Get the IP address of a website.

Monday, May 25th, 2009

Trouble

You need to get the IP address of a website using your domain name.

Solution

Use the method InetAddress.getByName(String host) to library java.net.InetAddress

Code

/**
 *
 * @author VenuThomas
 */
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {

 /**
 * @param args the command line arguments
 */
 public static void main(String[] args) {
 // TODO code application logic here
 try {
 InetAddress address = InetAddress.getByName("www.google.com");

 // Output: www.google.com/74.125.45.100
 System.out.println(address);

 } catch (UnknownHostException e) {
 System.out.println("Could not find www.google.com");
 }
 }
}

Java: Change To Uppercase/Lowercase A String

Monday, May 25th, 2009

Trouble

Looking for a change to case-insensitive string.

Solution

Use the methods toUpperCase() or toLowerCase() of class String

public class Main {
public static void main(String[] args) {

// define the string
String cad = "Welcome to WiseCodes.Com";

// string to uppercase
// OUTPUT: WELCOME TO WISECODES.COM ...
String cad_uppr = cad.toUpperCase();
System.out.println(cad_uppr);

// string to lowercase
// OUTPUT: welcome to wisecodes.com ...
String cad_lowr = cad.toLowerCase();
System.out.println(cad_lowr);

}
}

.NET: Checking whether an Internet connection is available

Wednesday, May 20th, 2009

The method using ping checks whether there is an internet connection or not?

In C#.NET

The following namespace is required:

using System.Net.NetworkInformation;
/// <Summary>
/// Checks whether an Internet connection is available.
/// </Summary>
/// <Returns>
/// True / false
/// </Returns>
/// Site: WiseCodes.Com

public static bool wcCheckInternetConnectionStatus()
{
 Ping pingSender = new Ping();

 try
 {
PingReply pReply = pingSender.Send("www.microsoft.com", 100);

 return pReply.Status == IPStatus.Success;
 }
 catch
 {
 return false;
 }
}

Link: System.Net.NetworkInformation Namespace (Via MSDN)

Happy Programming!! ;-)

An Introduction to Adobe Flex

Wednesday, May 20th, 2009

Adobe Flex (Macromedia Flex) is a term that covers a range of technologies published since March 2004 by Macromedia to support the development and deployment of rich Internet applications based on its proprietary platform Flash.
The traditional application developers see it as a challenge to adapt the metaphor of animation on the platform which was originally built Flash. Flex elegantly minimizes this problem by providing a workflow and programming model that is familiar to application developers.

Flex was initially released as an implementation of J2EE or library label JSP to compile the Flex markup language (MXML) and run through ActionScript Flash applications (binary SWF files). Later versions of Flex support the creation of files that are compiled, and can be distributed online without the need for a server license.

The purpose of Flex is to allow developers to build Web applications quickly and easily Rich Internet Applications, also called RIAs. In a multi-layer, Flex applications are the level of presentation.

Flex emphasizes the development of graphical user interfaces using an XML language called MXML. Flex has several components that provide functionality and features such as Web services, remote objects, drag and drop, ordered columns, graphics, animation effects and simple interactions. The client only loads the application once, thereby improving the flow of data from applications based on HTML (eg. PHP, ASP, JSP, CFMX) which require executing templates on the server for each action. The language and structure of files looking for Flex decoupling of the logic and design.

The Flex server also acts as a gateway allowing the client to communicate with web services XML and remote objects (such as Coldfusion CFCs, Java classes, and anyone who supports the Action Message Format).

Alternatives to Flex are Google Web Toolkit, data centers, OpenLaszlo and Silverlight from Microsoft.

For those working with opensource software adobe also available on this site http://opensource.adobe.com/ where the Flex SDK and includes projects by developers.

Directory structure of a project in Flex Builder.
When creating a project in Flex Builder automatically creates a directory structure

This application consists of an application directory that contains different types of files required to compile and run the application, these are:

introtoflex01
. Settings: Contains settings for the flex builder
bin-debug: debug contains the swf and the files needed for debugging
html-template contains the files to be used specifically for detecting the player
src: the sources of the mxml files
libs: Library to implement the desired application. 

Link: Via Officical Site , OpenSource (Via Adobe) , LiveDoc (Via Adobe), Flex Components (Via Flex.org), Adobe Flex Help (Via Adobe), 36 Cool Flex Tools (Via Seantheflexguy), Flex Developer Center (Via Adobe),

.NET: Check links (http, https, ftp, news etc …)

Thursday, May 14th, 2009

In this article we show how we can know what kind of address is an address. We will use the URI class, which does not allow URLs to work. The class belongs to the URI name space System.

The URI class has property “Scheme” that indicates the type of URI scheme today. The schemes that detects the URI class are:

* UriSchemeFile: tells us that points the direction in which our class is a file URI.
* UriSchemeFtp: the scheme is FTP (File Transfer Protocol)
* UriSchemeGopher: specifies that we can access through URI using the Gopher protocol.
* UriSchemeHttp: access is a URI using the HTTP protocol.
* UriSchemeHttps: the address is https, http secure.
* UriSchemeMailto: tells us that the address is an e-mail, which can be accessed via SMTP.
* UriSchemeNetPipe: tells us that the identifier URI is NetPipe.
* UriSchemeNetTcp: can access through URI using the protocol NetTCP.
* UriSchemeNews: URI is the address of a newsgroup or News.
* UriSchemeNntp: a newsgroup is accessed via NNTP.

The fields above are just reading.

In the following example, create a constant that contains the address from which we obtain information and identify which type of management is our constant.

In Visual Basic:

Const strURL As String = “http://www.wisecodes.com”
Dim strDir As New Uri(strURL)
Select Case strDir.Scheme
Case Uri.UriSchemeFile
'Code for when the address is a file
Case Uri.UriSchemeFtp
'Code for when the address is ftp
Case Uri.UriSchemeGopher
'Code for when the address is a file Gopher
Case Uri.UriSchemeHttp
'Code for when the address is http
Case Uri.UriSchemeHttps
'Code for when the address is https
Case Uri.UriSchemeMailto
'Code for when the address is an e-mail
Case Uri.UriSchemeNetPipe
'Code for when the address is NetPipe
Case Uri.UriSchemeNetTcp
'Code for when the address is NetTcp
Case Uri.UriSchemeNews
'Code for when the address is a newsgroup
Case Uri.UriSchemeNntp
'Code for when the address is a newsgroup
'accessible via NNTP.
End Select

In C Sharp

const string strURL = “http://www.wisecodes.com”
Uri strDir = new Uri (strURL);
switch (strDir.Scheme)
{
case Uri.SchemeFile:
//Code for when the address is a file
case Uri.UriSchemeFtp:
//Code for when the address is ftp
case Uri.UriSchemeGopher:
//Code for when the address is a file Gopher
case Uri.UriSchemeHttp:
//Code for when the address is http
case Uri.UriSchemeHttps:
//Code for when the address is https
case Uri.UriSchemeMailto:
//Code for when the address is an e-mail
case Uri.UriSchemeNetPipe:
//Code for when the address is NetPipe
case Uri.UriSchemeNetTcp:
//Code for when the address is NetTcp
case Uri.UriSchemeNews:
//Code for when the address is a newsgroup
caseUri.UriSchemeNntp:
//Code for when the address is a newsgroup
//accessible via NNTP.
}

Link: Via Microsoft
Happy Programming!! ;-)

PHP on Windows Training Kit (April 2009)

Wednesday, May 13th, 2009

Now Microsoft has published Training toolkit ie. PHP On Windows Training Kit (April 2009). This is a kit designed to help PHP developers can build applications in this language and platform for Windows and using IIS 7 and SQL Server 2008. The kit includes the following elements:

* PHP & SQL Server Demos.
* Integrating Geo-Spatial SQL Server with PHP.
* SQL Server Reporting Services and PHP.
* PHP & SQL Server Hands On Labs
* Introduction to Using SQL Server with PHP
* Full Text Search Using Office Documents in PHP over.
* PHP on Windows Hands On Labs
* IIS Access Control Features for PHP.
* Media Features Using IIS 7.0 in a PHP Application.
* Troubleshooting PHP.
* Migrating PHP Applications to IIS 7.0.

Link: Via Microsoft

SQL: New versions of SQL Server 2008 Express

Wednesday, May 13th, 2009

Microsoft has released three versions of SQL Server 2008 Express Edition, these are:
* Microsoft SQL Server 2008 Express, this is the basic version of SQL Server 2008 Express Edition, this version with other applications redistribution is free.

* Microsoft SQL Server 2008 Express Tools with this version gives us work with applications that work with data, whether to narrow or web development, this version is ideal for small server storage applications and data storage, among the features best we can name:

* Admin Tools reliable and effective.
* Interesting data protection system.

* Microsoft SQL Server Express 2008 with Advanced Services includes more features and makes it easier than ever to develop effective data-driven applications for the web or local desktop. Other features include:

* A graphical management tool.
* Interesting features to create reports.
* Run reports from SQL Server Reporting Services on local relational data.

Link: Microsoft SQL Server 2008 Express,
Link: Microsoft SQL Server 2008 Express Tools
Link: Microsoft SQL Server Express 2008 with Advanced Services

What is RSS?

Tuesday, May 12th, 2009

The RSS is an XML data set from which we can report the news and content to a web users who have subscribed.

Of course the best way to stay informed about updates to our favorite websites. And as an image, in this case a video is worth a thousand words we rolled over and leave you this video that explains clearly what the RSS.

Images in Access or SQL database

Saturday, May 9th, 2009

Description: An example of how to image files in an Access or SQL database and later display in VB

There are two possibilities:

* Save the path (without the image data itself)
* Save the complete image

The first solution is probably the simpler solution, because only the pure path of the image file is stored. Second option is a bit expensive, but has the advantage that the image will be displayed again if the image file itself is not (more) on the computer is available. The big disadvantage here is that the database, depending on the number of stored images (and image size) may become very large.

Save the image information in a memo
To view the entire image in a database, it is best to use a database field of type memo. Such content can have a field up to 1.2 GByte of memory. This should then also for larger image files are sufficient.

To do this, use the following routine:

'Image in variable (string) read
Public Function wcReadPicture(strFilename As String) As String

 Dim intF As Integer
 Dim strInhalt As String

 intF = FreeFile
 Open strFilename For Binary As #intF
 strInhalt = Space$(Lof(intF))
 Get #intF, , strInhalt
 Close #intF

 wcReadPicture = strInhalt

End Function

Whenever you’re a picture in the database must therefore call on the above function:

'Save Image in Database
Table.Edit
Table("wcImage") = wcReadPicture(Your_Image_Path)
Table.Update

Image database and read in Picture / Image View Object
Now the image from the database later in a PictureBox or an Image object again, create a temporary file and save to the contents of the database image field. About LoadPicture statement, the image can then be displayed. Then the temporary file is deleted again.

And here the code:

'Load image from database and display
Public Sub wcShowPicture(Picture As Control, ByVal strInhalt As String) 

 Dim intF As Integer

 'Create a temporary image file
 intF = FreeFile
 Open App.Path & "\wcImage.tmp" For Output As #intF
 Print #intF, strInhalt;
 Close #intF

 'Picture
 Picture.Picture = LoadPicture(App.Path & "\wcImage.tmp")

 'Delete temporary file
 Kill App.Path & "\wcImage.tmp"

End Sub

The call of the procedure is then as follows:

wcShowPicture Picture1, Table("wcImage")

Happy Programming!! ;-)

An Introduction to SQLite

Friday, May 8th, 2009

http://www.wisecodes.com/2009/05/an-introduction-to-sqlite/

SQLite is a small library written in C, which offers an engine for database SQL and implementing much of the standard SQL92 and ACID properties. In contrast to database servers like MySQL or PostgreSQL, its particularity is not to reproduce the usual client / server but to be integrated directly to programs using database files. SQLite is a public domain project created by D. Richard Hipp .

SQLite is the database engine as distributed through its offices in many large public software Skype, Firefox, Gears, and some products McAfee, in many languages like PHP, Python and Perl and some mobile phones whose iPhone and those running Symbian, which totals more than 200 million settlement of the library.

Features:

SQLite does not work on the paradigm client / server, but is a function library. Among its other features, it should be noted:

  • the absence of a procedure for installation and configuration. This includes the lack of account management and user rights.
  • whole database is stored in one file.
  • the type of data stored in each database is a property of the data, not the column. A column can contain data of different types.

SQLite implements most of the SQL 92 standard with the exception of:

  • management rights with GRANT and REVOKE
  • management of foreign keys
  • the joints type RIGHT OUTER JOIN and FULL OUTER JOIN (but supports LEFT OUTER JOIN)
  • the triggers are only partially taken into account
  • the possibilities of modifying the structure of a table are limited: you can rename a table and add columns, but not modify or delete columns.

SQLite can be interesting in performance and be useful in many cases (unable to use a database server for websites or applications and embedded devices, etc..), But it does not allow different processes or thread to access simultaneously write to the same database and is not designed to handle a lot of competitors.

The library can be used in Python, C and C + +. Modules for Perl, PHP, TCL and other scripting languages are available.

PHP includes SQLite in the distribution base since version 5, when it was released as version 4 in the form of an extension PECL.

Python SQLite 3 also includes in its standard library since version 2.5.

Link: Offical Website of SQLite
Link: Interview with Richard Hipp
Link: SQLiteSpy (compatible with Unicode for Win32. Freeware.)
Link: SQLite Database Browser
Link: SQLite Database Manager

Video: (An Introduction to SQLite)