Stress for Computer Programmers

September 12, 2008 at 3:38 am (Article)

What is a stress?

Stress is the consequence of the failure to adapt to change, specifically the inability to respond appropriately to emotional or physical threats to the organism, whether actual or imagined.[1] Common stress symptoms include irritability, muscular tension, inability to concentrate and a variety of physical reactions, such as headaches and accelerated heart rate.http://en.wikipedia.org/wiki/Stress_(medicine)

What are the sources of stress?
According to my officemates here are the sources of stress.
1. Boyfriend/girlfriend. ( demanding partners)
2. Family ( if you are a breadwinner of the family)
3. Tax (deductions to your salary every payday is too much because of your tax)
4. Deadlines (meeting your deadlines)
5. Sourcecode, Bug(for programmers)
6. Specs ( client specs, what they want to add in the next release)
7. Release ( release of product that are not yet tested)
8. Neighbors ( noisy neighbors)
9. Clients/ Customers ( customers are always right)
10. Financial Status

What are the ways to relieve your stress?

1. Playing PSP or computer games.
2. Watching funny videos in youtube
3. Go to starbucks and buy coffee.
4. Go to some bar and drink alcoholic drink but not too much because it can cause you another stress.
5. Sing your favorite song in a loud voice..
6. etc..

Here’s a another interesting article titled “Memo to my Managers”.. It was forwarded by my friend..

Memo to my Managers – the ‘Rules’…

1.Never give me work in the morning. Always wait until 4pm and then bring it to me. The challenge of a deadline is refreshing.
2.If it’s a really rush job, run in and interrupt me every 10 minutes to enquire how it’s going. That helps. Or even better, hover behind me, advising me at every keystroke.
3.Always leave without telling anyone where you’re going. It gives me a chance to be creative when someone asks where you are.
4.If my arms are full of papers, boxes, books or supplies, don’t open the door for me. I need to learn how to open doors with no arms in case I should ever be injured and lose all use of my limbs.
5.If you give me more than one job to do, don’t tell me which is the priority. I am psychic.
6.If a job I do pleases you, keep it a secret. If that gets out it could mean a promotion for me.
7.On the other hand, if you don’t like my work, tell everyone. I like my name to be popular in conversations; I was born to be whipped.
8.If you have special instructions for a job, don’t write them down. In fact, save them until the job is almost done. No use confusing me with useful information.
9.Never introduce me to the people you’re with. I have no right to know anything. In the corporate food chain, I am plankton. And anyway, when you refer to these people later, my shrewd powers of deduction will identify them.
10.Be nice to me only when the job I’m doing for you could really change your life and send you straight to manager’s hell.
11.Tell me all your little problems. No one else has any and its nice to know someone is less fortunate. I especially like the story about you having to pay so much tax on your salary.
12.Wait until my yearly review and THEN tell me what my goals SHOULD have been or what I did wrong eight months ago. Give me a mediocre performance rating, or better still, keep postponing the review meeting. I’m not here for the money anyway.

Advertisements

Permalink 1 Comment

Learning PHP…

August 23, 2008 at 11:06 am (Programming, Uncategorized)

PHP (recursive acronym for “PHP: Hypertext Preprocessor”) is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Example 1: Hello World (sample1.php)

<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>

PHP can be used on all major operating systems, including Linux, many Unix variants (including HP-UX, Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others. PHP has also support for most of the web servers today. This includes Apache, Microsoft Internet Information Server, Personal Web Server, Netscape and iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many others. For the majority of the servers PHP has a module, for the others supporting the CGI standard, PHP can work as a CGI processor.v

Variables and Operators

$var = “Hello”; //string “hello”

$var = 3; // integer 3

$var2 = $var1; // Assigns a value of ‘PHP’ to $var2

echo $var1; // Outputs ‘PHP’

STRINGS

A string is series of characters. In PHP, a character is the same as a byte, that is, there are exactly 256 different characters possible.

<?php
echo “Hello World”;

?>

ARRAYS

An array is a special kind of variable that contains multiple values. The simplest way to create an array in PHP is to use the built-in array function:

$myarray = array(‘one’, 2, ‘3’);

$arrayvar = array(‘apple’, ‘banana’, ‘orange’);

echo $arrayvar[0]; // Outputs ‘apple’

echo $arrayvar[1]; // Outputs ‘banana’

echo $arrayvar[2]; // Outputs ‘orange’

CONTROL STRUCTURES

The most basic, and most often-used, control structure is the if-else statement.

Here’s what it looks like:

1. If condition

Ex: if($username==”admin” and password==”admin”) { echo “Hello admin! Welcome!”; }

else { echo “Invalid username or password”; }

2. While condition

Example:

$count = 1;

while ($count <= 10) {

echo “$count “;

++$count;

}

3. For Loop

Ex: for($i = 0; $i <10; $i++)

{ echo $i; }

Example:

<html>

<body><center>

<table width =”50″ border=”1“>

<?php

for($y=1; $y<=10; $y++)

{ echo “<tr><td><center><h1>$y </h1></center></td></tr>”; }

?>

</table>

</center>

</body></html>

DEALING WITH FORMS

One of the most powerful features of PHP is the way it handles HTML forms. The basic concept that is important to understand is that any form element in a form will automatically be available to your PHP scripts.

welcome.html

<form action=”welcome.php” method=”get”>

<label>First Name: <input type=”text” name=”firstname” />

</label><br />

<label>Last Name: <input type=”text” name=”lastname” />

</label><br />

<input type=”submit” value=”GO” />

</form>

welcome.php

<?php

$firstname = $_POST[‘firstname’];

$lastname = $_POST[‘lastname’];

echo “Welcome to my Website, $firstname $lastname!”;

?>

SESSION HANDLING FUNCTIONS

Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site.

A visitor accessing your web site is assigned an unique id, the so-called session id. This is either stored in a cookie on the user side or is propagated in the URL.

Example:

session_start();

$_SESSION[‘username’] = $name;

To destroy a session you created:

Example: session_destroy();

UPLOADING FILE IN PHP

The <input type="file"> form element lets a user upload the entire contents of a file to your server. When a form that includes a file element is submitted, the PHP interpreter provides access to the uploaded file through the $_FILES auto-global array.

$_FILES[‘upload-name’][‘name’]: The name of the file as uploaded from the client to the server.

$_FILES[‘upload-name’][‘type’]: The MIME type of the uploaded file. Whether this variable is assigned depends on the browser capabilities.

$_FILES[‘upload-name’][‘size’]: The byte size of the uploaded file.

$_FILES[‘upload-name’][‘tmp_name’]: Once uploaded, the file will be assigned a temporary name before it is moved to its final location.

$_FILES[‘upload-name’][‘error’]: An upload status code. Despite the name, this variable will be populated even in the case of success. There are five possible values:

CONNECTING PHP TO MYSQL

1. $connect = mysql_connect(address, username, password); // address is the ip address or host name of the computer. username and password of the same username and password of your mysql server. returns true if the connection is established.

2. mysql_select_db($databasename,$connect); // databasename name of the database, $connect is the name of the connection your established see no.1.

3. mysql_query($query[, connection_id]); // $query is the sql command you want to execute;

4. mysql_close([connection id]) // To close the connection in database server.

Example:

<?php
$link = mysql_connect(‘localhost’, ‘root’, ”);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
echo ‘Connected successfully’;
mysql_close($link);
?>

Permalink Leave a Comment

Greedy Relative…

August 8, 2008 at 2:15 am (Article, Uncategorized)

How can you define greedy ? “well in my case, these are the people who were allowed to BORROW a property which they didn’t pay any amount for to the owner and the government, yet without etiquette and without word of honor, they deliberately refused to remove their belongings in the time due for them to move out. ” Building their house is only permitted by the owner. But the garage is too much. But because the owner is too kind, he asked that greedy person to sign a contract that if he wants to get that piece of land pertaining to the garage he can get that without any problem.. Years passed, the owner decided to get that piece of land because he wants to build a small office in that space.. Because they refused to remove their garage, the owner filed a case against his relative. But the greedy relative also filed a case of human rights..

“Human rights? WHAT A SHAMELESS PEOPLE? How could they file a violation of human rights! To my knowledge, the violation done is them COVETING OUR PROPERTY and AND ABUSING OUR GENEROSITY! The owner, of course, never failed to spend so much on the maintenance of that lot and these greedy people only covet it!

That’s not only a sin against society but also violates God’s commandment “thou shall not covet thy neighbors property”

Plus, it is also a form of stealing!

According to republic act no 386:
http://www.chanrobles.com/civilcodeofthephilippinesbook2.htm

Title II. – OWNERSHIP

CHAPTER 1
OWNERSHIP IN GENERAL
Ownership may be exercised over things or rights. (n)

Art. 428. The owner has the right to enjoy and dispose of a thing, without other limitations than those established by law.

The owner has also a right of action against the holder and possessor of the thing in order to recover it. (348a)

Art. 429. The owner or lawful possessor of a thing has the right to exclude any person from the enjoyment and disposal thereof. For this purpose, he may use such force as may be reasonably necessary to repel or prevent an actual or threatened unlawful physical invasion or usurpation of his property. (n)

Art. 430. Every owner may enclose or fence his land or tenements by means of walls, ditches, live or dead hedges, or by any other means without detriment to servitudes constituted thereon. (388)

Art. 431. The owner of a thing cannot make use thereof in such manner as to injure the rights of a third person. (n)


Art. 433. Actual possession under claim of ownership raises disputable presumption of ownership. The true owner must resort to judicial process for the recovery of the property. (n)

Art. 434. In an action to recover, the property must be identified, and the plaintiff must rely on the strength of his title and not on the weakness of the defendant’s claim. (n)

Permalink 1 Comment

Smart introduced the new mobile messenger “Uzzap”

July 7, 2008 at 2:50 am (Mobile, Uncategorized)

Yesterday, Smart introduced the new mobile messenger called “Uzzap”. It includes sms capability, sending emails, login to your yahoo and msn acoount, and unique chatrooms. It also has a feature called auto buddy matching where it loads your phonebook and search your contacts if they are already uzzap buddies. Uzzap has a lot of features. You can also personalize your uzzap. You can change your status, go on silent mode, change themes and more! You can also group your buddies. It also has search bar that can search your contacts easily. This uzzap is the most useful messenger.

Uzzap is a pc-pc, pc-phone and vice versa mobile messenger. Click here to download uzzap http://uzzap.com/download or text UZZAP send to 7272.

Go to http://uzzap.com/index.htm for more details.

Main Menu of Uzzap http://uzzap.com/start_enjoy.htm

Users Manual: http://uzzap.com/download_pdf.htm

You can install it in symbian, java phones, linux, windows xp and windows vista.

How to set your gprs using smart simcard:
Key in SET GPRS and send to 211.
Example: If you have a Nokia 6230, that’s “SET MMS N6230”
To activate SMART GPRS:
Key in “GPRS ON” and send to “333″

Benifits of Uzzap:
1. Unlimited Chat
2. Send Email
3. Connect to Yahoo
4. Connect to MSN
5. Send SMS
6. Auto Buddy Matching
7. Can store your phonebook contacts
8. Public Chatrooms
9. Private Chatrooms
10. GSM Call ( available on 3rd edition phones)
and many more..
Anywhere,anytime you can chat your friends easily.

Permalink 15 Comments

Simple HttpServer in Twisted Python

May 27, 2008 at 8:25 am (Programming, Uncategorized)

this is a sample code of http server programmed in twisted python
#httpserver.py
#!/usr/bin/python
import sys
from twisted.protocols import basic
from twisted.web import server,resource,http
from twisted.internet.protocol import Protocol

class HttpProtocol(basic.LineReceiver,Protocol):

def __init__(self):
self.lines = []

def connectionMade(self):
self.sendLine(“HTTP/1.0 200 OK”)
self.sendLine(“Content-Type:text/plain”)
self.sendLine(“”)

def lineReceive(self,line):
# your code goes here: process the line you receive
print line

class HttpFactory(http.HTTPFactory):

def __init__(self):
self.protocol = HttpProtocol

def onClientConnected(self):
print “Connected”

reactor.listenTCP(8080,HttpFactory())
reactor.run()

running on the terminal
$ python httpserver.py
as the reactor.run called, your http server is now listening on port 8080

Permalink Leave a Comment

List of All Programming Languages

May 7, 2008 at 7:34 am (Programming, Uncategorized)

Helloworld in all programming language

ActionScript
AdaLanguage:
AlephLanguage:
AppleScript
AssemblyLanguage for the IBM-PC (i386):
AwkLanguage:
B (BeeLanguage):
BasicLanguage
BefungeLanguage:
Bourne Shell:
BrainfuckLanguage (an EsotericProgrammingLanguage)::
C (CeeLanguage) (according to KernighanAndRitchie):
CsharpLanguage:
C++ (CeePlusPlus)
Cobol
ColdFusion
RM COBOL
COW (an EsotericProgrammingLanguage):
D
DOS (DiskOperatingSystem)
EiffelLanguage
ErlangLanguage:
EtcLanguage:
Forte TOOL:
ForthLanguage:
FrinkLanguage
GoogleplexianLanguage:
HaskellLanguage
HqNinePlusLanguage
HtagLanguage
HTML
InformLanguage
IoLanguage
JavaLanguage:
Swing Java
JavaApplet:
JavaScript:
J (JayLanguage)
JoyLanguage:
K (KayLanguage)
LingoScriptingLanguage
Logo
LolCode:
LuaLanguage:
LxLanguage:
MicrosoftExcel
ModulaThree
NemerleLanguage: (http://www.nemerle.org)
OpalLanguage
ObjectiveCaml
PascalLanguage
PathLanguage
PerlLanguage
PerlInline
PhpLanguage
PlbLanguage (or Databus)
PowerScript
PowerShell
PrographLanguage
Prolog
PythonLanguage
QBasic
Rebol
RexxLanguage
RpgLanguage
RubyLanguage
ShellScript
SchemeLanguage
SmalltalkLanguage
SmlLanguage
SnobolLanguage
TeX
TomLanguage
ToolCommandLanguage
UnLambdaLanguage
VisualBasic
VisualFoxPro
MS VJ++
VoiceXml
Whirl
VBScript
JScript
WikiWiki

Permalink 1 Comment

Send Message in J2ME

May 7, 2008 at 5:14 am (Mobile, Uncategorized)

Sample code for sending a message using J2ME: You can send message with or without port.

MessageConnection smsconn = null;

try {

/** Open the message connection. */

smsconn = (MessageConnection)Connector.open(address);

TextMessage txtmessage =

(TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE);

txtmessage.setAddress(address);

txtmessage.setPayloadText(messageBox.getString());

smsconn.send(txtmessage);

} catch (Throwable t) {

t.printStackTrace();

}

if (smsconn != null) {

try {

smsconn.close();

} catch (IOException ioe) {

System.out.println(“Closing connection caught: “);

ioe.printStackTrace();

}

}

Permalink 1 Comment

Start the Midlet when New Message arrived

May 7, 2008 at 5:07 am (Mobile, Programming, Uncategorized)

If you want your midlet to start when incoming message arrived, the message should be sent with specific port where your midlet is listening.

Your jad file should look like this
MIDlet-Jar-URL: MyMidlet-0.0.1.jar
MIDlet-Jar-Size: 556255
MIDlet-Name: MyMidlet
MIDlet-Vendor: 3rd Brand Pte Ltd.
MIDlet-Version: 0.0.1
MIDlet-1: com.MyMidlet
MIDlet-Push-1: sms://:5000,MyMidlet,*
MIDlet-PortNumber: 5000
MIDlet-Permissions: javax.microedition.io.PushRegistry,javax.wireless.messaging.sms.receive

But your midlet does not automatically start when new message arrive.. It will ask you if you want to start your midlet.

Permalink Leave a Comment

Writing J2ME Application in Linux

April 30, 2008 at 2:23 am (Mobile, Programming, Uncategorized)

If you’re going to create a mobile game application better use j2me.. But if you’re mobile application runs in a background better used symbian c++.
Quick Start for setting up your workspace..
1. Install eclipse in synaptic manager for your IDE. Why choose eclipse? Simple and easy to use.
2. You need to have the Java Development Kit (JDK) and the Sun Java Wireless Toolkit (WTK) installed on your system. Click here for installation tutorial
3. Install JDK Sun Java Standard Edition (SE) Downloads .
4. After setting up all the installers, you can now create a simple Hello World.

Creating a project:
1 Choose File – > New -> Project
2. New Poject window will appear. Select J2ME Midlet suite then click Next. Type the name of your project. Example HelloWorld Select which Device your going to use. Then click Finish.
3. On the project explorer pane, right click the name of your project.Select New – > Package. Type the name of your package.
4. After creating a package, right click it, select New -> File . Type your filename for example “HelloWorld.java”

Type this source code.
Create the file src/HelloWorld.java with the following code:

// Sample adapted from http://developers.sun.com/mobility/midp/articles/wtoolkit/
package com.hello
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld
extends MIDlet
implements CommandListener
{
private Form mMainForm;
public HelloWorld()
{
mMainForm = new Form(“HelloWorld”);
mMainForm.append(new StringItem(null, “Hello, World!”));
mMainForm.addCommand(new Command(“Exit”, Command.EXIT, 0));
mMainForm.setCommandListener(this);
}
public void startApp()
{ Display.getDisplay(this).setCurrent(mMainForm); }
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable s)
{ notifyDestroyed(); }
}

5. You can now run your HelloWorld midlet.
6. Creating the jar file. Right click the name of your project . Select J2ME then Create Package..

Permalink 3 Comments

Keep Moving Forward

April 30, 2008 at 12:42 am (Uncategorized)

The first lesson in my work.. Keep Moving Forward..
The incident happened when I checked- in the svn ( svn commit -m”checkin tester program”). By the way, what is svn/ subversion? “Subversion is used for version control when developing a program or system. It helps to keep track of your versions”. I used the copy for different program. When I checked-in my project, I forgot that there is hidden folder .svn. The backup copy is also updated and the tags are broken.. What a big mistake I have done. I’mm afraid that it can damage the working copy in our trunk.. My boss told me that it’s ok to make a mistake, at least you learned. He also told me about the movie “Meet the Robinsons” and lesson on this movie is “Keep Moving Forward”.. Thanks to svn.. It can revert the working copy..

Permalink 2 Comments

Next page »