Categories
Programmer's Mindset

Mysql Order By Clause Performance

Just had a strange query happen that I thought I would share.  I am by no means a Mysql expert, I know enough to usually write decent queries that are performant.

I had one today that was baffling me.  First, I know this should be extracted into reusable code, but right now that’s not the plan.  In one part of our system a query was happening pretty quickly.  In a new part that I am working on it was taking forever, to the point I had to kill the query (after 30+ seconds) so that it didn’t bring the entire system down.

I was trying everything to figure out why one was worse than the other.  They both seemed like terrible queries from first sight.  I rearranged the WHERE clause so that they matched, and that didn’t fix the problem.

The good query had: ORDER BY dateadded desc, id

The bad query had: ORDER BY dateadded desc

I guess that is something to try when you have non performant queries.  There was a subquery happening as well, so I think the order by may be helping the subquery.

It was just interesting to me and I thought I would share.

Categories
Programmer's Mindset

SD PHP Website Is Up

Being the organizer of SD PHP has been one of the most fulfilling experiences I have had yet. It has gone above and beyond anything I thought it would mean to me.

I have met some great people, and have learned more about what makes the PHP community so great.

So, we finally put a website up. It’s nothing great right now. It’s just your basic WordPress site, but it will at least give us a place to start putting some content. As always, I am very open to feedback and criticism (of the constructive kind).

Categories
Programmer's Mindset

Using OpenGPG to Encrypt/Sign Email

I used this over a decade ago, when I worked for tradeweb.net doing consulting in a doctor’s office.  We tried to get them to understand encrypting their emails.

After I left TradeWeb, I let go of using GPG (GNU Privacy Guard) out of laziness and the lack of adoption.  While attending #tek12 this year, my interest was again piqued by a presentation on security.

GPG or PGP (Pretty Good Privacy) are easy tools that help you sign/encrypt email.  If each one of us could convert a few people to using the tools, eventually it would spread to everyone.

Signing Emails

Signing emails is a way to let people confirm you are the author of a message.  It does not encrypt the email at all.  Since most people assume that when they receive an email addressed from you is from you, they don’t take the time to check the signature.  However, if they took the time to install the tools to check the signature, they would also have the tools that would allow me to encrypt my email to them.

Encrypting Email

For me to encrypt an email to you, I need you to already have a public key.  The email would automatically decrypt on your end, so it’s not like it takes any extra work.

Do us all a favor, help spread the word…

Categories
Programmer's Mindset

The Birth Of San Diego PHP Users Group

I am moving to San Diego, CA in one week. I have been a member of OrlandoPHP for about 18 months, so after I sold my house, I started looking for a user group to join. I searched and was shocked to find that there wasn’t an active PHP User’s Group. And as Cal Evans always says, if you look around for a user group leader and don’t find one, you’re it.

So I took the opportunity at #tek12 in Chicago to talk to a few user group leaders from around the country. I absorbed as much information as I could and recently opened San Diego PHP on meetup.com. It turns out there was a huge demand for this group in the area. We are already over 40 members with 15 confirmed for our first meetup.

The kicker is that I had two different members offer us conference room space to host the group, and also offered to buy pizza and drinks.

I am soooo looking forward to our first meetup and meeting the members. Looking for some fun and geekery, come check us out.

Categories
Programmer's Mindset

CraigsList / Amazon.com Trading Scam

I listed a bunch of things on CraigsList recently and started receiving a bunch of people asking me if I wanted to trade for crazy things.  Do I want to trade my $300 item for a $25 camera?  Of course not, so I just didn’t reply.

After the third or fourth one, I really wanted to know why they were asking me for these ridiculous trades.  I brainstormed for awhile, initially thinking they were trying to get my email address to sell it.  Then it hit me like a ton of bricks!  They have an Amazon Associate Account (AKA affiliate account).  They don’t want the trade, they just want me to click the link and forget about it.  Now if I buy from Amazon any time in the next month, they will get a percentage of the sale.

It’s ingenious and yet so deceptive.  Part of me wants to do this.  But the honest part of me can’t.  🙁   Should I participate in this type of scam?

 

Categories
Programmer's Mindset

PHP|Tek 2012

The Backstory

Two years ago, I attended php|tek 2010, and that is when my life began to change.  I met a few people and had a great time, but I was overly shy and didn’t get as much out of the networking opportunity as I could have.  One night, I went to dinner by myself at Harry Caray’s.  A nice expensive dinner, with nobody to share it with… 🙁

This is not meant to be an “oh woe is me” post.  However, this conference had a HUGE impact on me as a developer and my confidence from that point began to grow.  I saw myself in a different light, and made it a mission to change myself for the better.

I can honestly say that TekX changed my life for the better.  At least it was the catalyst for me to change my life.

The New Awakening

With the confidence from TekX, I began to do things like attend Orlando PHP and even considered starting up Daytona PHP again.  Over the two years I continued learning as much as I could, attended user group meeting, local events (like PHP Codeworks), etc…

I then started hanging out in IRC and met some great people virtually.  I learned about a fun podcast call “/dev/hell” and listened to Chris Hartjes make a really great point about being shy at conferences.  I bought him a beer this year because of that simple point.  Sorry, Ed, you weren’t there at that point, or I would have bought you one too.

Anyway, I stepped outside my comfort zone immediately by talking to someone (Tom, sorry I didn’t catch the last name) outside the airport.  I wasn’t even sure he was there for php|tek, but I did it any way and had many great conversation with him the entire week.

