Saturday, December 24, 2011

Merry Christmas and Happy New Year


Sunday, December 11, 2011

TCP/IP Socket in C Language


On the other day searching on internet for TCP/IP Socket Codes i found a website with code examples of TCP and UDP Socket in several languages like C, Java, Perl and Python. That website was Techtalks.
So i leave here the link to the website and a video tutorial on "how to compile and test the TCP/IP Socket code in C language". I will also leave the direct link to download all the socket examples from Techtalks.

Download Socket Examples.

Sunday, November 27, 2011

Java search bar - Click event and Enter key event (Netbeans)

Create a search bar in a java application using netbeans, configuring click event listener and ENTER key event listener in the jTextField.







Code for button click event listener and key listener in jTextField:

        jButton1.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                jLabel1.setText("You searched for: "+jTextField1.getText());
            }
        });
        
        jTextField1.addKeyListener(new KeyAdapter()
        {       
            @Override
            public void keyPressed(KeyEvent e)
            {
                if(e.getKeyCode() == KeyEvent.VK_ENTER)
                    jLabel1.setText("You searched for: "+jTextField1.getText());
            }
        })



Saturday, November 26, 2011

Zymic - Free Web Hosting



Lots of people wounder how they can put thir website online without spending much money or no money at all. There are several way of doing that and Zymic is on of them. Zymic provides a free hosting service with the following caracteristics:

Free Web Hosting - General Features
- Disk Space 5000MB
- Data Transfer (Monthly) 50000MB
- Control Panel ZHCP
- Number Of Accounts Unlimited
- FTP Access Yes
- Advertisements No

Free Web Hosting - PHP And Databases
- PHP Ver 5.2.12
- MySQL Databases 3
- SQLBuddy Ver Custom

Free Web Hosting - Domain Names
- Sub-Domains Yes
- TLD Domain Yes

Free Web Hosting - Zymic Hosting Control Panel (ZHCP) Features
- File Manager Yes
- MySQL Management Yes
- Free Support Yes
- Account Settings Yes

I am using Zymic for a while and i'm really happy with their service.




Thumbs up to TweakUniverse for this video.

Monday, November 21, 2011

Java Core Tutorial for beginners

I found a nice Java core tutorial presentation that talks about the basic of Java to help you get started in Java Programming. So if you are a complete Java beginner this could be your way in.
You can check the tutorial here:






Or you can download it here:
Download Java Tutorial.

So a thumbs up for mister Vijay A Raj that made this tutorial.

Sunday, November 20, 2011

Create an installer to your Java Applications

A comum question that Java beginners ask themselves is "how do i create an installer to share my application?". The answer is easy!


Inserting an image in a Java GUI using NetBeans

This is a quick tip on Java about inserting an image on a JFrame using a JLabel in Netbeans IDE. Since NetBeans don't give a direct way to insert images this is the best way to do it. 
Keep programming and learning!



Monday, November 14, 2011

Order a vector in C

This tutorial presents two ways of order a vector using the programming language C.
We can use the typical way with two for cicles that can become really slow when the vector length is big (like 3555555) or a less commun way but a faster and smaller (in lines of code).

Typical way:

#include <stdio.h>


int main()
{
int v[5] ={2,5,3,2,4};
int v_temp;
int i,j;
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
if(v[i] <= v[j] && i!=j)
{
v_temp=v[j];
v[j]=v[i];
v[i]=v_temp;
}
}
}
for (i=0; i<5; i++)
{
printf("%d -> %d\n",i,v[i]);
}
return 0;
}


Other way:


#include <stdio.h>


int sort(const void *x, const void *y) {
  return (*(int*)x - *(int*)y);
}


int main()
{
int v[5] ={2,5,3,2,4};
int i;
qsort(v, 5, sizeof(int), sort); /*less lines of code and way faster ordering the vector qsort(name_of_vector,length_of_vector,sizeof(type_of_variable),name_of_function) in this case name_of_function is "sort"*/
for (i=0; i<5; i++)
{
printf("%d -> %d\n",i,v[i]);
}
return 0;
}


