Business card that shoots pennies

Saw this on digg, thought this was pretty cool.
http://www.buzzfeed.com/nikoguy1/penny-shooter-business-card-5xy

CakePHP 1.2: Passing an absolute path to $this->render

Lets say you’re inside an action in /app/plugins/plugin/controllers/my_controller.php and you want to render /app/plugins/plugin_2/views/form.ctp. You would probably do something along the lines of:

function action() {
  //Do some things here
  $this->render(APP . "plugins/plugin_2/views/form.ctp");
}

That will not work, unfortunately. It will try and render /app/plugins/plugin/plugins/plugin_2/views/form.ctp. So, how can you do this? Lets take a look at the $this->render function:

$this->render(string $action, string $layout, string $file);

Note the $file parameter. This is what we want. A quick look through the CakePHP code revealed that if you pass false for the $action parameter, CakePHP will try and use $file instead. Passing null as the layout parameter will use the default layout.

$this->render(false, null, APP . "views/file.ctp");

Or perhaps if you need to render a view file of a plugin?

$this->render(false, null, APP . "plugins/plugin_name/views/file.ctp");

The APP constant holds the absolute path to your CakePHP project’s app directory.

Checking if an element exists with jQuery

There isn’t too much I can really write about this, so I’m just going to get straight to the point. To check if an element exists, with jQuery, you do this:

if ($('element').length == 0) {
  //Element does not exist
} else {
  //Element exists
}

Or you can just do:

if ($('element').length) {
  //Element exists
}

Fairly simple. If you wanted to do it with regular javascript, you would just do:

if(document.getElementById('element_id')) {
  //Element exists
}

“Major” atomiku.com update

So I’ve finally decided to completely switch atomiku.com over to wordpress. The crappy CMS I had built for atomiku.com’s purpose 2 years ago was just too… crap. Wordpress is a really nice CMS. I think I’m going to have a lot of fun with this.

A few things I still need to do, though. One of the things is to *finally* get atoChat v0.7 finished. Another is to write more interesting things, like web development tutorials, tips, etc. This is something I’ll be doing soon, hopefully.

Anyways, yeah. Enjoy the new website. Or, don’t.

Also: Follow me on twitter! http://twitter.com/atomiku

atoChat v0.7 Updates

Hey hey! Just to let you know atoChat is going pretty well and that I HAVE been working on it, I promise!

A few things added to atoChat v0.7:

  • All the ajax calls are much more stable now, it uses jquery
  • Color picker added instead of dropdown menu
  • Help screen updated, looks much better now
  • /roll command added, will make the bot roll a dice then output what it landed on.
  • /fact command added, has the bot fetch a random fact then output it to the channel
  • Added a send button
  • A large portion of atoChat has been fully recoded, much more efficient now
  • Helpup popup has been replaced with new on-screen “popup”
  • All admin commands removed, admins can now kick/ban/etc through an interface shown on-screen
  • Messages you send are now shown instantly, instead of waiting for your message to come back from the server
  • When you enter the chat, the chat is loaded instantly. There was a major lag in v0.5
  • No more using /register, you can now register through an interface

There are many more things changed/added to v0.7, but perhaps I’ll let them be a surprise :)

The benefits of Google Analytics

In an attempt to write more interesting things for atomiku.com, I’m going to write a little bit about Google Analytics today. If you already use Google Analytics on your website then stop reading now, I’m only going to be going through the basics.

So, what is Google Analytics? It’s an amazing web application that allows you to see the performance of your website. It saves down all sorts of information such as what browsers your visitors are using, where they came from, what keywords they used to find your site on google, what screen resolution they’re using and all sorts of other interesting and important information. Although, I’m not going to go through it all because it would take absolutely ages.

I recommend Google Analytics to anyone who runs a website and is interested in what is going on with their visitors. To get Google Analytics installed and working on your website, the first step would be to go to http://www.google.com/analytics/. If you already have a google account (Which you WILL have if you use GMail) you can click “Access Analytics” and login as normal. If you don’t have a google account, click “Sign Up Now” and get yourself registered.

Once you’re logged into Google Analytics, you should be given a sign up page if you’ve never used it before. Click the sign up button and get the form filled in. Once you’re all done, you will be given a block of javascript code to put at the top of your website, in the <head> tags. Get that put in and you’re all ready to go! You’ll have to give the analytics data some time to update, it appears to be updated daily so you may have to wait till the next day to see anything interesting.

Well, hopefully I’ve covered everything. Do leave me a comment if you found this helpful, or if you need more help. Thanks, and enjoy! :)

50 Great Icon Sets

On my travels through the vast and endless sack of shit, the internet, I found a great blog post over at speckyboy.com – “50 of the Best Ever Web Development, Design and Application Icon Sets

I had only really been aware of FamFamFam’s Silk icons, but the icon sets mentioned in speckyboy.com’s blog post are pretty darn good. I will list two of the icon sets from the blog post I really liked, if you want the full list, check out their post.

Xiao Icon Set

Weby Icons

Excellent stuff. I’ll sure be using these lovely icons where nessessary in future projects!

Why I don’t have a girlfriend

Chance I’ll spill coffee on myself

Foobar2000 media keys

Having a problem with your media keys only working when the Foobar2000 window is active? I had the same problem, too. Here is an easy way to get them working properly:

File -> Preferences -> General (In the tree on the left) -> Keyboard Shortcuts

Click the “Add New” button in the “Assigned shortcuts” frame, then click inside the input/textbox, located in the “Key” frame. Press your “Play” media key. Check “Global Hotkey”. Then, in the treeview which contains all the actions (Such as Clear, Redo, Remove Dead Items, etc) find then select “Play”. Repeat this step for the rest of the media keys you have.

Below shows rougly what your preferences window should look like:

No idea why foobar2000 doesn’t do this by default, perhaps maybe to stop conflicts with other applications that want to use multimedia keys?

If you have any trouble following this tutorial, do not hesitate to leave a comment and I will get back to you soon as possible :)




Search engine optimization by SEO Design Solutions