I went out to dinner with different people every night of the week and had a blast.  I joined into conversations, and even started conversations.  This was no ordinary trip for me, it was exciting and I didn’t find myself shying away into a corner like I had in the past.

Thank you to all the great people that I had great conversations with.

I have so much more to say, maybe another post soon.

Categories
PHP Snippets Programmer's Mindset

Solved: vBulletin Quick Reply Not Working (ckeditor.js unable to get value of the property ‘label’)

I have a vBulletin board that I manage and while recently had users complain about the Quick Reply not working.  They had to go into the advanced editor to make it work.

Doing my due diligence as an IT professional quickly narrowed it down to…. IE of course.  I spent hours digging, using a debugger I kept getting the error in the title of this post.  I kept going through the Call Stack trying to figure out what was going on, but the javascript is minified very tightly, so following it became daunting.

Two days later another user complained about not being able to update their profile.  While debugging this, both problems became very clear.

I had recently put in some rewrite rules to make the forum more SEO friendly.  However there are a couple situations where the rewrite rules broke down.  I was missing the two lines colored in green below.

RewriteEngine On
RewriteRule ^/videos.html /forums/36-Bowling-Videos-amp-Pictures
RewriteRule ^/threads/ckeditor.php /ckeditor.php?t=$1 [L]
RewriteRule ^/threads/(.*) /showthread.php?t=$1 [L]
RewriteRule ^/forums/(.*) /forumdisplay.php?$1 [L]
RewriteRule ^/entries/(.*) /entry.php?$1 [L]
RewriteRule ^/blogs/(.*) /blog.php?$1 [L]
RewriteRule ^/members/ajax.php /ajax.php?$1 [L]
RewriteRule ^/members/(.*) /member.php?$1 [L]
RewriteRule ^/list/(.*) /list.php?$1 [L]
RewriteRule ^/list/author/(.*) /list.php?$1 [L]
RewriteRule ^/$ http://www.bowlingboards.com/forum.php  [R,L]

It was that simple.  I am sure I am missing some other rules, and will try to get them corrected in due time.

 

Categories
Programmer's Mindset

PHP User Groups (Orlando and Daytona Beach)

I am a member of two PHP user groups.  Each one runs a little bit differently.  I am looking for feedback from other people in other PHP user groups to find ways we may be able to make these better.

The East Central Florida PHP User Group (Daytona Beach area) is new/restarting.  They have only had one meeting so far, and finally scheduled another a few months later.  They seem to be more geared towards teaching new PHP developers.  While we haven’t done anything so far, they are leaning towards a mentor/student type of group.

The Orlando PHP User Group is quite different.  They lean towards more presentation style meetings.  Someone proposes a topic, and then someone volunteers to be the presenter.  If there isn’t a presentation, then they do some coding in DjangoDojo.  I have not been to a meeting without a topic yet, so I am not sure how those go.  I probably should since I am not very familiar with Django (or Dojo for that matter) at all.

Of the two, I prefer the Orlando version because I am growing my skills.  However, I may like the mentor version because I feel I am a decent programmer and love teaching.

I am looking forward to doing a presentation sometime, because I really want to improve my speaking skills.

How does your user group run?  What is your preference?

Categories
Programmer's Mindset

APC Configuration Hell

Note to self: Know where your configuration files are.

I have been fighting an APC out of memory/100% fragmentation nightmare.  I kept tweeking settings in /etc/php.ini and nothing seemed to be fixing the problem.  Sure, gracefully restarting Apache will appear to fix the issue at the moment, but then it returned.

I started looking at the Runtime settings in apc.php and realized that nothing I had set really changed anything.  Turns out, apc by default put its config in /etc/php.d/apc.ini.  Sure, I would set them in php.ini and then they were overwritten in apc.ini.  ARGH!!!!

Found and fixed… YAY!

Categories
Programmer's Mindset

I Need PHP Advice From The Community, #tekx

I will try to keep this short.

My Background:
I have been programming for 20 years (12 professionally).  Grew up on BASIC and PASCAL.  And first job was in the old school Q&A database.  Needless to say, I started out very procedural.  My first web programming started in 1999 with PERL.  And I have always had the attitude of I will make it work and work quickly.

Advice Needed:
I took over a project 6 years ago.  It started with no pay, just a percentage of profits at the end of the year.  I took what they already had, and extended it to be able to sell more.  I year after that I was hired full time and have just been adding on top of the mess since then.  Spaghetti code, procedural, unused database tables, unused database fields, it’s just a mess.  I know OOP, but haven’t had the aha experience until a couple of years ago.  I used objects here and there, but ultimately not in good form.  

I went to TEKX to improve my skills.  I have been looking into Zend Framework, CakePHP, and others for about a year, and have decided to go with Zend Framework and Doctrine.  So I am going to rewrite my entire codebase.  Here is where I need advice.  I’m at a fork in the road.

I can either keep my bad database structure and work with it, or start from scratch and migrate the old data into the new database layout.

Pros for keeping the DB structure:
I can build parts of the site in ZF and get the code live quicker, letting the old codebase continue to run and eventually die out on its own.

Cons for keeping the DB structure/Pros for rewriting the DB structure:
The old DB is a mess.  A new DB structure will probably improve speed and data accuracy.

Cons for rewriting the DB:
I will have to rewrite the entire codebase before it can go live.  Everything will need to be rewritten and tested.  A data migration script will need to be written.  And a date will need to be set for new code to go live.

Any advice would be greatly appreciated.