Archive for the ‘programming’ Category

using php mail() with postfix

Monday, April 16th, 2007

First, let me give a short history… I had to make a script at work that would get fired off by our hylafax server when ever an incoming fax was recieved. This script needed to check the caller id info and see what number was dialed, then based on that either move the file into a dir for the department it was intended for, or if it was ment for a person then to convert the tiff file into a pdf then email them the fax. Sounds simple enough… So for what ever reason my boss is hung up on using php for everything so I start working on this thing in php. We are using asterisk at work with IAXmodem to make asterisk and hylafax work happy like.. We have given all 90+ users we have their own DID as well as their own FaxDID. What I do with this script is lookup the number that was passed with callerid info in a mysql database to see whos umber it is, I get their username and their email as well as some other info, then mail the user the fax. I decided to use Pear for this because I like to reuse code when ever possible. I made a simple script to get the job done and damn to hell if it wouldnt work. I would get an email with the headers all screwed up. I knew they were not getting messed up in the php because I could print the email (headers and all) to the command line and it was perfect. I tried this same script on another box (that happened to have sendmail) and it woked perfect. I spent all damn day trying to figure out why my emails were not being sent correctly today. Then along came my good buddy Caleb. The first words from his mouth were ” I bet the working servers are sendmail and the nonworking are postfix” Sure enough that was the case. For what ever reason postfix is adding 2 new lines to my stuff. The fix was really extremely trivial.

$body = $mime->get();
$body = str_replace(“\r”,”,$body);
$headers = $mime->headers($headers);
$headers = str_replace(“\r”,”,$headers);

The full script can be found here. This script is not the best work ever, and it could be improved for sure. But this is what I am using. I hope someone can find it useful someday.

PekWM, its whats for breakfast!

Thursday, October 12th, 2006

I have been trying to get a package built for fedora for pekwm. PekWM is a nice light weight window manager for X-11. I decided to give it a shot using it because it supported dynamic menus. I built a package and filed a bug report so it could be included in fedora extras. After my first couple of comments it was suggested to me to create something more fedora friendly for my package. As it is the default menu provided by pekwm has a lot of apps in it. I didnt even have 1/2 of them my self. This was a minor problem to provide a package to a user who in turn cant use 1/2 of whats in the menu. It doesnt take an expert to figure out that bugs would be filed about things “not working”. I decided to take the code from fluxbox-xdg-menu and fork it to work for pekwm. After about an hour or so of hacking I removed all the unneeded stuff from its code base and had a fully functional dynamic menu generator using standards. Tonight I plan to repackage pekwm and post an updated .spec file and src rpm. I hope that by the first of next week I will be commiting pekwm to fedora extras cvs.

More Fedora RPMS

Wednesday, September 27th, 2006

I have been on a kick lately building packages for Fedora. I have started to build packages for:

And several others which are slipping my mind right now. I plan to add as many new packages each day as I can. I am still building fluxbox and fluxbox-svn packages too. All the packages are built using mock to help make sure that all the deps are met during build time, and that they are built in a clean env every time (just like in the fedora extras project 🙂 ) In the next couple of weeks I will be submitting all the packages I have been building for review to the fedora extras project (I really hope they get accepted and find their way in so I can yum install them on my other systems 😛 ).

Google hosting for t3h win!!

Wednesday, September 27th, 2006

Many of you may not know that google is now offering project hosting. This is great. I have been needing svn access for a project I work on, and this made it simple. I just went and filled out a short form and started using the service. Thanks google 🙂

Fedora Core 5 irssi scripts

Tuesday, August 8th, 2006

I have been using irssi as my IRC client on gentoo for years. I loved it, I would run it in screen so when I was out in the “real world” I could ssh into my system and “pick up” my IRC session and chat with my buds. When I installed fedora a few weeks ago I made sure to install irssi as well

yum install irssi

For those of you who wanted to know how to install it for your self. I noticed after I installed it I wasnt able to load any of the scripts I have written for it. I was missing the vital command “/script”. To solve this problem all that has to be done is to run the following command

/load perl

This will give you the “/script” command, and with out it you cant load or run any perl scripts. To keep from typing this every time you start irssi simply add it to your startup script for irssi. From the command prompt run the following command

echo "load perl" >> ~/.irssi/startup

I hope this will help someone out there.

UIL regional meet, and another year older :)

Friday, April 21st, 2006

