Best Christmas Decoration Ever

Make sure to read story at bottom…

best-christmas-decoration-ever

Fantastic!

“Good news is that I truly out did myself this year with my Christmas  decorations.

The bad news is that I had to take him down after 2 days.

I had more people come screaming up to my house than ever. Great stories. But two things made me take it down.

First, the cops advised me that it would cause traffic accidents as they almost wrecked when they drove by.

Second, a 55 year old lady grabbed the 75 pound ladder almost killed herself putting it against my house and didn’t realize it was fake until she climbed to the top (she was not happy).

By the way, she was one of many people who attempted to do that.

My yard couldn’t take it either.

I have more than a few tire tracks where people literally drove up my yard.”

Apple to replace magsafe adapters even out-of-warranty

After doing some researching and finding videos showing how to re-solder the cable and stuff, I stumble upon this page:

http://support.apple.com/kb/TS1713?viewlocale=en_US

And thought it was worth a shot going to the apple store here in Pasadena. So I made an appointment and in about 15 minutes I got a new magsafe adapter at no cost.  🙂

Old MagSafe adapter

Here’s a shot of the new one:

New MagSafe Adatper

Redirecting to another page when Flash is not installed

For all you that need to redirect users to another page if they don’t have Flash installed and use swfobject, just drop this code and you’re good to go:

var playerVersion = swfobject.getFlashPlayerVersion(); // returns a JavaScript object
var majorVersion = playerVersion.major; // access the major, minor and release version numbers via their respective properties

if (majorVersion == 0)
{
 document.location = '/PAGE_THE_USER_SHOULD_BE_REDIRECTED_TO';
}

This should go just before:

swfobject.embedSWF("xmas/happy_christimas_2009.swf", "flashcontent", "100%", "100%", "10", false, flashvars, params, attributes);

Let me know if you have a different approach.

