TECHiE TALKS

Just another techie stuff

The floating message goes here

Bubble Sort and Graphics.h in Dev C++

dev c++

Lately I have been searching  this post on the net about graphics.h in dev c++ and found few resources about it .  So I decided to write how to use graphics.h in dev-c++.  I am expecting that you have already installed bloodshed dev-cpp on your machine.  Graphics.h is a header file found in borlan c but because of its late development devcpp is now the mostly used IDE and compiler in programming c++.

Below are the steps on how to get graphics.h running on your machine,

  1. download graphics.h and save it to the include folder where you installed dev-cpp (C:\Dev-Cpp\include)
  2. Download libbgi.a and save it in the lib folder where you installed dev-cpp (C:\Dev-Cpp\lib)
  3. So when you have to create a program that needs the use of graphics.h  you must instruct the linker to link in certain libraries by going to projects > project options > parameters tab > linker column copy the lines below and paste it on that column.
-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32

By then you should be able to use graphics.h. As a sample I created this bubble sort algorithm as an example on how to use graphics.h in c++. Read the rest…

Did find the post very useful? Maybe you want to buy me a glass of beer!

No Comments

Saving .ico in Photoshop

Photoshop

Adobe Photoshop is one of the most advance tools in digital image editing and for developments as well such as icons and some other stuff.  Photoshop now is on CS5 which handles several new features and one is Content-Aware Fill where you can magically fill in spaces on digital images matching the tones, lightning and noise of the images making it as if it existed on the image.  You can find more of the new features on their site. Read the rest…

Did find the post very useful? Maybe you want to buy me a glass of beer!

No Comments

Slackware PHP GD Error

In the past months I was able to handle a LAMP server, this is my second time to handle a UNIX based web server but this time its a lot different because I will will be the one to install and configure the web server.  Our System administrator was the one who installed the latest version of slackware which is 13.1 on the machine, so all I need to do is have the web server up and running.

Our system administrator did include the x packages when he installed slackware and this caused me a problem in running PHP because it gave me several errors in GD support.  The error I get was,

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/gd.so’ – libxcb-xlib.so.0: cannot open shared object file: No such file or directory in Unknown on line 0

I was able to solve the problem with the following steps taken and was based from a linux forum I really loved. Read the rest…

Did find the post very useful? Maybe you want to buy me a glass of beer!

No Comments

Change a String or Character in MySQL

Knowing the right MySQL statement is the most important part in having thousands of data in your database, one false move and you can’t undo things.    If you want to change a string or character in your database and doing it manually in thousands or millions of entries then that should consume all of your time.

One example scenario is when you want to change all the entries containing a character ‘_’ to this character ‘-’ .  All you need to do is have a backup first on that specific table or database so that whatever false move you  will be doing, you can still have the data back.  After having the backup here is the SQL syntax that you should enter:

UPDATE Table SET Column = Replace(Column, ‘find value’, ‘replacement value’) WHERE xxx

Where in my scenario:

UPDATE paging SET pagename = Replace(pagename, ‘_’, ‘-’)

There within less than a minute I was able to change all the data containing ‘_’.  It saved me a lot of time and I can continue coding some other stuff rather than editing the data manually.  Hope this helps and happy coding!

Did find the post very useful? Maybe you want to buy me a glass of beer!

No Comments

Thunderbird To Outlook

I have successfully exported Thunderbird email files on ms outlook 2007 on a Windows XP platform which can also be done in windows vista and windows 7 platform.  There are several steps on how to do it.

1.  First, you need to download and install this software:  IMAPSize
2. Locate your Thunderbird emails, usually it is located in this directory C:\Documents and Settings\user\Application Data\Thunderbird  or  you can copy paste the directory and change the user to your account name.  When you are in the application data folder of Thunderbird navigate to the mail folder of the email account you want to convert.  Make sure you make full backup on the mail folder before doing the conversion. Read the rest…

Did find the post very useful? Maybe you want to buy me a glass of beer!

No Comments

Getting Main Domain

Do you want to extract the main domain of a URL?  Here is a function that works well and can be modified easily.  I found this function while searching for a good Regular Expression to fulfill such result.

<?php
function get_base_domain($url)  {
$debug = 0;
$base_domain = '';
$G_TLD = array(
'biz','com','edu','gov','info','int','mil','name','net','org','aero','asia','cat','coop','jobs','mobi','museum',
'pro','tel','travel','arpa','root','berlin','bzh','cym','gal','geo','kid','kids','lat','mail','nyc','post','sco','web','xxx',
'nato','example','invalid','localhost','test','bitnet','csnet','ip','local','onion','uucp',
'co' );
// country tlds (source: http://en.wikipedia.org/wiki/Country_code_top-level_domain)
$C_TLD = array(
'ac','ad','ae','af','ag','ai','al','am','an','ao','aq','ar','as','at','au','aw','ax','az',
'ba','bb','bd','be','bf','bg','bh','bi','bj','bm','bn','bo','br','bs','bt','bw','by','bz',
'ca','cc','cd','cf','cg','ch','ci','ck','cl','cm','cn','co','cr','cu','cv','cx','cy','cz',
'de','dj','dk','dm','do','dz','ec','ee','eg','er','es','et','eu','fi','fj','fk','fm','fo',
'fr','ga','gd','ge','gf','gg','gh','gi','gl','gm','gn','gp','gq','gr','gs','gt','gu','gw',
'gy','hk','hm','hn','hr','ht','hu','id','ie','il','im','in','io','iq','ir','is','it','je',
'jm','jo','jp','ke','kg','kh','ki','km','kn','kr','kw','ky','kz','la','lb','lc','li','lk',
'lr','ls','lt','lu','lv','ly','ma','mc','md','mg','mh','mk','ml','mm','mn','mo','mp','mq',
'mr','ms','mt','mu','mv','mw','mx','my','mz','na','nc','ne','nf','ng','ni','nl','no','np',
'nr','nu','nz','om','pa','pe','pf','pg','ph','pk','pl','pn','pr','ps','pt','pw','py','qa',
're','ro','ru','rw','sa','sb','sc','sd','se','sg','sh','si','sk','sl','sm','sn','sr','st',
'sv','sy','sz','tc','td','tf','tg','th','tj','tk','tl','tm','tn','to','tr','tt','tv','tw',
'tz','ua','ug','uk','us','uy','uz','va','vc','ve','vg','vi','vn','vu','wf','ws','ye','yu',
'za','zm','zw','eh','kp','me','rs','um','bv','gb','pm','sj','so','yt','su','tp','bu','cs','dd','zr'
);
// get domain
>if ( !$full_domain = get_url_domain($url) ) {

return $base_domain;
}
// now the fun
// break up domain, reverse
$DOMAIN = explode('.', $full_domain);

if ( $debug ) print_r($DOMAIN);
$DOMAIN = array_reverse($DOMAIN);

if ( $debug ) print_r($DOMAIN);
// first check for ip address
>if ( count($DOMAIN) == 4 &amp;&amp; is_numeric($DOMAIN[0]) &amp;&amp; is_numeric($DOMAIN[3]) ) {

return $full_domain;
}
// if only 2 domain parts, that must be our domain
>if ( count($DOMAIN) <= 2 ) return $full_domain;

if ( in_array($DOMAIN[0], $C_TLD) &amp;&amp; in_array($DOMAIN[1], $G_TLD) &amp;&amp; $DOMAIN[2] != 'www' ) {
$full_domain = $DOMAIN[2] . '.' . $DOMAIN[1] . '.' . $DOMAIN[0];
}

else {
$full_domain = $DOMAIN[1] . '.' . $DOMAIN[0];;
}
// did we succeed?
>return $full_domain;
}
function get_url_domain($url)  {
$domain = '';
$_URL = parse_url($url);
// sanity check
>if ( empty($_URL) || empty($_URL['host']) )  {
$domain = '';
}

else {
$domain = $_URL['host'];
}

return $domain;
}
?>

To test the code we can use the function,

$url  = 'http://www.icpep.org';
echo get_base_domain($url) ; // icpep.org

Click here to download.

This code really helped me a lot.  There are a lot of Regular expressions out there but this simple approach can break all those head breaking expressions.  Btw, this function is free of use and is under GNU licensing.   Hope this functions is of big help to you also, happy coding!

Did find the post very useful? Maybe you want to buy me a glass of beer!

3 Comments

PLDT’s Port 25 (SMTP)

Today, a friend and a colleague of mine called me and questioned me why she can’t send emails using her mail client which is Incredimail which is one cool mail client because of the effects and animation.  It really bothered me a lot because I can’t solve the problem without being there in the situation and it is hard to explain things using a phone. So I went over to her place and to find out that PLDT changed their SMTP port to 587 which is not the usual port of SMTP.  But this is not only the solution, outgoing mail server should also be changed to smtpdsl4.pldtdsl.net instead of using your own outgoing mail server(mail.icpep.org).

This has become an issue but still PLDT has no action for this.  This is really one problem especially to those people who are not that techie.  Hope PLDT will change it back to the usual port and find other ways on how to solve the spamming issues.

To summarize it, you can configure your mail clients using the following information:

Outgoing mail server SMTP: smtpdsl4.pldtdsl.net
UNCHECK – My outgoing server (SMTP) requires authentication
USE Port: 587

Hope this helps in solving your problem.

Did find the post very useful? Maybe you want to buy me a glass of beer!

3 Comments

« Previous Entries

Rss Feeds