Well today was my 26th Birthday. I had a really good time. I didnt do what most people I know who are in their 20’s do on their birthday (which is go out and drink and party). Instead I was a judge at a UIL computer science regional meet. It was totally awesome. There was a total of 9 teams from all across parts of Texas. One team ended up having to quit before we got started because they had a sick team member and they didnt have the required 3 team members needed to compete. The contest had a total of 12 problems that each team could choose to do. Each problem they got correct was worth a max of 60 points. Some of the problems were so easy to do that if you didnt get them right you didnt need to be there in the first place, and others would have taken me more than the 2 hours of allowed time to write. All the teams got problems 11, and 12 right off the bat with the first submission taking under 8 mins. Which isnt much of a suprise considering this was all that was needed:

for(int i=0;i<23555;i++) System.out.println(“some message”);

Most of the other programs required you to parse some given data files and do something with them. The easy ones were problems 11,12,1 and 2. Only 1 team even tried any other programs than those 4. Team 6 (no idea who team 6 was) They tried problem 6 and found a bug in the given data and we were able to reproduce the bug, this team would have won first place if they would have had the correct datafile to parse. I have no idea what will happen now but they should be given the points for finding the bug like they did. I got a shirt in the mail from today from my mom. It was the “No, I will not fix your computer.” shirt. Personally I think I had the coolest shirt on tonight at the contest. It was really a great time getting to see all the upcoming computer scientists, some of those kids were really bright. Well I guess this is the end of my geeky day. I guess Ill wrap it up by writting some java code on one of my apps.


Making a button inactive using PYGTK + GLADE

Sunday, October 2nd, 2005

I have been working on a little app in my spare time. It is for calculating your GPA. Its nothing special, I have even made a similar app in Java as an assignment in class. This app has (at the time of this writting) only 3 buttons. An “add” button, a “calculate” button, and a “quit” button. I decided I wanted to make it so once you hit calculate you could not press add or calculate again, this will prevent you from adding the same info to the display once it has been calculated (with out selecting something from the file menu to reset the form). I searched all over the net and couldnt find anything on how to make this happen but some of the wonderful people in #pygtk were able to help me so I thought I would pass that info along for anyone else.

I made a really simple example to show how this is done with pygtk and glade2. You can d/l the example here. If you have any questions, comments, or suggestions on how I could/should/needed to do this please feel free to comment. I do have moderation enabled for comments so it might take a day or so for it to show but I will allow (and will be open to) any comments that are not spam.

Commenting your code

Thursday, September 29th, 2005

Ok I have been reading and writting a lot of code lately, and one thing that is really pissing me off when I start reading other peoples code is the massive lack of commenting that is going on. It really drives me insane. Whats wrong with taking 1 min of your time as you are writting code to pause and

// this is a comment
/* or maybe this is a comment */
# and maybe this is a comment…
! Maybe even this. Whats it take to get people to comment!?!?!

It doesnt make you cool to not add comments to your code, no one thinks youre a great programmer because you managed to write 1200 lines and not 1 comment in it, it makes you a bit of an a-hole. Im not talking to any one person out there, and if you do comment your code good woot for you, keep it up.

I have been running into a whole mess of uncommented code in the UT2004 video game. It has all this open source stuff where you can make mods etc etc, and thats great and all, but when youre doing code for public projects such as a game mod like this; even if you dont think anyone will look at the code; better guess again, we will reverse compile your code and look what you did to see how it happened so we can make a mod thats similar or maybe even fix a bug in your mod (yep you might have a bug in your mod I know its hard to believe) and reading through 1261 lines of code to find 10 lines that have a comment on them and then only 4 of those 10 are even the slightest bit like a comment (the others are who evers name and date etc) makes it harder to fix your code, or see what youre doing/trying to do. Moral of this rant is to comment your code no matter what your doing!!!!!

How to start Fluxbox with a random style

Wednesday, April 20th, 2005

In #fluxbox yesterday someone asked if fluxbox could be started with a random style everytime. The simple answer is no. I told this person I did feel it would be a simple thing to whip up a script to set the style to be random everytime, and well….it was pretty easy. If you would like to have fluxbox start with a random style try my script in the downloads section. Its in the perl section. Right now the styles must be located in ~/.fluxbox/styles and I dont really have plans to do anything else to it unless someone sends a patch.

Fluxbox Patch

Monday, April 4th, 2005

I was on IRC the other day in #fluxbox talking with some of the guys when one of them mentioned something about a run tool in the toolbar. I thought that sounded like a good idea so I wanted to add it to my fluxbox. I went to the place I find all the coolest patches for fluxbox. The name of the patch that I added was runtool-svn.diff. ak|ra is the author of this wonderful patch. I think this is a great patch. I hope to see it make it into the next release, and better yet I hope it is commited to SVN soon so I dont have to remember to apply the patch when I build. If you wonder how it looks here is a shot of what mine looks like