20.11.09

29 November 2009

The day started out fine. Woke up at about 8AM and then went back to bed. Woke up again at 9:30 then fixed myself. At about 10:30, I started for the office. It'll be a few more days later before we can migrate to the new office as I heard that there are lots of things to fix before it can be considered to be work-able. Also, the Internet connection for the place hadn't been put to place yet.

I goofed around (meaning worked) for a couple of hours then lunch came. We decided to take rice gruel (goto) with egg and fried tofu instead of the normal lunch. Man, I missed eating goto, I promise to make one for me and my wife at least every two weeks.

After office, Kelly and I went somewhere to talk to a client about building a content management system from scratch. I really think that CMSs should be customized for each client and avoid run-of-the-mill CMSs since you can only customize then as much as you can.

For this CMS, I will probably be using CodeIgniter PHP Framework and MySQL Database Server.

I just finished (albeit, lacking one functionality: the comments section) working on the database schema for the basic CMS. I just hope that my team mates would approve of the schema. If not, it's back to the drawing board for me. Not that I complain :D

As of this writing, I am about 78% complete on the Vicidial Report Generation Tool that I have been working for the past two months already.

5.10.09

SHA256 encryption and all the stuff....

What have I been doing?

I'm no security expert, but I have just implemented (read: copy and pasted code) sha256 encryption to my kcauth codeigniter plugin/module combo ( I don't like codeigniter, really don't know why...)

I'm still thinking if I will be using codeigniter's session or create my own. The former seems to be fine, but since I have no time to scrutinize the code, I cannot really rely on it. The latter would eventually be done, not at the moment since I don't have the time to create one from scratch (yet)

I have also created a HTTP GET middleware to read from a remote eventum source. Hopefully, this will scale as the middleware would be used by an application that's already a memory hog (without proper caching since it is in the development phase still, of course).

Still need to create memcache plugin for that codeigniter thingie. Also, I will need to find an easy payment gateway for the rf service that we are cooking up.

System.exit(0);

6.9.09

Ubuntu and AMP

Here are simple steps to get AMP (Apache, MySQL and PHP) running in Ubuntu.

1.) sudo aptitude install apache-mpm-prefork php5-mysql mysql-server -y

If you need phpmyadmin:

1.) sudo aptitude install phpmyadmin -y
2.) cd /etc/apache2/sites-available
3.) ln -s /etc/phpmyadmin/apache2.conf phpymadmin
4.) a2ensite phpymadmin
5.) /etc/init.d/apache2 reload

you can now go to : http://localhost/phpmyadmin

17.8.09

Subversion + SSH on ports other than 22

What you need:

putty (not the putty.exe but the whole installer as you need pageant, plink and puttygen :D)
subversion

Step 1: Install PUTTY
Step 2: Install subversion
Step 3: Create a profile for your server (indicate port, user, etc.) using putty (be sure not to overwrite Default Profile) (i.e. profile name is MyServer)
Step 4: using puttygen, create a private key and a public key
Step 5: copy the public key ( in the puttygen window ) to the .ssh/authorized_keys (located in your home directory) on your server
Step 6: load your private key using pageant
Step 7: the url for your repository will be svn+ssh://MyServer/path/to/your/repository

You're Done!

20.6.09

PHP5 RRD Module in Ubuntu/Debian Lenny missing!

Today, I started reading about using RRDTool in replacement for the flash-based reports that I was using for a pet project. What stunned me later was to finding out that php bindings for this nifty little tool is absent in my toolkit!

I am here now to tell you how I did it, well, sort of, :D

1.) be sure to download http://oss.oetiker.ch/rrdtool/pub/contrib/php_rrdtool.tar.gz
2.) apt-get (or I use aptitude in ubuntu) install librrd-dev php5-dev
3.) extract php_rrdtool.tar.gz (tar zxvf php_rrdtool.tar.gz
4.) enter the directory created by extraction then run phpize
5.) run ./configure then make to compile the module
6.) inside the created modules directory lies two files: rrdtool.so and rrdtool.la. copy both files to your extension_dir (which you can find out if you open the php.ini that is being called by your apache web server) I saved mine in /usr/lib/php5/20060613+lfs which is the default for debian lenny
7.) add this line:
extension=rrdtool.so
in any of your php.ini file (in debian lenny's or ubuntu's case, you can create a new .ini file in /etc/php5/apache2/conf.d and put that line in there )
8.) restart your apache webserver
9.) create a phpinfo(); file and see if these lines exists:
rrdtool
rrdtool Version 1.2.x extension
rrdtool support enabled

10.) you're done!

24.5.09

Symfony EDITOR :D

