Categories
Programmer's Mindset

Jenkin’s Build Pipeline

I watched a great video of a presentation by @adamculp about Jenkins. I have been setting up a Jenkin’s build server for a while, but this thing can be both easy and complicated at times. The video, while great, left me wanting more of the specifics of the setup, not just “look at what this can do”. I wanted, “This is how you do this”.

I reached out to Adam on the twittersphere and he told me which plugins I needed. The one I really wanted was the Build Pipeline Plugin, and when I finally took a second to scroll down on the plugins page, things started to click. Specifically “views”. I hadn’t used them before.

Even with the instructions, I missed the key point. It says to add a new build pipeline view, so I kept clicking on New Item and not finding it. I read a little closer and looked at the picture, and it was clear… Click the “+” to create a new view.

Categories
Programmer's Mindset

Should Website Authentication Really Require Email Addresses?

At SDPHP we are starting an open source project (grouptopics) for user groups, but that is for another post.

We are setting up oAuth authentication with Google, Twitter, and Facebook.  While doing so, the developer that did the initial integration stopped with the Twitter integration because they do not give you an email address, and he is steadfast that an email address should be required for a user.

I have thought a lot about this lately, and I am of the personal belief that an email address is not required.  While I would like to have one for communication, the main goal is authentication.  Having the email address does nothing to accomplish this authentication, it just serves our greedy desire to send emails that are probably unwanted.

I have not given any final direction towards the group.  What are your thoughts?  Do I listen to him and require it, or go with my gut and say that it shouldn’t be required?

 

Categories
post

How I Am Choosing Sections Of A Website To Optimize

I have an e-commerce system that is a complete PHP spaghetti mess.

I am running way Way WAY to many database queries. I want to share how I am tackling this mess.

I am using the mysql general log to store the queries that are being run to both a table and a file. At first I was using this to see what was run most often, and started caching those in memcache.

Today I decided, why don’t I find out what pages are causing the most queries, and optimize those, instead of individual queries. For example, my first test showed my product page took 110 queries.

1) I am executing this https://gist.github.com/1958901 on every page when I initialize the DB.
2) I turn on the general log for a few minutes. set global general_log=1; wait…. set global general_log=0;
3) I am using this query to find out what threads are running the most queries.
SELECT general_log., count(*) as c from general_log where general_log.event_time like ‘2012-03-02%’ and argument like ‘SELECT%’ group by q order by c DESC limit 10
4) I can then use the thread_id to find out what it was doing. The @page from the gist above will be one of the first queries, so I know where to start analyzing.

I hope this helps someone else.

Categories
post

Pre-Commit Fails When Removing a File From Git

I just blogged about automatically running PHP Lint when committing a file into the repo. Well I also had the joy of it failing because I removed a file.

If you get “Could not open input file: abc.php”, then you may have the same problem I did.

There’s an easy solution. The pre-commit file looks for all changed files. Technically, a removed file is changed, but it also doesn’t exist when you go to run php -l against it.

Open your pre-commit file, and change the line that looks like this:

exec(“git diff-index –cached –name-only {$against}”, $output);

to

exec(“git diff-index –diff-filter=ACMRTUXB –cached –name-only {$against}”, $output);

Categories
post

Run PHP Lint before committing to GIT

This is going to sound stupid, but if you don’t have rock solid unit tests in place, one of the things you should be doing is running PHP Lint.

What is PHP Lint?
Simply stated, it checks your php file for syntax errors. How many times have you forgotten a semi-colon, or had unmatched curly braces?

How do I run PHP Lint?
It is very easy to run from the command line
php -l your_php_file.php

Using GIT? You should setup a pre-commit hook to always do this so you don’t push something bad into the repo. I am guilty of doing this in the past. 🙁

Here is a great post by Travis Swicegood about setting this up.
http://phpadvent.org/2008/dont-commit-that-error-by-travis-swicegood

One thing to remember is that you also have to make the script executable.
chmod 744 .git/hooks/pre-commit

Categories
post

I am coining a new term “Arsonistic Firefighter”

I find myself putting out fires in my code base all the time. The problem is, I set the fires to begin with. 🙁

Categories
post

Making WAVs play in Chrome for Mac

I was really frustrated that our voicemail was not working in Chrome. All it said was Missing Plug-in.

Through some research, I found that the voicemail system was loading the files via ajax to a PHP script. Because the extension was not .wav, Chrome was confused.

How did I solve?

Well, this is an internal box with very little traffic and I have complete control of it.

I first told Apache to treat all .php.wav files as PHP. In httpd.conf of php.conf you will see
AddHandler php5-script .php

Add this right below it.
AddHandler php5-script .php.wav

Restart Apache.

Then I symlinked the .php file to a .php.wav file. So that they were identical. Then in the file that pulled in this php file, I changed the filename there as well.

Fixed my issue. 🙂

Categories
post

PHP Parse error: syntax error, unexpected $end in

I was receiving this error and did a quick Google search to figure out why. Most posts referred to a missing curly brace “}”.

I went through about 3-4 posts when it hit me. My code was from an older server that allowed the short tag

Categories
post

PHP Excel/reader.php Date Format Error

I, like so many others have been confused by the Excel/reader.php problem with dates. I took the time today to patch it for myself. This works in my situations, but may not in yours. Make a backup before trying this.

You will see in the diff that for some reason the date being returned was off by a day, so I fixed by adding 86400.

Here is the patch:

Categories
post

Why Aren’t You Using Git Flow?

I gave a presentation at Orlando PHP last night. I had a great time, and everyone there was fantastic.

I really want to improve my public speaking. I gave a very simple introduction of myself to a Google Checkout panel a few years ago and thought I was going to passout. I felt I did a horrendous job, and all I was doing was talking about myself and the company I work for.

Enough about that. Last night I was running late due to traffic on I-4 because of the rain. I got there and was very surprised to see one of the biggest turnouts we have ever had for Orlando PHP. I quickly setup my computer while David Rogers talked a little about GIT.

I sped through my slides a little bit. I really didn’t want to just sit there and read what was on them. I wanted to be personable, clear spoken, and desperately wanted to avoid filler noises (ah’s, umm’s, like’s and you know’s). Overall I am very happy with the way it turned out.

Had I gotten there early, I would have setup a tripod and camera to tape it. Because I was running late, I scrapped that.

People were asking me some great questions, and I hope I took enough time to answer to the best of my ability. Some things I deferred to other members of the group that had better answers. Thank you Ketema for stepping in where you could.

I have become very passionate about using Git & Git Flow for my development. It has truly made me a better developer, rather than just a hacker.

Thank you to Vincent Driessen for sharing his git workflow originally. I used it for a couple of weeks, but ultimately did not keep up with it. At some point he released the “git flow” tools that I used in my presentation. I became aware of these tools thanks to Jeff Kreeftmeijer who wrote a blog post titles “Why Aren’t You Using Git Flow?

I have some resources at the end of the slides that you can refer to.