Archive for the ‘work related’ Category
26
Aug
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 »
09
Aug
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 »
11
Jul
After an hour long reading his frustrations over IM, I began google’ing on files served thru PHP but locks clicks in a client’s browser until download is finished. It is unresponsive until the download is complete.
// add this function before a readfile() or chunked with fopen() session_write_close(); // header goes here, content-type, filename, etc readfile($filepath);
And, also, I found this class to support downloading using a download manager.
Posted in job, me stuff, work related | No Comments »
02
Jul
If you follow install procedures of Firefox 3.5 on Ubuntu, it will setup a new Mozilla browser instance named Shriketo “Shiretoko”, and in your main menu will appear as “Minefield”.
I had it installed, but removed it. I’ll wait for final release in default apt sourcelist. Also removed entries there I added using the tutorials. Why? Not much of a reason, I just prefer Firefox in the title bar. I’d like it even better if they change letter “e” in place of the globe there
Posted in me stuff, work related | No Comments »
22
Jun
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 »
19
Jun
Hacking in or modifying Blueprint CSS to match your design is easy! You will notice that the original .box class had the light blue color, but here it isn’t.
What I did is added this code below to make .box background color as grey.
.entry .box { background-color: #fdfdfd !important; color: #696969 !important; border: 1px solid #dedede; } .entry .box a { color: #363636 !important; text-decoration: none; } .entry .box a:hover { text-decoration: underline; }
Tags: blueprint, css
Posted in me stuff, work related | No Comments »
18
Jun
Simple way to remove Google watermark in search text box.
$(document).ready(function() { $("#cse-search-box input[name=q]").css("background-color", "#fff"); });
You need to include jQuery package first, of course.
Tags: jquery, quicky
Posted in me stuff, work related | No Comments »
11
Jun
What choice? Between what/who?
I wish I can tell. But not the right place. Though its basically about my career.
Posted in me stuff, work related | 1 Comment »
10
Jun
So far, I’ve been happy how this template behaves when I pass a parent/child links into it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | < {$parent_tag|default:'ul'}{if $menu_id} id="{$menu_id}"{/if}{if $parent_class} class="{$parent_class}"{/if}>{* ul tag opens here *} {foreach from=$links item=link} {if $link.class_active && $link.href == $current_uri} {if $link.class} {assign var=class value="`$link.class` `$link.class_active`"} {else} {assign var=class value="`$link.class_active`"} {/if} {else} {assign var=class value="`$link.class`"} {/if} < {$child_tag|default:'li'}{if $class} class="{$class}"{/if}{if $link.id} id="link_{$link.id}"{/if}> <a href="{$link.href}"{if $link.target} target="{$link.target}"{/if}>{$link.text}</a> {if $link.children} {include file="links.html" links=$link.children parent_class=""} {/if} {/foreach} < /{$parent_tag|default:'ul'}> |
Does something like this when rendered
<ul class="sf-menu"> <li><a href="http://www.swerteka.com/index.php">Home</a></li> <li><a href="http://www.swerteka.com/PostItem">Post Item</a></li> <li><a href="http://www.swerteka.com">Blog</a> <ul> <li><a href="http://www.swerteka.com/BlogComments/do/viewrecent">Comments</a></li> </ul> </li> <li><a href="http://www.swerteka.com/Content/name/about">About</a> <ul> <li><a href="http://www.swerteka.com/Content/name/contact">Contact Us</a></li> </ul> </li> </ul>
Tags: OOP, smarty
Posted in job, me stuff, work related | No Comments »