I come to realize that I can never leave without VIM. I've been hooked to it till kingdom come and I can never switch to any editor anymore. Most specially now that I have found this. Presenting (drum rolls). The VIM symfony plugin.

I would not give away the details. The thing is, I have been looking for this in almost all the editors that I have used so far. And for me, finding this thing off of the internet is a great surprise.

It does nothing more than take you to the template file of the current action that you are editing. For me this is a big thing as I don't have to leave vi just to go back and forth between the action and the template. It automatically opens it. If only komodo has this feature :D

I think that's all for now, have to get back to coding :D

http://www.vim.org/scripts/script.php?script_id=2128

Renz Out

24.4.09

Upgraded to Jaunty Jackalope

Wow! I just installed Ubuntu 9.04 Jaunty Jackalope and was really amazed on how fast the thing booted up.

Also, the install experience was really really nice. I just went through 7 steps and after a restart, here I am.

Try it now. It's very stable, so far so good, considering that I already "hacked" the system compiling things that I have had in the last linux that I used.

Peace!

12.3.09

Adding gmail SMTP to symfony 1.0

PHPMailer is already included in symfony, so why add one yourself?

The thing is, I never get PHPMailer that is bundled with symfony to work with my gmail account so I decided to find something that can be done.

1.) Create a file myMailer.class.php inside your lib directory (either in apps/app_name/lib or in your root lib directory)
2.) Put these codes in there:


class myMailer {

public function __construct($username, $password, $user_alias) {
$this->from = $username;
$this->password = $password;
$this->user_alias = $user_alias;
}

public function send($to, $subject, $body) {

$eol = "\r\n";
$host = 'gmail-smtp.l.google.com';
$port = 465; $fname = $this->user_alias;
$data = 'Date: ' . date ( 'r', time () ) . $eol;
$data .= 'From: "' . $this->from . $eol;
$data .= 'Subject: ' . $subject . $eol;
$data .= 'To: "' . $to . '" <' . $to . '>' .
$eol; $data .= 'X-Priority: 1 (High)' . $eol;
// you can comment this one out if you want a normal email.
$data .= 'X-Mailer: ' . $eol;
$data .= 'MIME-Version: 1.0' . $eol;
$data .= 'Content-Type: text/plain; charset="ISO-8859-1"' . $eol;
$data .= 'Content-Transfer-Encoding: 8bit' . $eol . $eol;
$data .= $body . $eol;

$has_error = false;
if ( ( $smtp = fsockopen ( 'ssl://' . $host, $port, $errno, $errstr, 5 ) ) ) {
fputs ( $smtp, 'HELO ' . $host . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) { $
has_error = true;
}
sleep(2);
fputs ( $smtp, 'AUTH LOGIN' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, base64_encode ( $this->from ) . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, base64_encode ( $this->password ) . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, 'MAIL From: <' . $this->from . '>' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
} sleep(2);
fputs ( $smtp, 'RCPT To: <' . $to . '>' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, 'DATA' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, $data . $eol . '.' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
sleep(2);
fputs ( $smtp, 'QUIT' . $eol );
if ( ! $this->test_return ( $smtp, $error ) ) {
$has_error = true;
}
fclose ( $smtp );
}
return !$has_error;
}

function test_return ( $res, &$error ) {
$out = fread ( $res, 1 );
$len = socket_get_status ( $res );
if ( $len > 0 ) {
$out .= fread ( $res, $len['unread_bytes'] );
}

//echo $out;
if ( preg_match ( "/^5/", $out ) ) {
$error = $out;
return false;
}
return true;
}

}


3.) In your controller, you can now use it this way:

