OOP 101: No logic in template, as much as possible

If you have a repeating region in your template and it doesn’t need a wrapper around it, simply use section

{section name=s loop=$images}
{/section}

Cases where you need html wrap tags is like this

{if $navlinks}


{/if}

This avoids the <ul> being rendered if $navlinks don’t have a return record. Another way is to access Smarty properties

{section name=s loop=$navlinks}
   {if $smarty.section.s.first}


{/if}
{/section}

But still, this adds an if in the template. As this post title goes, you should avoid them, that’s the basics of OOP system and MVC frameworks, separate logic from code :D

What made me write this post? Template Designers sometimes hate seeing if statements. In my case, my boss transforms into savvy Designer as well, at times! Bummer

Tidy-up back to the kitchen

So much of those out-of-town posts! Back to my normal life, and to the kitchen! Did I say kitchen?!!! I’m blogging for …cooking (the life)? LOL! But how I wish I’m really “back-to-my-normal-life” which would mean, I really went off of it. Gone easy, to the beaches, relaxing, and stuff like that, but I didn’t :( , not much!

This kitchen I’m referring here is the back-end, of the CMS I’m working on, where stuff on the front-end – basically the HTML and the data within is being prepared. Been tidy from the start, indentions, and phpDoc blocks. I thought why not take this quality of code up to the front. What exactly I’m talking about?

Here. Don’t you wish when you look at the HTML source of your published page you have a well formatted document tree? That instead of this


It would have rendered like this


Neat! So, let’s go with the ingredients, I mean the tools/modules needed for this.

HTML Tidy
wiki: is a computer program and a library the purpose of which is to fix invalid HTML and to improve the layout and indent style of the resulting markup. Install instructions here. See that? It also fixes invalid HTML!

And, since I’m using Smarty, this line is called before the $smarty->display(); method.

// this way
$smarty->load_filter("output", "tidyrepairhtml");
// or
$smarty->register_outputfilter("tidyrepairhtml");

You got nice and neat HTML source! Which takes me to thinking, perhaps, someone had already written a WP plugin of tidy. Let me try google it. And yes, there’s available plugin.

WordPress Summer of Code 2009

Dad: Well, Billy, another school year is coming to a close. No more college parties, just another summer here at home. What will you do all day?

Billy: Oh, I dunno. I’ll probably work on my blog or something.

Dad: You need more direction! That blog is just your generation’s answer to comic books.

Billy: On the contrary, Dad, working on my blog utilizes my skills in programming, design, writing, critical thinking, and all sorts of other liberal artsy things that you’re paying those professors to teach me.

Dad: If only there were a more practical application for those skills, one that could lead you to fame and fortune!

Billy: Where’ve you been living, Dad? My skills are totally in demand in today’s questionable economy. An awesome WordPress developer is worth his/her weight in gold. Lead, even.

Dad: What is this WordPress?

Billy: Only the greatest open source publishing platform ever created. It’s what runs my blog. I like to fiddle around with the code and come up with cool hacks that make mine better than the average College Joe’s.

Dad: I had no idea you were that capable.

Billy: Duh, Dad. I’ve been using WordPress for a couple of years now. I could practically teach a course on it, though there are definitely things I could learn from the lead devs. They are like kings.

Dad: Hm. That kind of ability ought to be worth something. Seems like there would be programs in place for kids like you to utilize your skills while being nurtured by people like these lead kings.

Billy: Lead devs, Dad. Not lead kings.

Dad: Maybe you could apply for an internship or something, earn a little money this summer instead of just spending mine.

Billy: Well, there is this one thing like that.

Dad perks up.

Billy: The Google Summer of Code lets college students work with lead developers on a bunch of open source projects, you can get college credit for it, and if you do a good job, you can earn up to forty-five hundred bucks over the summer. And WordPress is one of the participating projects.

Dad: !!

Billy: But it’s pretty competitive. My friend Joe applied last year and didn’t make the cut. I can improve my skills just by fiddling around on my own this summer without the rejection, thanks.

Dad: Don’t be lame! You said yourself you’re awesome. And that you could learn from the kings. And that you could earn over FOUR THOUSAND DOLLARS. Life is full of rejection, kid. Best way to get over that is to make yourself so awesome that no one wants to reject you. And know that even if they do reject you, there’s always next time.

Billy: I dunno, Dad.

Dad: Tell you what, if you apply, I’ll give you $500 toward that car you’ve been wanting, whether you’re accepted into the program or not. And if you get in and complete it successfully, I’ll match that $4500. I’d be so proud of you. And the bragging rights at work! My kid, a Google engineer!

Billy: I wouldn’t actually be a Google engineer, Dad.

Dad: Oh be quiet. Do you think Harold in shipping knows the difference?

Billy: Okay, Dad, I’ll do it!

Dad: That’s my boy.

Source

Last-minute Conficker survival guide

Tomorrow — April 1 — is D-Day for Conficker, as whatever nasty payload it’s packing is currently set to activate. What happens come midnight is a mystery: Will it turn the millions of infected computers into spam-sending zombie robots? Or will it start capturing everything you type — passwords, credit card numbers, etc. — and send that information back to its masters?

No one knows, but we’ll probably find out soon.

Or not. As Slate notes, Conficker is scheduled to go “live” on April 1, but whoever’s controlling it could choose not to wreak havoc but instead do absolutely nothing, waiting for a time when there’s less heat. They can do this because the way Conficker is designed is extremely clever: Rather than containing a list of specific, static instructions, Conficker reaches out to the web to receive updated marching orders via a huge list of websites it creates. Conficker.C — the latest bad boy — will start checking 50,000 different semi-randomly-generated sites a day looking for instructions, so there’s no way to shut down all of them. If just one of those sites goes live with legitimate instructions, Conficker keeps on trucking.

Conficker’s a nasty little worm that takes serious efforts to bypass your security defenses, but you aren’t without some tools in your arsenal to protect yourself.

Your first step should be the tools you already have: Windows Update, to make sure your computer is fully patched, and your current antivirus software, to make sure anything that slips through the cracks is caught.

But if Conficker’s already on your machine, it may bypass certain subsystems and updating Windows and your antivirus at this point may not work. If you are worried about anything being amiss — try booting into Safe Mode, which Conficker prevents, to check — you should run a specialized tool to get rid of Conficker.

Microsoft offers a web-based scanner (note that some users have reported it crashed their machines; I had no trouble with it), so you might try one of these downloadable options instead: Symantec’s Conficker (aka Downadup) tool, Trend Micro’s Cleanup Engine, or Malwarebytes. Conficker may prevent your machine from accessing any of these websites, so you may have to download these tools from a known non-infected computer if you need them. Follow the instructions given on each site to run them successfully. (Also note: None of these tools should harm your computer if you don’t have Conficker.)

As a final safety note, all users — whether they’re worried about an infection or know for sure they’re clean — are also wise to make a full data backup today.

What won’t work? Turning your PC off tonight and back on on April 2 will not protect you from the worm (sorry to the dozens of people who wrote me asking if this would do the trick). Temporarily disconnecting your computer from the web won’t help if the malware is already on your machine — it will simply activate once you connect again. Changing the date on your PC will likely have no helpful effect, either. And yes, Macs are immune this time out. Follow the above instructions to detect and remove the worm.

Source: http://tech.yahoo.com/blogs/null/132464

iPhone VNC Remote Desktop over 3G

I just had a chance to access my home PC using VNC over 3G. I was able to play with it only on local network before.

photo

[ad#ad-5]

photo2

What you need… on your ubuntu machine

  • Remote Desktop (vino)
  • System > Preferences > Remote Desktop. Check “Allow other users to view your desktop”. And best if you set a password and uncheck “Ask for confirmation”.

On your iphone…

  • Mocha VNC Lite http://mochasoft.dk/iphone_vnc.htm
  • Add your connection preferences.