Archive for the ‘web’ Category
PHP 5.3.0 (cli) (built: Jun 30 2009 13:24:04)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
Yes, it has arrived.
Today is a big day for open source software. Lets look at some notable releases:
This is one of those days where I realize more and more that open source software (and notably the PHP community) is thriving and I love it!
Tags: open source, pecl
I write this in honor of the Firefox web browser. I still remember when it was first released November 9th, 2004, and gave me hope for a better, nicer, non-IE world. Today, Firefox 3.5 is released. Building upon nearly 5 years of success, they have continued innovating and I thank them for making the web a better place.
Feel free to Skip to the demo.
I previously wrote about using IP based Geolocation. Although this method is widely used, the downsides are obvious: inaccurate results, proxies, false positives, and a lack of privacy control for the end user.
The Future of Geolocation
The new generation of browsers are implementing the Geolocation API specification. This gives the browser the job of figuring out where you are. There are some positive points and negative points to this. Firstly, the position of the user can be more accurate. In IP-based Geolocation, the only data available is the IP address. The browser has access to much more precise data such as WiFi networks and GPS devices (iPhone!). Secondly, privacy settings. The browser should be able to ask the user if they will allow such information to be shared, ideally even the level of accuracy that should be shown. This is possible if implemented in the browser. One negative point is something we are all familiar with: cross-browser compatibility. Different implementations in different web browser will make developers miserable, but hey, that’s what standards are for, right?
Browser Support
As of today a few web browsers support geolocation. Here’s the status of the mainstream browsers:
- Firefox: Available in version 3.5, released today.
- iPhone Safari: Available in OS3.
- IE: Experimental in version 8.
- Opera: Available in nightly builds since March 2009.
- Chrome: Available through Google Gears API
- Safari: Unknown.
Here is how to request a users location (see line 26 for the goods):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| function knownLocation(position) {
var latitude, longitude;
if (position.coords) { // iPhone
latitude = position.coords.latitude;
longitude = position.coords.longitude;
} else { // Firefox
latitude = position.latitude;
longitude = position.longitude;
}
var div = document.getElementById('geo');
div.innerHTML = div.innerHTML + "Latitude: " + latitude + "<br/>Longitude: " + longitude;
}
function unknownLocation() {
var div = document.getElementById('geo');
div.innerHTML = div.innerHTML + "Unknown Location";
}
window.onload = function() {
var div = document.getElementById('geo');
div.innerHTML = div.innerHTML + "Browser: " + navigator.appName + " (" + navigator.appVersion + ")<br/>";
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(knownLocation, unknownLocation);
} else {
div.innerHTML = div.innerHTML + "Browser not supported";
}
}; |
This then prompts the user for their approval:

Similarly, on the iPhone:

Conclusion
This is really cool. With geolocation implemented in the browser, great precision can be achieved. For example, on the iPhone the GPS is used, so visiting the demo page from my living room gives different coordinates than when visiting from my kitchen. I can imagine many useful applications of this. Another thing I love is that I can deny my location to certain sites, which I will absolutely use on certain sites.
Tags: firefox, geolocation, iphone, javascript
I just saw this post on friendfeed:
“I love Drupal and Joomla, but it’s too bad they’re written in PHP… which is kind of an antique compared to newer stuff like Ruby on Rails… the next generation of cool CMS platforms will probably be running something like Rails, not PHP.”
Normally I would disregard this kind of ignorance but the fact that some people were agreeing with him pissed me off
I began working feverishly on preparing a response to this “media guy”, arming myself mostly with Terry Chay blog posts. In the end I cooled off and decided to write a quick blog post about it.
I won’t defend PHP, as there is plenty of evidence on the web that can do this for me. I just think we should be skeptical when “cool”, “antique”, and “next-generation” are used in the same sentence by social media junkies.
Tags: php, ror
In short, because it is the ideal format for most situations.
This webcomic summarizes the views of many developers when comes the question of what image formats to use on the web.
For those who don’t get the joke, JPEG is a lossy format, meaning that each time the file is edited there is a degradation in quality. That’s why the JPEG side of the comic contains visual artifacts.
JPEG’s popularity is helped by the fact that it is the default image file format of most digital cameras, making it the most common image format on the web.
I love JPEG’s too, but I understand that they are not the solution to every problem. In general I believe its a simple solution to determine which format to use.
- If your image has many colors (such as pictures) I recommend using JPEG.
- If small file size is important or your image has less colors (like icons, buttons) I recommending trying PNG8, which produces a 256 color PNG. As points out Stoyan Stefanov, the human eye has difficulty telling the difference between 200 and 1000 colors. If it looks good then go for it.
I recently setup a command line solution for converting and compressing images from JPEG to PNG8 using ImageMagick and PNGCrush.
1 2
| convert ~/jpgs/file.jpg PNG8:~/pngs/file.png
pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB ~/pngs/file.png ~/crushed/file.png |
By also stripping out the color correction I was able to reduce the size on average by 50% for 290×290 image sizes without any visible loss of quality. This can give a real front-end performance boost on web pages that contain many images.
Tags: imagemagick, png vs jpeg, pngcrush
Maybe, but for now forget about it.
Today some servers in California were shutdown for spam related activities effectively dropping the amount of spam sent by roughly 66%. Wow! 2/3 of the worlds spam eliminated in one swift blow.
Unfortunately for us, this is but a mild setback for spammers. They will regroup and find a new home to host their activities.
It is still unsure if the hosting provider, McColo Corporation, will even be held legally responsible even though they are known as being friends of the bad guys, specifically with their involvement in botnets.
A study recently showed that 1 out of 12.5 million spam emails were responded to. This corresponds to 8×10^-8% response rate. Not worth it for spammers you think? The study estimates that this corresponds to revenue of 7,000$ per day. Its fair to say the quantity comes before quality.
There seems to be money to make and until this is no longer true spam will stay with us.
For some reason or another this news reminded me of a great Woody Allen quote from Annie Hall:
[In California]
Annie Hall: It’s so clean out here.
Alvy Singer: That’s because they don’t throw their garbage away, they turn it into television shows.
Tags: botnet, spam