Binary Expressions

« Previous PageNext Page »

2007-12-19

Perl - Out of Memory!

Filed under: — Adam @ 4:23 pm

Background Knowledge


This case was done on a machine running OpenBSD i386 v3.7 operating system with Perl v5.8.6 built for i386-openbsd using BASH as the command prompt interrupter.

I’ll be honest I have very little knowledge of Perl so if you have anything to comment on or suggest please do so.

Problem


I tried to install a couple Perl modules and received an error message of “Out of Memory!”.

Solution


Just to clarify I have very little knowledge when it comes to Perl, so this solution may or may not work for you.

On Unix machines each user has a ulimit or “user limit” which is basically from what I understand sets the limit for each resource to ensure the system is not over loaded or abused. In this case at least for me, my issue was not having a big enough data seg size. Type at the command prompt without quotes “ulimit -a” to see a list of the set limits. I increased my data seg size from 76800 to 200000. I did this by typing at the command prompt without quotes, “ulimit -d 200000″.

You may need to play with this value for your case or other ulimits. Don’t worry about the changes as none of them are permanent in this case, at least to my knowledge. When you use the ulimit it only changes it for the user you are using and for that given session. If you require more permanent changes look into using ulimit in the login script or better yet change your system configuration settings.

Comments/Thanks


Many thanks to Scott Corley who posted an excellent blog entry entitled “perl Out of memory! (with solution)” on his blog called “Red Mercury Labs”. Without this I was getting know where fast.

If anyone can provide some further knowledge on ulimit it would be much appreciated.

Source: Red Mercury Labs - perl Out of memory! (with solution)

2007-11-24

IBC - Inflammatory Breast Cancer

Filed under: — Adam @ 11:46 am

IBC should be known to all women of all ages, be informed and watch for symptoms.


Source: YouTube.com
Source: IBC Research Foundation

2007-11-23

Dik dik

Filed under: — Tux @ 1:48 am

This is got to be one of the oddest animals I have found out about, but for something that small and only grows up to be about a foot tall it is fairly cute.

read more | digg story

2007-11-16

French Characters Not Rendering Correctly

Filed under: — Adam @ 9:13 am

Background Knowledge


The MySQL database v4.0.23 is using the default character set of “Latin1″. When the database was created I had no knowledge of character sets other wise it would have been “UTF-8″.
The web pages are using a character set of “UTF-8″.

Problem


Data being queried from a MySQL database that contains French accent characters will not render correctly in the browser even after applying PHP htmlentities().

Example code: $string = htmlentities($string , ENT_QUOTES, “UTF-8″);

Solution


The queried data from the database was inputted using the character set “ISO-8859-1″. I found this out by changing the browser’s character encoding to “Western ISO-8859-1″ and the French accent characters then rendered properly. With the use of PHP iconv() I was able to convert the data from “ISO-8859-1″ to “UTF-8″ character set and the French characters then rendered properly in the browser.

Example code: $string = iconv(”ISO-8859-1″,”UTF-8″,”$string”);


If you are unaware of what MySQL default character set being used, you can run this SQL command “show variables like “%character%” and check your MySQL configuration file. Refer to the MySQL manual for further details.

2007-11-12

The Burger King Song Parody

Filed under: — Adam @ 8:17 am

Source: YouTube.com

2007-11-9

Finding The Total Lines Within Files

Filed under: — Adam @ 5:06 pm

I have learned by using the “find”, “wc” and “awk” commands one can find the total number of lines within files of a given directory and sub-directories. Thanks to NicM on IRC server Freenode channel #OpenBSD for his solution below.

Solution
find /path/blah -type f -name ‘*.php’|while read i; do wc -l <$i; done|awk ‘BEGIN { x=0 }; { x+=$1 }; END { print x }’

Note: Shell must be bourne-compatible.

2007-11-8

HTML_QuickForm Generates Invalid Code for XHTML Strict

Filed under: — Adam @ 4:18 pm

One of the biggest complaints I’ve had with HTML_QuickForm is not producing valid XHTML Strict code. Well there is a simple solution to removing the name attribute of the HTML form element tag using remoteAttribute().

Example
$form->removeAttribute(’name’);

2007-11-3

Mac or PC - Rap Music Video

Filed under: — Adam @ 7:25 pm

Source: Revver.com

The Day The Routers Died (song parody)

Filed under: — Adam @ 8:25 am

Source: YouTube.com

2007-11-1

PHP Calendar Functions Error

Filed under: — Adam @ 11:56 am

I was trying to use the PHP calendar API and immediately received this error message, “Fatal error: Call to undefined function cal_days_in_month()”. This error message means PHP was not compiled with the calendar extension.

Solution


The only solution to this error message and other similar error messages relating to the PHP calendar API requires PHP to be compiled with the calendar extension by adding “–enable-calendar” to the “configure command” as stated in the PHP documentation on the Calendar functions page.

How to Tell if the Calendar Extension is Installed


