Recent Updates RSS Toggle Comment Threads | Keyboard Shortcuts

John Congdon 4:23 pm on February 14, 2012 Permalink | Reply
Tags: git ( 5 ), PHP ( 20 )   

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);

 

Reply Cancel reply

Required fields are marked *

*

Loading...

John Congdon 11:03 am on February 14, 2012 Permalink | Reply
Tags: git ( 5 ), PHP ( 20 )   

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

 

John Congdon 11:12 am on February 9, 2012 Permalink | Reply
Tags: phpUnderControl   

phpUnderControl javascript fix for Internet Explorer 

There are two errors in the phpUnderControl javascript that causes IE to work like the other browsers.

Basically, you may not be aware that the “home screen” auto updates in other browsers. I kept refreshing like a madman until I opened it in another browser and saw it happen automatically. Then I dug in and fixed it.

Here is the patch:
[code]
@@ -16,7 +16,7 @@
if(d != null) {
el.setStyle( {
'height': d.getAttribute('height') + 'px',
- 'width': d.getAttribute('width') + 'px',
+ 'width': d.getAttribute('width') + 'px'
} );
}
delete d;
@@ -26,7 +26,7 @@
var d = el.contentWindow.document.body.scrollHeight;
if(d != null && d > 20) {
el.setStyle( {
- 'height': (d + 50) + 'px',
+ 'height': (d + 50) + 'px'
} );
}
else {
[/code]

 

John Congdon 9:26 am on January 4, 2012 Permalink | Reply  

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.

 

 

John Congdon 3:09 pm on November 28, 2011 Permalink | Reply
Tags: Javascript ( 6 ), Open Source ( 3 )   

Just had my first GitHub pull request put into a project. Happy to contribute, even in small ways.

https://github.com/EmilStenstrom/jQuery-animate_from_to

 

John Congdon 3:12 pm on October 19, 2011 Permalink | Reply
Tags: jQuery Mobile   

jQuery Mobile Select Box Not Showing Up 

jQuery Mobile is a great framework with lots of great out-of-the-box magic.

I am in the middle of converting a site over from a full website to a mobile version. I was really frustrated when I tried to click on a select box and nothing would happen. If my header/footer were fixed, they would just toggle on and off. I assumed it was the fixed positioning, and I was wrong.

Through some FireBug debugging, I found the problem. It probably won’t affect many people, but it’s worth pointing out. I had a set a width through CSS on the select item for the desktop version. When I ported into the mobile version, I left the CSS width in there. So if I happened to click on the very far left of the button, it worked.

I removed the width and all is right in the world again. :)

 

John Congdon 1:12 pm on October 18, 2011 Permalink | Reply
Tags: ab, linux   

Running Apache Benchmark (ab) and receiving apr_socket_recv: Connection reset by peer (54) 

I was having this issue and was getting quite frustrated. All of my researched turned up nothing. Finally I decided to run this from another machine instead of my Mac, and it worked just fine. So this had nothing to do with my server, it was a client side related issue.

I still don’t know what caused it. I was just able to identify the issue and thus find a work around.

 

John Congdon 10:09 am on October 14, 2011 Permalink | Reply
Tags: +1, Google   

Google +1 Button Shows Zero (0) Count When Not Logged Into Google Account 

I had a situation that my boss pointed out yesterday that was very confusing.

He was on a competitor’s website and their +1 button was showing a count. However, the same product on our website was showing 0. I knew that I had +1′d it.

So I go to my machine and I see (3) +1′s. I logout of Google and sure enough the 3 went away. ?!?!?!?

I was so confused that I went as far as copying the +1 code from the competitor’s site and theirs showed a number and ours still did not until I logged in. My mind was boggled.

Next step: ask another person in the office to create a Google Profile and +1 our product. Bringing our +1′s up to 4. There you have it, it showed whether I was logged in or out of Google.

I hope this save someone else time from searching hours for an answer. It was ridiculously confusing. Why is 4 the magic number?

 

John Congdon 11:55 am on September 30, 2011 Permalink | Reply
Tags: PHP ( 20 )   

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. :(

 

John Congdon 8:17 am on September 30, 2011 Permalink | Reply
Tags: Javascript ( 6 )   

Lazy Loading Images with JQuery 

I am trying to speed up a website every way that I can. I decided to look into lazy loading which I have read about numerous times.

Lazy loading is basically not wasting time loading images that are off the screen, or out of the viewport.

This got me thinking, why do the browsers not do this for us? They would be better equipped to handle this than a JS developer. Especially since the browser is doing the rendering, it knows what it needs in order to display the screen.

 
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser