[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 () {
this.counter++;
console.log(this.counter);
};
}

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


Super Tool: (Probably) the best SQLite Editor/IDE for web development and production use

| No Comments »

I really love SQLite. It’s lightweight and got a really small footprint. I use it as my database initially when i’m creating web applications(I then move to mySQL during production), the only issue I have is the lack of IDE for working with it. Of course there’s SQLite Administrator, i’m just not into the idea of installing a software especially with SQLite being small(I prefer not to cramp up as much software possible in my Windows).

This is where sqlite-manager comes along. It’s a 100kb plugin for Firefox(which also means cross compatibility with other OS), it’s a great complement to SQLite’s lightweight and small footprint. If you need to work with the database, you simply fire up sqlite-manager from the Tools menu.

That’s It!