$mail = myMailer(“username@gmail.com”, “thisshouldbeaveryhardpassword!@#$!@#$!@#$”, “From Me!”);
if($mail->send(“spam_victim@somewhere.com”, “This Is Spam”, “<div style=’font-size:300px’>GET THIS</div>”)) echo “Mail Sent!”;
else echo “Mail is not sent!”;


And you’re done!

8.3.09

Sending HTTP Posts through JAVA

I found this truly helpful tip :D

http://www.javaworld.com/javatips/jw-javatip34.html?page=1

From the site:

    URL              url;
    URLConnection   urlConn;
    DataOutputStream    printout;
    DataInputStream     input;
    // URL of CGI-Bin script.
    url = new URL (getCodeBase().toString() + "env.tcgi");
    // URL connection channel.
    urlConn = url.openConnection();
    // Let the run-time system (RTS) know that we want input.
    urlConn.setDoInput (true);
    // Let the RTS know that we want to do output.
    urlConn.setDoOutput (true);
    // No caching, we want the real thing.
    urlConn.setUseCaches (false);
    // Specify the content type.
    urlConn.setRequestProperty
    ("Content-Type", "application/x-www-form-urlencoded");
    // Send POST output.
    printout = new DataOutputStream (urlConn.getOutputStream ());
    String content =
    "name=" + URLEncoder.encode ("Buford Early") +
    "&email=" + URLEncoder.encode ("buford@known-space.com");
    printout.writeBytes (content);
    printout.flush ();
    printout.close ();
    // Get response data.
    input = new DataInputStream (urlConn.getInputStream ());
    String str;
    while (null != ((str = input.readLine())))
    {
    System.out.println (str);
    textArea.appendText (str + "\n");
    }
    input.close ();



Thanks to the person who posted this :D

11.2.09

Signing Jar Files

Compared to most Java programmers, I can still call myself a newbie.

I just learned how to sign java jars to be able to maximize the potential of applets.

1.) First of all you need to create your keystore. A keystore file (usually named .keystore in your home directory) contains your private and public keys. .keystore is stored in a binary jks format (Java Key Store) similar to PKCS #12 containing both public and private keys, protected by a passphrase. The first four signature bytes of a Sun .keystore file in hex are FEEDFEED. ( http://mindprod.com/jgloss/keystore.html)

    To create your keystore, you need the keytool which you can get with most java jdk. At the command line, you type something:

    keytool –genkey –alias alias_to_be_used

    you need to specify alias_to_be_used as this will be the alias that you will be using for the jarsigner command later.

2.) You can save your .keystore file if you are going to transfer to other machines or reformat the machine that you are going to be using. You just have to remember to put it at your home directory.

3.) You can now create your jar file. After which you can issue the command:

    jarsigner –storepass yourpassword –keypass yourpassword jarfile.jar alias_to_be_used

     you have to specify yourpassword for both the storepass and keypass as they could be different passwords (as you will be prompted in the keytool to be able to do so). Also don’t forget to change jarfile.jar for the filename of your jarfile and alias_to_be_used for the alias you supplied to keytool.

4.) That’s it you have a jar signed file.

Enough for now, back to work...

3.2.09

Now: Java

Hi,

It's been a while since I posted here and a lot of things happened already. Tonight, I will be posting of a different thing as I have been re-learning JAVA. Yes, the old programming paradigm that I once rubbed off my shoulder was once again at the doorsteps, knocking at ME to learn about it.

Now that JAVA is OpenSource, I am still a bit skeptic about what can be done with it.

There must be a reason why I am now shifting most of my time to JAVA and not with Python,PHP and C++ which is what I commonly use.

Just to keep you hanging and of course, not to spoil the company's plan, I would not discuss the details of what I have been doing the last 2 months. I have a month more of development for this so I'm going to keep my fingers shut until it is the time to divulge the great secret.

After which, I will be blogging about the pain, the hardships and all the fuzz that happened before, during and after development.

Thanks for reading.

14.1.09

Installing APACHE 2.2, PHP 5.2 and MySQL on Windows XP that works

1.) Get apache 2.2 from http://httpd.apache.org I prefer that you download the one with ssl
2.) Next, get PHP from http://ph.php.net/get/php-5.2.8-Win32.zip/from/a/mirror. I am downloading PHP 5.2.8.8 windows binaries in ZIP file not the installer
3.) Next get mysql from http://dev.mysql.com/downloads I got mysql 5.1 community edition essentials
4.) wait for them to finish
5.) Install apache normally first. I installed mine on C:\apache you can use the default
6.) Next install MySQL you would want to configure the root password
7.) extract PHP somewhere, I did mine in C:\PHP
8.) add this to httpd.conf that is in C:\apache\conf:

LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

PHPIniDir "C:/php"

9.) restart apache
10.) create this as index.php in your C:\apache\htdocs folder:

phpinfo();
?>

11.) open a browser and point to: http://localhost/index.php
12.) in the line: Loaded Configuration File you will find that there is none loaded so in your c:\php directory rename php.ini-recommended to php.ini. open the file and uncomment the line extension=php_mysql.dll it's around line 681. also, don't forget to change the extension_dir around line 542 to read :

extension_dir="C:/php/ext"

13.) restart apache again
14.) check again http://localhost/index.php as you can see, mysql is not included in there.
15.) to enable mysql in php:
I. copy the file libmysql.dll from the directory where you install mysql usually in C:\Program Files\MySQL
to C:\php
II. you need to put mysql's bin path to the PATH environment variable the same with C:\php
III. at this point you need to restart
IV. check again at http://localhost/index.php and you should see mysql already there
16.) Edit again c:\apache\conf\httpd.conf the line:
DirectoryIndex index.html
should now read:
DirectoryIndex index.php index.html

17.) Restart apache and now you are done!