The result in both methods it's:

0 -> 2
1 -> 2
2 -> 3
3 -> 4
4 -> 5

Tuesday, October 18, 2011

Mootools - Javascript Framework

Note: This tutorial it's not for beginners but it's for people already with some knowledge of Javascript, HTML and CSS.

Mootools it's a javascript framework that allows you to create animations and take your website to the next level. Check Mootools Website and check their documentation and demos.

Mootools - Javascript Framework


I leave here an exemple of how to create a cool publicity to your website using mootools function Fx.Slide.

Code:


<html>
<head>
<script src="js/codemirror.js" type="text/javascript"></script>
<script src="js/mootools-core-1.3-full.js" type="text/javascript"></script>
<script src="js/mootools-more-1.3-full.js" type="text/javascript"></script>
<script src="js/mootools-art-0.87.js" type="text/javascript"></script>


<script language="JavaScript" type="text/javascript">
/* function called when the page loads */
window.addEvent('domready', function() {

var state = 0; /* state variable  0 - out 1 - in */
var mySlideH = new Fx.Slide('slideH_div', {mode: 'horizontal', duration: 7000}); /* initialize the slide */

mySlideH.hide(); /* Initialy hide the image */
animated_truck();
window.setInterval(animated_truck,10000); /* Set the time interval to call the animated_truck function */


/* Alternate the slide state */
function animated_truck(){
if(state == 0)
{
slide_in();
state = 1;
}
else
{
slide_out();
state = 0;
}
}
  
/* Function to slide in the image */
function slide_in(){
document.getElementById('truck_img').src="images/truck2.png"; /* change the image */
mySlideH.slideIn(); /* slide in the image */
}
  
/* Function to slide out the image */
    function slide_out(){
document.getElementById('truck_img').src="images/truck4.png"; /* change the image */
mySlideH.slideOut(); /* slide out the image */
    }
});


</script>


</head>
<body>
<div id="slideH_div" style="height: 200px; width: 1000px;">
<img id="truck_img" src="images/truck2.png" style="float:right;"/>
</div>
</body>
</html>

Download: Mootools Example







Monday, October 3, 2011

Give a better look to your login forms

Note: This tutorial it's not for beginners but it's for people already with some knowledge of HTML and CSS.

So instead of creating a regular login form like this:

User:

Password:



Code:

<html>
<head>
</head>
<body>
<form action="" method="post">
User:<br>

<INPUT type="text" name="username" size="25"><br>
Password:<br>
<INPUT type="password" name="password" size="25"><br><INPUT type="submit" value="Send">
</form>
</body>
</html>

 You can add some stuff that will make your login form look a lot more professional and nice like this:

 User:

 Password:



Code:


<html>
<head>
<style>
input:focus {
outline: none;
}/*This CSS propriety takes out that yellow border that apears when you select the input box with your mouse*/
#login_div{
font-family: Impact, fantasy;
font-size: 13px;
color: #66665E;/*font color*/
letter-spacing:2px;
}
.login_form{
background-color:#EDEDED;
border-type:solid; /*configure border*/
border-width:3px; /*configure border*/
border-color:#3088bc; /*configure border*/
font-family: Impact, fantasy;/*font type*/
font-size: 13px;
color: #66665E;/*font color*/
letter-spacing:2px;/*space between letters*/
-moz-border-radius: 7px 7px / 7px 7px;/*configure the rounded corners*/
border-radius: 7px 7px / 7px 7px;/*configure the rounded corners*/
}
</style>
</head>
<body>
<div id="login_div">
<form action="" method="post">
&nbsp;User:<br>
<INPUT type="text" name="username" size="25" class="login_form"><br>
&nbsp;Password:<br>
<INPUT type="password" name="password" size="25" class="login_form"><br>
<INPUT TYPE="image" SRC="submit.png" ALT="Submit Form" style="margin-top:4px;margin-left:2px;"><!-- Change the image of the submit button -->
</form>
</div>
</body>
</html>

I hope it helped.