Tag Archives: quicktip

Trigger setInterval immediately

Its probably common knowledge that you can do this, but I didn’t know that you could. This is a great way to trigger a function at the beginning of a `setInterval`. As you might know `setInterval` triggers after the given millisecond. So what this does it that it triggers it self at the beginning and returns it self as a function to `setInterval`.

Password confirmation using Zend Form and Validators

A while back i needed a password confirmation field for my users. I looked and found this neat little snippet. I cant remember who created it originally so i cant give credits to the person but its quite easy to use. Just add this to your library and create a new validator object like this.

This would be in your form where you want to have password confirmation.

Force select in bash case statement

This is probably common knowledge but i keep forgetting it so. If you’ve ever wanted to force a user to select an option you might have have noticed that a user can select anything they want in a select statement. A way to get around this is by converting your options in a function and then use the *) to fire the same function again.

Alternative to MacPorts, homebrew

If you’ve ever needed a 3th party app like `wget` or anything like it you should probably take a look at homebrew. Its fast and slick and bound to git. It has all the great features we know from `apt` or `macports`. What more could we ask for?

Some of the things ive used it for the last couple of days is installing and playing with [nginx](http://nginx.org/) which is an awesome tiny webserver that has a brilliant json like syntax for vhosts.

Blogging from textmate using markdown

One amazing thing about textmate, is that it does so many incredible things! In the last couple of months ive been using a lot of [markdown](http://daringfireball.net/projects/markdown/). Its such an easy syntax and great for blogging. Textmate has this bundle build in.

Another thing that is already build in is this great blogging tool that’ll let you blog directly from textmate. Simply select the blog bundle with the preferred syntax, in my case `Blog-Markdown`. When you’ve written your blogpost simply hit ctrl + cmd + p and it’ll post to Blogger, WordPress, Drupal or any other platform that supports the `MetaWeblog API`.

Using a Wacom with multiple monitors

A quick tip for people with multiple monitors and a Wacom tablet. You can setup your function keys on the side of the tablet to switch the mapping area.

First you’ll need to go to System Preferences > Wacom Tablet > Tools > Grip Pen. Set your “Screen Area” to your first monitor.

Now go to Tools > Functions – and the Express Keys tab. Pick a key and select “Display Toggle”. Now try hitting your key. The cursor should now switch to your second monitor. You might need to hit the key twice to go to monitor 2, and once to go to monitor 1.

quick unix tips

tail

When debugging a site, i like to keep a terminal up with the apache error log and access log. This is great and all but having one window for each logfile is kind of a pain. But did you know that you can give it all those files you want and get one output? If you give it more than one file it’ll print an overview with a header displaying the filename.

[code]$ tail -f logs/access.log logs/error.log logs/mysql.queries.log[/code]

-f will keep tail open and update the output uppon new additions

grep

Grep is great when you want to find something specific. But did you know that you can search for a string in multiple files recursive? Say you want to find all files with a giving variable or string just do,

[code]$ grep -lr "string" .[/code]

-l gives you a filename with path
-r is recursive from path giving

Say you want to use a regex pattern you can do so by adding -e

Remember these tools all exists within Linux and Mac OS X!