Posts Tagged ‘OpenSource’

PostgreSQL 8.4 maintains its distance with rivals

Thursday, July 2nd, 2009


The Group PostgreSQL Global Development has released version 8.4 of the database of open source with advanced features. There are nearly 300 improvements to administration, programming and query language opening up new possibilities with this database.

Some improvements are:

* Restoring the database using parallel processes, accelerating the recovery of a back up to 8 times compared to the previous version.
* Column privileges, to control access to a greater level of detail.
* Language settings and management for database. To be able to select the most appropriate depending on the language that is required.
* Update 8.3 to 8.4 with minimal downtime
* New tools for monitoring consultations, delivering information to managers to know what is happening in the database.
* Implement advanced features of ANSI SQL: 2003 which allow complex queries into a single expression which previously required several.
* Improvements in stored procedures, for example using default parameters in the statement or list of arguments of variable length, the style C + + / Java.
Besides the new features, this new version includes improvements to the strong performance, particularly in complex operations.

While there are other databases of open source with a large base of users as MySQL, PostgreSQL orientation has always been to implement the features that make face to face with advanced databases such as Oracle. In this issue again The project has made it clear what distinguishes PostgreSQL jurisdiction in the world of open source.

Link: via PostgreSQL

Detection of faces on canvas with Javascript

Wednesday, June 17th, 2009

Detect faces and is not just for Google Images. Now you can implement it on your website using Javascript and the canvas properties.

Venu

How it works?

To do this we need to work only 2 files in our <head />

<script type="text/javascript" src="dat.js"></script>
<script type="text/javascript" src="detector.js"></script>

Dat.js the file shows how to detect and detector.js the file has the logic of the script can detect faces in any photo.
1 can detect faces in the photos, the process becomes slower depending on what we choose (of course).

1 Face

?View Code JAVASCRIPT
face_detect_one( document.getElementById("myCanvas") );

Multiple Faces

?View Code JAVASCRIPT
face_detect_multi( document.getElementById("myCanvas") , progress_callback, result_callback );
function progress_callback( StepsCompleted, TotalSteps){
....
}

Answer

The response functions that returns the values we obtain a rectangle that contains the person’s face.

?View Code JAVASCRIPT
var myCanvas = document.getElementById("mycanvas");
 
var result = face_detect_one( myCanvas );
if (result) draw_rect(result, myCanvas);
 
function draw_rect(r, myCanvas){
	var CanvasContext = myCanvas.getContext("2d");
 	CanvasContext.strokeRect( r.x, r.y, r.w, r.w );
}

Link: via Percobaan

Javascript Image combobox, give your life to select

Wednesday, June 3rd, 2009

Javascript Image ComboBox is a jQuery plugin that allows our items <select/> have a life that until now could not have.

comboboximage_030608

This is an extension that allows items of <select /> have an image to facilitate the selection of items within a list of options.
To do this using an attribute (not standard) element <option /> named icon which will indicate where we’ll take the image next to <option />

 <select name="webmenu" id="webmenu" onchange="showValue(this.value)">
    <option value="calendar" icon="icons/icon_calendar.gif">Calendar</option>
    <option value="shopping_cart" icon="icons/icon_cart.gif">Shopping Cart</option>
    <option value="cd" icon="icons/icon_cd.gif">CD</option>
    <option value="email"  selected="selected" icon="icons/icon_email.gif">Email</option>
    <option value="faq" icon="icons/icon_faq.gif">FAQ</option>
    <option value="games" icon="icons/icon_games.gif">Games</option>
    <option value="music" icon="icons/icon_music.gif">Music</option>
    <option value="phone" icon="icons/icon_phone.gif">Phone</option>
    <option value="graph" icon="icons/icon_sales.gif">Graph</option>
    <option value="secured" icon="icons/icon_secure.gif">Secured</option>
    <option value="video" icon="icons/icon_video.gif">Video</option>
  </select>

After a line of JavaScript with this attribute will be housed within an image <select />

?View Code JAVASCRIPT
 MSDropDown.init();

If you want to see a demo of how to be, you can take a look here.

Mastered the accordion with MooTools

Wednesday, June 3rd, 2009

Call accordion those dynamic elements of our Web pages that show an item to move the mouse (or click on it) to conceal the other components. This technique very convenient for displaying large amounts of information in a small space usually give a headache to match all the information.

byslidermenu

With BySlideMenu never have problems. This is a MooTools plugin that allows us to make a wide variety of accordions, with very few lines of code.

HTML:

The HTML code we use to generate our accordion will be based on a list of elements:

<ul id="pinclickmenu">
    <li><img src="creditcards.jpg" /></li>
    <li><img src="games.jpg" /></li>
    <li><img src="computer.jpg" /></li>
    <li><img src="eiffeltower.jpg" /></li>
    <li><img src="electronic.jpg" /></li>
</ul>

Each <li/> will be one of the elements that make up the accordion.

JavaScript:

?View Code JAVASCRIPT
var pinclickmenu = new BySlideMenu('pinclickmenu', {pinMode: 'click'});

As we see fewer lines is impossible :D

Demos and Downloads:

You can see more demos and download the plugin from the project page.

Happy Programming!!! ;-)

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!! ;-)

.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!! ;-)

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!! ;-)

SQL: Get First and Last Day of Week

Monday, May 4th, 2009

Description:
How to get First and Last Day of Week.

Select GETDATE() AS 'Today', 

DATEPART(Week,GETDATE()) AS 'Week No of Today', 

DATEADD( DAY , -DATEPART(WEEKDAY,(DATEADD( DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE())))
+(7-DATEPART(WEEKDAY,GETDATE()))+1 ,GETDATE()) 'First Day Of This Week', 

DATEADD(DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE()) AS 'Last Day Of Week'

Happy Programming!!