Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Posted in Uncategorized | 1 Comment

New Layout

This blog has been pretty lifeless and dull with small spurts of inspiration.  This week is one of those spurts.  I recently got a hold of a copy of http://www.sitepoint.com/books/wordpress1/.  Though I could probably figure most of it out, there will hopefully be some non straight forward information, and a more person and professional lay out and content coming to this blog.

Posted in Web Development | Leave a comment

Sphinx Installation and Setup

Sphinx is an open-source full-text search server, designed from the ground up with performance, relevance (aka search quality), and integration simplicity in mind. It supports multiple databases as well as files and streaming data. It has a command line implementation as well as API’s in many different languages. This guide will go over installation, setup, as well as some common problems that many first time users have while working with the LAMP stack. Read More »

Posted in Sphinx Search Engine Integration, Web Development | Tagged , , , | Leave a comment

Calculating Business Week

Need to calculate what day 10 business days ago was? This is how it is done.

Breaking it down
The function is passed the number of business days as an integer. It calculates the current day of the week 0-6, storing non-business days(Saturday and Sunday) as Mondays(1).

If the current day of the week is fewer than the given number of business days away from the previous non business day the function returns the number of business days. If this is not the case the function subtracts the number of business days already used this in week from the total number of business days(if today is Thursday then subtract 4 from the number of business days). The difference or remaining business days is divided by 5, the number of days in a business week. This number is then rounded down to the nearest even integer, it can be thought of the number of business weeks or the number of skipped weekends. Adding 1 accounts for the weekend that was skipped with the original subtractions. Multiplying the number of skipped weekends by 2 returns the total number of skipped business days.

skippedWeekend is added to account for days that were skipped if the current day is on a weekend.

Posted in Web Development | Leave a comment

Setting Up MySQL Server on Ubuntu

Pretty easy first:

Read More »

Posted in Web Development | Leave a comment

Django On Mac OSx

Originally battling with installing Django on OSx I decided to go with my host(dream host) then after battling with them and realizing that I did alot of my development on a train with out internet access that it would really benefit me to install it on my Mac OSx Laptop and to forgot the Apache Integration, I thought this would be a synch armed with my new book I leaped into the unknown.  The instructions were pretty easy to follow:

I installed a new version of MySQL, pretty easy find out what version of OSx you’re running and if you don’t know how many bytes your processor is go with 32.

Then using basic commands from the Django website.  (I’m a big fan of svn, as i use it at work, I also see it’s down sides though) I was able to install Django and begin with the “interesting chapters” of my book.

./django-admin.py startapp mysite
./manage.py startserver(You can verify this works here, but we’ll check later)

So I trucked onwards in my book with the next command that actually set the framework and got the ball rolling.

./manage startapp blog

Then I continued defined a Model and set my database information in the settings tab.  And that’s when I hit my first road bump, I’m a trained programming not really a systems guy.  Everything I learn about sysadmins is by total accident in an attempt to do something with a programming language.

The first of two problems was python could not find the mysql driver.  This isn’t a hard problem at all.

1. Download East Install(download the egg that is the same version as python you’re running)
2. run the command “sudo sh setuptools-0.6c9-py2.4.egg ” renaming 2.4.egg to the file you’ve downloaded
3.  Run this command “easy_install MySQL-python” (This will install the mysql patch)
3.5 (At this point feel free to try the “./manage syncdb” command again it should fail
4. Open ./bash_profile or ./profile in using vim ~/.bash_profile or vim ~/.profile
5. add the following line PATH=”${PATH}:/usr/local/mysql/bin” (and “EXPORT PATH” if needed, this will allow all binary files to be added to the global link, to test this run mysql_config from wherever you are)
6. At this point you should be able to run “./manage syncdb” with no problem

If you’re following the same book as me, Python Web Development with Django, it will have you setup the admin controller for the blog site.  Once you do this and visit your blogsite you will have some error saying that “NameError: name ‘admin’ is not defined”.  In the urls.py add the following line of code “from django.contrib import admin” and you should be golden

Posted in Web Development | Leave a comment

Valid Credit Card Numbers for Paypal Sandbox

When testing your paypal account in the sandbox you’ll sometime need a fake credit card, and the ones supplied by Paypal do not work.
The easiest way is to login/create an account in the sandbox. When you do that goto My Account > Profile > Credit/Debit Cards.
From here create a credit card, remember the information for this credit card, and yes you can leave the Card Verification Number as 000.
And there you go, a valid credit card number. Note if you save this credit card you will not be able to save it as it will be tied to a paypal account.

Posted in Web Development | Leave a comment

Changing Search Engine in Chrome

To use google search in Chrome all you need to do is type the search term in the address bar, simple.
But is there a way to change the search engine to yahoo? Can I have multiple search engines like Firefox supports with a drop down, the answer is two these is yes.
Right click the address bar and click “Edit Search Engines”. As you can see there is a pre-populated list of popular search engines, as well as search engines that you have transfered over from existing browsers. You can easily any of these to your default search engine by click “Making Default” on the bottom when the specific search engine is selected. But how do you change the search engine?

When you looking at the “Edit Search Engines” window there are two columns: Name, Keywords. You can edit these by simply double clicking on the row. But back to the browser window, highlight the address bar(ctrl L) type the keyword for the search engine you want to use yahoo.com and then tab. This should create “Search Yahoo!” box in the url so you are aware of what engine you are using. escape will set the url back to what it was originally

Posted in Web Development | Leave a comment

My First Ruby Script

I decided as PHP developer I should learn another scripting language.  After running into RoR several times I decided I’d be better off just learning Ruby.  Asking my boss for any advise he told me to just rewrite what I do at work with Ruby.

Well I didn’t take is advice on a per word basis, but This is my first ruby script.  It’s designed to be run from the command line.  Any suggestions on making it better are welcomed.

This is a pretty straight forward function, slightly harder than your normal “Hello World” but doesn’t do anything to revolutionary. Little surprised about the lack of increment/decrement operator, but I recall reading that it isn’t not there because it is unclear.

Posted in Web Development | Leave a comment

Validating Integers

A while at work I came across some random reference where I need to validate that a $_POST or $_GET value was an integer. Now this is a fairy common problem, but like many PHP programmers I had never found Filter Var Functions. I came across what ended up being an extremely tedious work around.

The issue arises when a variable needs to be an integer where 0 is a possible value. Most databases don’t use 0 as indexs so this is a semi rare situation, but often happens on drop downs and sliders. The issue is as follows

The tricky thing about this function is it returns the integer value, so be careful to use !== when comparing to false.
There are a large number of “filters” that can replace common used regexp, IP address, email, url. I’d suggest giving this a really good going over.

Posted in Web Development | Leave a comment