I realize the need for this when working on an MVC based CMS especially with Smarty engine in it.
Oh and in case you’re wondering why its sounds like the upcoming movie Avatar by James Cameron, I don’t know. What it has to do with internet term ‘avatar‘? I really don’t know. But in ‘www’, Gravatar is a short term for “Globally Recognized Avatar” assigned by a user as his/her default avatar in every places of the internet, same people behind WordPress. There are other similar services too.
So, this plugin is based from its documentation
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| /**
* Gravatar
*
* @link http://www.marvinmarcelo.com
*
* @param array $params
* @param Smarty $smarty
*/
function smarty_function_gravatar($params, &$smarty)
{
/**
* constant $gravatar_host
*/
$gravatar_host = "http://www.gravatar.com/avatar/";
if ( !isset($params['email']) )
{
$smarty->trigger_error("gravatar: email parameter not set");
return;
}
if ( !eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $params['email']) )
{
$smarty->trigger_error("gravatar: {$params['email']} is not a valid email.");
return;
}
/**
* @link http://en.gravatar.com/site/implement/url
*/
$hash = strtolower(md5(trim($params["email"])));
$src = $gravatar_host . $hash . ".jpg?";
if ( !isset($params["size"]) || !($params["size"] >= 1 && $params["size"] < =512 ))
{
$params["size"] = 32;
}
$src .= "s={$params["size"]}";
if ( !isset($params["default"]) )
{
$params["default"] = "identicon";
}
$src .= "d={$params["default"]}";
if ( !isset($params["rating"]) )
{
$params["rating"] = "G";
}
$src .= "r={$params["rating"]}";
$extras = "";
if ( isset($params["class"]) )
{
$extras .= " class=\"{$params["class"]}\"";
}
if ( isset($params["id"]) )
{
$extras .= " id=\"{$params["id"]}\"";
}
/**
* @example http://www.gravatar.com/avatar/7023218434f12aee57f4b03454dadcaa?s=32&d=identicon&r=G
*/
print "<img src=\"$src\" alt=\"{$params["alt"]}\"$extras />";
} |
Simply extract function.gravatar.zip into your Smarty plugin directory. And use it in your template file like this
{gravatar email='someemail@domain.com'}
You’re done!
Tags: gravatar, smarty, template
Posted in job, me stuff, productivity, work related | No Comments »
Hello, finally! The next version of Facebook for iPhone has been submitted for review, TechCrunch spills
List of what to expect is here
- The “new” News Feed
- Like
- Events (including the ability to RSVP)
- Notes
- Pages
- Create new photo albums
- Upload photos to any album
- Zoom into photos
- Easier photo tagging
- Profile Pictures albums
- A new home screen for easy access to all your stuff, search, and notifications
- Add your favorite profiles and pages to the home screen
- Better Notifications (they link to the comments so you can reply)
- Quickly call or text people right from the Friends page
- Messages you are typing will be restored if you quit or are interrupted by a phone call
Now that’s good news!
Tags: facebook, iphone
Posted in me stuff, productivity | No Comments »
This is REAL work! They do not only trace bugs, but also annoyances, which is a big factor in UI experience.
WordPress 2.8.4: Security Release
Posted August 12, 2009 by Matt. Filed under Releases, Security.
Yesterday a vulnerability was discovered: a specially crafted URL could be requested that would allow an attacker to bypass a security check to verify a user requested a password reset. As a result, the first account without a key in the database (usually the admin account) would have its password reset and a new password would be emailed to the account owner. This doesn’t allow remote access, but it is very annoying.
We fixed this problem last night and have been testing the fixes and looking for other problems since then. Version 2.8.4 which fixes all known problems is now available for download and is highly recommended for all users of WordPress.
Source: http://wordpress.org/development/2009/08/2-8-4-security-release/
Tags: word, wordpress
Posted in me stuff, productivity | No Comments »
jCryption, is simply Javascript Encryption. “j” stands for jQuery as core framework. And as always, everybody likes jQuery.
Normally if you submit a form and you don’t use SSL, your data will be sent in plain text.
But SSL is neither supported by every webhost nor it’s easy to install/apply sometimes.
So I created this plug-in in order that you are able to encrypt your data fast and simple.
jCryption uses the public-key algorithm of RSA for the encryption.
Author’s site had a good documentation on usage.
Tags: javascript, jquery, security
Posted in me stuff, productivity, work related | No Comments »
Ohoh, I am a Globe subscriber, but had to admit, internet connection speed on my iPhone got beaten by a Samsung i450 on a Smart line
Globe iPhone