You can verify weather or not the PHP Calendar extension was compiled at install by using the phpinfo() function. When viewing the output of phpinfo() look under “Configure Command” just below “Build Date” and if you do not see “–enable-calendar” present then all PHP Calendar functions will not work.

Configure Example


./configure –with-mysql=/usr/local –with-mssql=/usr/local –with-apxs –with-zlib-dir=/usr/lib –with-libxml-dir=/usr/local –with-config-file-path=/var/www/conf –with-iconv=/usr/local/bin/iconv –enable-exif –-enable-mbstring –enable-calendar

2007-10-20

WordPress v2.05 to 2.3 Upgrade

Filed under: — Adam @ 9:18 am

Well this upgrade went very smooth with no problems at all. It really only took 3 steps to upgrade WordPress from v2.05 to v2.3. I had to upgrade two plugins and I deleted all the obsolete plugins to keep things clean. I admit a fresh install might have been better but didn’t want the hassle of putting the pieces back together.

Akismet plugin didn’t require any upgrade.

Upgraded WP Plugins (installed fresh)

Removed WP Plugins

  • WordPress Database Backup (upgrade required)
  • WP-Cron (obsolete)
  • WP-Cron-Mail (obsolete)
  • WP-Cron Dashboard (obsolete)
  • WP-Cron Future Pings (obsolete)
  • WP-Cron Gravatar Cache (obsolete)
  • WP-Cron Moderation (obsolete)
  • WP-Cron Reminder (obsolete)
  • WP-Cron UpdateLinks (obsolete)
  • WP-phpMyAdmin (upgrade required)

Source: Upgradding Wordpress

2007-10-17

PHP Free Chat - Joining Chat Email Notification

Filed under: — Adam @ 2:50 pm

I recently upgraded an install of PHP Free Chat to that latest version of 1.0 Final. However it was still lacking a feature to notify individual(s) that someone has joined the chat if they were not already in the chat application to begin with. I came across a posting explaining how to achieve this in PHP Free Chat at PHP Free Chat Forum. After a little reading and discussion I was able to implement the feature.

Here’s my modified version for the solution based on the forum posting. The pfcmail() function can be made to be way more versatile for any use, however for my use it was made to be simple and produce properly formated email messages.

Solution


  1. Create a new PHP file called pfcmail.php with the following lines of code.
  2. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    
    < ?php
    function pfcmail($szChannel,$szNickname)
    {
    	$szCurrentDateTime = date('F j, Y @ g:i:sa', time());
    	$szClientIP = getenv("REMOTE_ADDR");
    	$szHostName = gethostbyaddr("$szClientIP");
    	$szServerName = getenv("SERVER_NAME");
    	$szEmailWebmaster = getenv("SERVER_ADMIN");
     
    	$szEmailTo = "Webmaster <$szEmailWebmaster>";
    	$szMsgHeaders = "From: $szEmailWebmaster\r\n";
    	$szMsgHeaders .= "X-Mailer: PHP\r\n";
    	$szMsgHeaders .= "MIME-Version: 1.0\r\n";
    	$szMsgHeaders .= "Content-type: text/plain; charset=UTF-8";
    	$szMsgSubject = "[WEB] Chat Login - $szNickname in channel $szChannel at $szCurrentDateTime";
     
    	$szMsgBody = "Date\t\t\t\t: $szCurrentDateTime\n";
    	$szMsgBody .= "Server Name\t\t\t: $szServerName\n";
    	$szMsgBody .= "Client IP\t\t\t: $szClientIP\n";
    	$szMsgBody .= "Client Hostname\t\t: $szHostName\n\n";
     
    	$szMsgBody .= "Join chat now by going to http://$szServerName/chat/index.php.\n\n";
     
    	$szMsgBody .= "---\n";
    	$szMsgBody .= "Email message auto-generated by PHP mail().";
     
    	$nSendEmail = mail($szEmailTo, $szMsgSubject, $szMsgBody, $szMsgHeaders);
    }
    ?>
    Note: The extra r, n and t’s should have a \ character before them to produce a carriage return, new line and tab. WordPress appears to remove the character.
  3. Make sure to modifiy the code in pfcmail.php for the To, from, subject and body of the email message to your requirements.
  4. Save pfcmail.php file into the following path, /src/commands/.
  5. Edit /src/commands/nick.class.php at line number 84, just before “return true;” add the following code and save.
  6. require_once(dirname(__FILE__).”/pfcmail.php”);
    pfcmail($c->title, $newnick);

You should now be receiving email notifications each time an individual joins chat.

« Previous PageNext Page »

Take back your mailbox - CAUCE.org

Powered By Wordpress PHP: Hypertext Preprocessor MySQL Powered Download Juice, the cross-platform podcast receiver
Proud To Be Canadian Get Firefox Valid XHTML Valid CSS
<NO>OOXML Logo


26 queries. 0.475 seconds.
Copyright © 2004 - 2005 by Adam Douglas