[Super Tip!] How to loop or iterate over an object’s key/value pair.

| No Comments »

Problem: Help! Is it possible to loop or iterate through each object’s key/value pair like an array? Answer: A very useful trick for iterating over objects is the use of (for x in object), with this you can completely use objects as array!

myObject = {
“this” : “value1”,
“is” : “value2”,
“awesome” : “value3”

for (x in myObject)
alert(‘key : ‘ + x + ‘ / value : ‘ + myObject[x]);

[Solution] How to use this in setInterval and setTimeout problems inside objects

| No Comments »

Problem: One of the problems we find when using setInterval and setTimeout functions in javascript is how the special variable this is switched to the window object on the instance the function executes inside the interval.

Answer: Store the current object in a variable (for this example, the variable is called self) and use that variable for your interval’s function instead of this.

function foo()
this.init = function () {
var self = this;
this.interval = setInterval(function(){ self.update(); }, 1000); // this can be setTimeout

this.update = function () {

Json Example

How to login as root or how to fix the permission problems when running su commands in WHM

| No Comments »

You can’t use the root user when SSH’ing to WHM but what you can do is issue a SU command once you’ve logged in with another user which isn’t root. On some occassions, you may encounter a no permission error when doing this.

Problem: Help! I can’t seem to login as root in whm so I need to do a SU command instead but i’m getting a permission error!

Answer: In your whm panel, access Security Center -> Manage Wheel Group Users and you will be able to assign the username to the group that allows SU

And that’s the solution to your problem!

How to find, look or search for a specific file in linux

| No Comments »

A common problem for those aren’t aware of using linux are locating certain files(this is when troubleshooting, or simply doing steps from a guide)

Problem: I’m looking for a file in linux! How do I find this?

Answer: You can easily find a file by using the find command:

find / -name “httpd.conf” -print

Note: the -print option will print out the location of the name, / represents what location to start.

If you are interested in knowing more about the find command, look no further than the following link: http://www.ling.ohio-state.edu/~kyoon/tts/unix-help/unix-find-command-examples.htm

Solution for Headers Already Sent problem in php scripts and frameworks

| No Comments »

Headers already sent issue?

Here’s how to fix one of the most common problems in frameworks and websites:

Problem: Help! i’m getting the errors and/or warnings – “Headers already sent!

Answer #1: Check the php files which are usually found in your headers(the ones which are loaded first, typically config.php) and look for extra spaces before your <?php start tag and spaces after ?> end tag. Delete them and voila! Problem Solved!

Answer #2: Check your header scripts(The first few lines of code) and make sure you’re not outputting anything(e.g: an echo, sprintf or a warning message) before using header.

mySQL: Simplify your multiple WHERE queries with WHERE in

| No Comments »

_Problem #1_: How do I simplify my mySql where queries? _Problem #2_: How can I search through an array in my where statement?

Answer: An awesome trick when it comes to querying multiple where clauses is to use the WHERE <…> IN command.

$id = ‘1,4,3,6,8,2’; “SELECT * FROM <…> WHERE id IN ($id)”

Oh and did I mention you can prepend the NOT statement to show results which is NOT included in the list?

$id = ‘5,7’; “SELECT * FROM <…> WHERE id NOT IN ($id)”


Jquery Super Tip! Automatically highlight the links/menu of the current page with 1 line of code


One very important usability feature of a website is to have the menu or links highlight the current page the visitor is currently in. Here’s a trick I do with jquery to do just about that. For educational purposes, i’ve split it to 3 lines of code to make it more understandable.

Simply add the following to your header (don’t forget to include jquery first!).

$(document).ready(function()   {     var loc = window.location.toString().split("/")     loc = loc[loc.length – 1]     $("#navigation li a[href=\""+loc+"\"]").addClass("selected");   });

Of course, jquery isn’t really needed to do this. If you prefer to have it done _without_ jquery, here’s a native way of doing things:

   window.onload = function()    {      var current_page = window.location.toString().split("/")[window.location.toString().split("/").length – 1]      var links = document.getElementsByTagName("a");      for (x in links)      {        var link = (links[x].href != undefined) ? links[x].href.toString().split("/")[links[x].href.toString().split("/").length – 1] : ""        if (link == current_page)          links[x].className = (links[x].className == "") ? "selected" : links[x].className + " selected"      }    }

_Important_: The above code takes use of the .selected class. Simply add the class to your a:hover classes.

#navigation ul li a:hover { color: #ff0; }

Should be written as:

#navigation ul li a:hover, #navigation ul li a.selected { color: #ff0 !important; }

_Don’t Forget!_, this works for menu/links with background images as well.

and that’s all there is to it! Don’t forget to thumb this up and share!

How to Fix: I’m unable or can’t copy, move or delete files in MAC because of insufficient privileges or permissions

| No Comments »

Problem: My Mac OSX is complaining that the files im about to copy or move doesn’t have sufficient privileges or permissions!

Solution: Simply use the CHMOD trick here to recursively set all your files and directories permissions. After these are set, you will now be able to copy, move or delete these files.

You need to have administrative privileges for the following to work.

1. Open Terminal by typing Terminal in your spotlight(click the magnifying glass on the top right or press CMD+Spacebar on your keyboard). You can also open terminal from your Applications folder. 2. Type cd <Type the directory you want to give yourself permissions to here...>  3. Type the following commands(enter your password when it asks): sudo find . -type d -exec chmod 755 {} \; sudo find . -type f -exec chmod 644 {} \;

That’s it! You can now backup, copy, move or delete these files.

Unix Super Tip: Easy Access to your files and directories by creating symbolic links(shortcuts)

| No Comments »

The directory structure of Mac and Linux(both are UNIX) tends to get really _really_ long. But don’t worry, by using the ln -s, or Symbolic Link command in the terminal(unix shell), creating “shortcuts” to your folders or files is now a breeze.

ln -s   Here’s an example: ln -s /Library/Python/2.5/ /shortcuts/PYTHON  

The effect: cd /shortcuts/PYTHON is now the same as cd /Library/Python/2.5/, removing a shortcut is similar to removing a file: rm /shortcuts/PYTHONthat’s it!

How to: A beginner’s expert guide on blogging your way to the top.

| No Comments »
After writing my 6th post, i’ve decided that i’m now an expert blogger. This is a beginner’s expert guide on blogging your way to the top.

Hey, look. Isn’t that a great idea of yours that have just passed through? Ideas flashes in an instant so it’s only natural that you could forget it just as fast – this is always a bad thing because that idea that you let passed through you? That could’ve been “the” post that could’ve made you an instant hit.

Drafting your ideas should be your #1 priority. This writing as of now is an idea that suddenly popped out of nowhere while writing a blog about a game. Ideas usually comes up in the weirdest times(and places) so make sure you’re always ready for it. Whenever that happens, I stop whatever I’m doing, fire up my notepad and start writing right away. One idea leads to another so don’t break it up by letting any of those ideas pass through. So draft, save and continue editing it in a later date. Before you know it, that little idea of yours has already become a very interesting blog on it’s own. This is one of the key to having many things to blog about in the future.

Chop ’em down Sometimes even a well written post can be very exhausting when it’s too long. Break your posts down by sections or find a way to split some parts into an entire different post if its possible.

It’s all about quality of the content… How you write your content is very important. If you get a lot of visitor hits or traffic but your content is mediocre then it won’t matter, you are just turning them off and making them vow not to visit anything related to your website again, so take some time, grabe a coffee and polish your content. Getting visitors is one thing but keeping them is another.

… and the blog title How do you invite a visitor to read your content? That’s the job of your blog title, it’s the door that seperates the visitors from the blog itself. Placing a very uninteresting title is like putting a "Do not disturb" sign so make your title really stand out, read it over a couple of times and think: "If im a regular reader, will I find this title interesting?".

Nothing personal, you’re just becoming too personal. Hey let’s face it, unless all visitors are friends and relatives, personal blogs about ourselves is just plain too uninteresting. I won’t be getting as much hits as I have now if my blogs is all about what I’ve done during my vacation, what I got for my birthday or whatever, no one cares. But don’t let me get you too worked up here, personal blogging is a-ok! just avoid having too many, unless you can make them very interesting. If personal blogging is more of your thing then you might want to try twitting instead.

Reach a wider audience by sticking to a certain theme and creating an online persona. Setting a certain category or theme to your blog will put some interests into your links and post. A reader from google who found you through a keyword for Technology might not be interested to click your recent posts about cultures or cooking, stick to a few themes and all your posts will now be related to each other, which your readers might find interesting. A wider audience is good but if you become too diverse, you will lose more readers than usual. If you prefer to blog about anything, then a very good way of attracting your users is through an online persona(build your own character, create a style of writing, cosplay, act) and carry it throughout your posts. Chances are, people will subscribe to you because they find how you write very interesting or entertaining.

Do something special or unique. What makes your blog super-special? Exclusive contents of course! Contents that you can’t find anywhere but yours. Do something very original! did you a create a cool application? are you a beta tester of an upcoming hyped up game? Did you discover the meaning of life? or perhaps you made an awesome video? then blog about it.

Get your name out there. Explore, Connect. Be part of communities, participate in forums. Post a smart or helpful comment in other people’s blogs. Help people in IRCs. Join social networking websites. Getting your name out there by participating and being part of a large community is sure fire way of getting good traffic.

Share anything useful. Have you finally found the solution to a problem that’s been plaguing you for quite some time now? If you had this problem then chances are, someone else is having the same problem as yours right? Make things easier for other troubled users by blogging about it.

Motivate yourself. Getting addicted to blogging, or writing content is of course, the most important part to blogging. Installing WordPress Stats, Google Analytics, Woopra, CrazyEgg or myBlogLog to keep track of your visitors Sources(where they come from), Unique Visitors and what search keywords they used to get to your site is a great way of motivating yourself.

People are People. They have other important things to attend to as well. I respect my readers and their valuable time – that’s why I always have something in the start of my post detailing what they’re about to read to save them the trouble of going through the content only to find out what they’re looking for isn’t there.

Get Addicted to Blogging, Do a lot of Drafts, Have a lot of fun, and most importantly have a lot of heart