I have found this (http://pastie.org/433193 ) while searching for a solution to my problem, but it made more sense to rely on swfobject API since I was already using it to embed flash.

Solving Firefox 3.5.5 slow response and high CPU usage

Tonight I got fed up of Firefox 3.5.x eating up CPU cycles and not being responsive…. So I decided to google that to see what other have experienced and tried.

After uninstalling Flash (just to be sure as it seems it was not guilty this time 🙂 ), I tried looking for thing in the configuration.

You type in the URL address bar:  “about:config” (without quotes). Confirm that you’re going to be careful.

The setting I disabled (and didn’t even have to re-start to notice better response times was:

security.enable_java

It is now set to false, as I don’t care about java on my browser.

I do use Eclipse while programming, so Java is still installed on my computer.

Let me know if that helps you.

A base controller using Kohana v3.0.3

Here’s how I created a base controller for websites I develop using Kohana v3

1. create a website config file ( application/config/website.php ):

<?php defined('SYSPATH') OR die('No Direct Script Access');
return array( 'site_name' => 'Example site',);
<?php defined('SYSPATH') OR die('No Direct Script Access');
return array(
      'site_name'  => 'Example site',
);

2. Create a basic CSS file for your site ( html/template/default/css/style.css ):

body {
      font-size: 14px;
}

3. Create the website controller ( application/classes/controller/website.php ):

<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Website extends Controller_Template {
      public $template  = '';
      public $page_title  = '';
      public $site_name  = '';
      public $template_name  = '';
      public $styles  = array();
      public $scripts  = array();
      public function before()
      {
            $this->auto_render = false;
            parent::before();
            $this->auto_render = true;
            $this->template_name = 'default';
            $this->site_name = kohana::config('website.site_name');
            $this->styles = array(
            'template/' . $this->template_name . '/css/style.css' => 'screen',
      );
      $this->scripts = array(
            'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',
      );
      $this->template = View::factory('template/' . $this->template_name . '/default');
      if ($this->auto_render)
      {
            $this->template->bind('page_title', $this->page_title)
            ->bind('site_name', $this->site_name)
            ->bind('styles', $this->styles)
            ->bind('scripts', $this->scripts)
      ;
      }
      }
      public function action_index()
  {
  //$this->request->response = 'hello, world!';
  $this->template->content= '<!--Default website controller, you don't want to access this one-->';
  }
  public function after()
  {
  $this->template->bind('styles', $this->styles)
  ->bind('scripts', $this->scripts)
  ;
  parent::after();
  }
} // End Website

4. Create the template file ( application/views/template/default/default.php ):

<html>
  <head>
  <meta charset="utf-8" />
  <title><?php echo empty($page_name) ? '' : "$page_name - "; ?><?php echo empty($site_title) ? '' : $site_name; ?></title>
  <?php foreach ($styles as $file => $type) echo HTML::style($file, array('media' => $type)) . "n"; ?>
  <?php foreach ($scripts as $file) echo HTML::script($file) . "n"; ?>
  </head>
<body>
  <?php echo empty($content) ? '' : $content; ?>
</body>
</html>

Removing “index.php” from kohana v3 urls

Now that you have Kohana v3 installed, let’s remove “index.php” from all the URLs to help our SEO capabilities.
Rename the file “example.htaccess” to “.htaccess” or merge its contents if you already have one in place.
You should change the line:

RewriteBase /kohana

to point to the folder where your “index.php” file is.
Next file you will change is “application/bootstrap.php”.
You need to change the line:

Kohana::init(array('base_url' => '/kohana/'));

To:

Kohana::init(array(
    'base_url' => '/',
    'index_file' => '',
));

My “index.php” file is not on a “kohana” folder, so I changed both “RewriteBase” and “base_url” to “/”, as I am gonna user Kohana for all content (except static content).

Annoying advertisement

Sometimes ads are way too invasive… the one provided by this domain, for example:

http.tidaltv.com

I don’t mind ads… (most of the time at least)… but when they have audio going on and I’m listening to songs I like, then it’s get really annoying.

To prevent that, I did the following:

Edit the file <WINDOWS>system32driversetchosts and include the following lines:

127.0.0.1                clickfuse.com
127.0.0.1                l2.zedo.com
127.0.0.1                pubads.l2.doubleclick.net
127.0.0.1                www.ringtonematcher.com
127.0.0.1                www.mediataskmaster.com
127.0.0.1                http.tidaltv.com

You may reboot your computer for the changes to take effect, after saving the file. Or you can simple close your browsers.

By doing this, all domain names will resolve to the local IP address of your own computer (that in most cases will not be running a web server). If that the case, you don’t lose time nor bandwidth with ads.

Weird: FCK loses first line of formatted text when submitting

Last night (Oct, 28th), I was fixing a very weird problem where text edited using FCK, submitted via jQuery was losing the very first line when it was formatted (color, style) but not every single time… randomly it seemed.

At first, I thought it would be something wrong with FCK editor and checked if there was an updated version. I was using 2.5.x on my site and 2.6.5 is current in the 2.x series (and 3.0.1 was just released, note: checking that for another website [http://thirdgenerationco.com]).

Since I didn’t want to introduce new features (cause my client freaks out when I do without letting him know), I thought I’d give 2.6.5 a try. That did not solved my problem.

My next logical step was checking how jQuery was encoding the text to preserve quotes and double quotes and making sure PHP was getting that right. Which both were.

Next, I tried adding slashes and stripping them down, which also did not work.

At this point, I thought about changing my Ajax approach…..  but before that I’d though I’d give JSON a try.  🙂

So this is the changes I’ve made in my coding:

Javascript side (My text is edited inside a dialog window (created using jQuery-UI) and then posted using Ajax, from the main window.

var new_text = $('#frame_frontpage').contents().find('#previewMyStoreMessageBoard').html();
$("#previewFrontPageText").html(new_text);
$("#frontpage_text").val(new_text);
var str = $("#form_frontpage_text").serialize();
var This = this;
$.post('/member/store_home_page/ajax_save_frontpage_text', str,
$.post('/member/store_home_page/ajax_save_frontpage_text', {frontpage_text: new_text},
  function(text) {
    if (text == "success") {
    alert("Store Description Text submitted successfully.");
    $(This).dialog('close');
  } else {
    alert(text);
  }
}
);

Besides that I just added addslashes() and stripslashes() to preserve double quotes to/from the database.
And it’s now working 😀

Creating a content controller using Kohana v3.0

These are the things I needed to change on .httacess to have kohana default files working before creating my first controller:

 # Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /kohana/

# Protect hidden files from being viewed
<Files .*>
 Order Deny,Allow
 Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)b - [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

My Kohana v3 installation is not inside a folder, so I’m changing “/kohana/” to “/“.

I want to use my Content controller to show content for the front page and any other content pages read from the database, so I am doing the following changes to my /application/bootstrap file:

Route::set('default', '(<controller>(/<action>(/<id>)))')
 ->defaults(array(
 'controller' => 'content',
 'action'     => 'index',
 ));

Create the Content controller file /application/classes/controller/content.php

<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Content extends Controller {

 public function action_index()
 {
 $this->request->response = 'This is the content controller!';
 }

 public function action_view()
 {
 $this->request->response = 'This is the content controller [view action]!';
 }

} // End Welcome

Playing around with Kohana v3

New Kohana version is out, grab it from here:

http://dev.kohanaphp.com/projects/kohana3/files

And again, extract to a folder on your web server.

On good thing to do is extract both “Application” and “System” into a folder accessible to the user your webserver runs (usually, apache, nobody, httpd) and change the paths inside index.php

$application = '../application';
$modules = '../../../data/kohanav3/modules';
$system = '../../../data/kohanav3/system';

If you got the paths right on your environment, you should see a message saying your environment passes all requirements and you that you should remove the install.php file

kohanav3_environment_testsIt’s late here…. so this is all I’m gonna do for now.