Smart Samsung i450

Tags: internet, iphone
Posted in me stuff, productivity | No Comments »
I just got the title from the source, read it yourself
This options worked for me! I’ve been having trouble trying tidy on my CMS. But it only renders tidy’ed the content inside <body> and worst, everything outside it are stripped off – no title, and meta’s neither opening and closing html
$config = array(
'indent' => true,
'output-xml' => true,
'input-xml' => true,
'wrap' => '1000'
);
For detailed options and their uses, look at their quickref
Tags: smarty, tidy, xhtml
Posted in me stuff, productivity | 1 Comment »
Just dropping quickly here, and wanting to share a little and yet important part of software development, in web or in any platform.
I believe it is always nice to have a property in your object (or class) to hold the latest error encountered or latest command executed. Sort of like this
class test1
{
var $last_error;
var $last_cmd;
// some other properties here
function test1()
{
// other codes here
}
/**
* the "why" for this class
*/
function execute()
{
$command = $this->get_command();
$this->last_cmd = $command;
system($command, $res);
if ($res)
{
$this->last_error = $res;
return false;
}
return true;
}
}
I realize the need for these two properties when I was debugging the CMS I was working on. It involved GraphicsMagick to process resizing, cropping and sharpening image, and executed thru PHP exec or system functions. I forgot why I arrived at using exec over the other. What I did was include these two properties in the log thru a logger method of another class in the system, which indeed, helped me get back to my sanity
.
Posted in me stuff, productivity, work related | No Comments »
update: scsa.msg.yahoo.com seems to work now. This is the default address in 2.5.8 for Ubuntu and Windows versions.
After a few search terms finding what’s going on recently with pidgin that it’s unable to connect to Yahoo. I found a correct temporary fix
using the page server: cn.scs.msg.yahoo.com instead of scs.msg.yahoo.com did the trick.
Tags: pidgin, ubuntu, yahoo
Posted in me stuff, productivity | 10 Comments »
Update only columns that has changed.
Its tedious to compare old column values against the new being submitted before adding the column in the query statement. But, most of the articles I read says its the most efficient.
+---------------+--------------------------+-----------------+
| username | email | lastip |
+---------------+--------------------------+-----------------+
| admin | admin@google.com.ph | 127.0.0.1 |
+---------------+--------------------------+-----------------+
In this example, current $row["email"] is compared to request $email value
/* repeat this test in every column in your table */
if ($row["email"] != $email)
{
$columns[] = "email = '$email'";
}
/* constructed sql statement would be */
$sql = "update customer set email = '$email' where username = 'admin'";
Another advantage following this convention is when there are multiple users accessing the same row. Though it sounds impossible that same row is updated at an exact same time, unless your site tops google on ranking. And even so, your SQL operation would have saved a little less resource than usual.
Posted in me stuff, productivity, work related | No Comments »
Ok, I think there’s more to Blueprint CSS than fixed width designs. Somebody already came up with the liquid version.
So I think I’d spend some time adapting this generator and pass the four parameters needed to calculate the grid.
<script src="/getblueprint.php?width=950&cols=24&colwidth=30&margin=10"></script>
or perhaps a mode parameter to set px or percent as values
<script src="/getblueprint.php?mode=px&width=950&cols=24&colwidth=30&margin=10"></script>
Tags: blueprint, css
Posted in me stuff, productivity, work related | 1 Comment »