My Science Is Better

23Sep/090

Google Chrome Frame IE Update released

After Google launched yesterday the Google Chrome Frame, a plugin that changes IE rendering engine (Trident) for WebKit, slicer@work created a nifty JavaScript that allows developers to present the plugin as an IE Update.

Although some of you might say this is not ethical as the user is being fooled, I DON'T GIVE A DAMN! I think it's a great idea to have as many people as possible have this plugin installed in order to GET RID OF IE!!

You can get the Google Chrome Frame IE Update and post comments on the authors site.

22Sep/093

How to update your Twitter status using Zend Framework

After reading the NetTuts tutorial on how to update your Twitter status using CodeIgniter, I wanted to show how to update your Twitter status using Zend Framework.

For this tutorial you need to install Zend Framework and Zend_Tool first.

Step 1: setup apache vhost by creating the /etc/apache2/sites-available/twitter as follows:

<VirtualHost *:80>

    ServerAdmin romeo.cioaba@spotonearth.com
    DocumentRoot /home/mimir/Zend/workspaces/DefaultWorkspace7/twitter
    ServerName twitter.dev
    ServerAlias www.twitter.dev
    ErrorLog /home/mimir/Zend/workspaces/DefaultWorkspace7/logs/twitter_error_log
    CustomLog /home/mimir/Zend/workspaces/DefaultWorkspace7/logs/twitter_access_log combined

    <Directory "/home/mimir/Zend/workspaces/DefaultWorkspace7/twitter/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
    </Directory>

</VirtualHost>

You will need to change the DocumentRoot and Directory directives to match your configuration.

Step 2: add twitter.dev to your hosts file:

127.0.0.1	twitter.dev www.twitter.dev

Step 3: create the Zend Framework project

# i switch to my Zend Studio workspace, where apache is reading his sites from:
# cd Zend/workspaces/DefaultWorkspace7/
zf create project twitter

Step 4: restart apache

sudo /etc/init.d/apache2 restart

At this point you should have a default Zend Framework project that you can browse at http://twitter.dev/public/. How let's change our status :)

Replace the content of IndexController with the following:

<?php
class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // we create the form
        $updateForm = new Zend_Form();

        $status = new Zend_Form_Element_Text('status');
        $status->setLabel('New Twitter Status')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty');

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Update');

        $updateForm->addElements(array($status, $submit));

        // we send the form to the view
        $this->view->updateForm = $updateForm;

        // we check if there was any POST
        if ($this->getRequest()->isPost()){
            $formData = $this->_request->getPost();
            // checking if the form data is valid (if we have a new status or not)
            if ($this->view->updateForm->isValid($formData)){
                // our form is valid, we can update our status
                $twitterStatus = $formData['status'];

                $twitter = new Zend_Service_Twitter('myusername', 'mypassword');
                $response = $twitter->status->update($twitterStatus);
            }
        }

    }

}

Also replace the view for the index action of IndexController with:


<h1>Welcome to the Twitter Update Tutorial</h1>

<?php echo $this->updateForm?>

TADA! You can now check your twitter account and see that twitter status is updated every time you submit the form -:)

22Sep/090

Install Zend Framework and Zend_Tool using PEAR on Ubuntu

I work every day with Zend Framework and the easiest way i find to install it is by using the PEAR packages offered by the betta channel ZF Campus

Here is what you have to do install Zend Framework and Zend_Tool using PEAR on Ubuntu:

sudo pear channel-discover pear.zfcampus.org
sudo pear install zfcampus/zf
# for some reason the installer does not correctly link the zf.php and Zend_Tool won't work
# so we need to setup a symlink
sudo ln -s /usr/share/php/zf.php /usr/bin/zf.php

That's it! You can now test your install:

zf show version

In my care the output was this one:

mimir@orion:~$ zf show version
Zend Framework Version: 1.9.2
7Sep/094

Magento export categories with id

A friend asked me to help out import some products and categories from an old database to a brand new magento install. What I first did was to construct a CSV file with all the categories from the old store (that was the easy part...) and import them to magento. I followed this thread and the import when smooth. Now I needed to get the ids that magento addigned to my categories so that I could import a product inside the categories so that my friend won't have to do it in backend.

First thing I did was to look on magento forums how to get all store categories. After finding this great thread, i came up with this little script which I put into my template folder in /catalog/allcategories.phtml:

$category = Mage::getModel ( 'catalog/category' );
$tree = $category->getTreeModel ();
$tree->load ();

$ids = $tree->getCollection ()->getAllIds ();

if ($ids) {
$fp = fopen('var/import/catwithid.csv', 'a');
fwrite($fp,  'catId, catName\n');
foreach ( $ids as $id ) {
                $string = $id . ', ' .$category->load($id)->getName() . '\n';
fwrite($fp,  $string);
}
fclose($fp);
}

As a note, you need to make sure that /var/import/catwithid.csv exists and it's writeable by your web server. You can make sure it is by chmod-ing it to 777

touch var/import/catwithid.csv # we create the file
chmod 777 var/import/catwithid.csv #make sure it's writeable

Since this was a dev install, I then just loaded that script into a block element by editing the Home Page inside the CMS section:

{{block type="core/template" template="catalog/allcategories.phtml"}}

Hope this helps someone :)

29Aug/090

Install GIMP 2.7 on Ubuntu

This tutorial will show you how to install GIMP 2.7 on Ubuntu Jaunty without affecting the default GIMP 2.6 install

sudo apt-get install ruby # needed by gegl
git clone git://git.gnome.org/babl
git clone git://git.gnome.org/gegl
cd babl
./autogen.sh
make
sudo make install
cd ../gegl
./autogen.sh
sudo make install
sudo apt-get install libjasper-dev # the jasper libs are required to provide JPEG2000 support in GIMP
cd ..
wget ftp://ftp.gimp.org/pub/gimp/v2.7/gimp-2.7.0.tar.bz2
tar jxvf gimp-2.7.0.tar.bz2
cd gimp-2.7.0
./configure --prefix=/opt/gimp-2.7
make
sudo make install

Now just create a file gimp-2.7 inside /usr/bin as follows:

#!/bin/sh

PATH=/opt/gimp-2.7/bin:$PATH
export PATH
LD_LIBRARY_PATH=/opt/gimp-2.7/lib
export LD_LIBRARY_PATH

/opt/gimp-2.7/bin/gimp-2.7 "$@"

Run /usr/bin/gimp-2.7 :)

Tagged as: , , No Comments
29Aug/090

Made the switch to wordpress

I've been using MovableType as the platform for my blog and i've been really happy with it. The reason i decided to switch to Wordpress is simply because it's written using PHP and i'm able to easily extend it, unlike MT which is built in perl.
I haven't got a change to import the comments so far, but hopefully i'll get to that this week.

Let me know if you find a broken link or something unusual.

Filed under: Uncategorized No Comments
24Mar/092

Zend Framework tutorials – RFC

After a talk on #zftalk I'm thinking to start witting a site that would allow the Zend Framework community to submit learning material.

The site is going to be called Zend Framework Tips

I have a few ideas of my own, but i want to hear more from you.

18Mar/090

Counting Crows Goes Label-Free

Counting Crows is joining Radiohead and Nine Inch Nails in the initiative to release music outside of the normal music industry (label/distributor).

Lead Singer Adam Duritz announces on the bands website:

The internet opens a world of limitless possibility, where the only
boundaries are the boundaries of your own imagination. We want a chance
to push those boundaries back as far as we can. Unfortunately, the
directions we want to go and the opportunities we want to pursue are
often things that our label is simply not allowed to do. We've been
friends for a long time and we've worked together for a long time so
they understand the direction we need to go in and we understand why
they can't always go there with us. We all want what's best for
everyone which is why we've decided to part ways.

Jono Bacon started the severed fifth project a while ago, which aim is to prove that a band can make it on it's own and i'm sure he will succeed.

Filed under: Uncategorized No Comments
14Mar/090

Bad memories…

Bad memories

This still brings back bad memories...

Thanks to Andrei for helping me with the text :P

You are free to use this in any way you want.

Filed under: comics No Comments
9Mar/090

Timed cycling of DOM elements using Javascript

I had the following sequence of code:

<ul id="parent">
    <li>test 1</li>
    <li>test 2</li>
    <li>test 3</li>
    <li>test 4</li>
    <li>test 5</li>
</ul>

What i wanted to achieve was to add the class "selected" to the childrens of #parent one at a time, having some delay in between. When then next element is selected, then the element before it should lose the selected class.

Based on the great work of cmarshall at http://www.webmasterworld.com/javascript/3449722.htm and adding a bit of jQuery i was able to build a page using jQuery that does that.

I didn't bother to put the all the code here, you can just view source in the demo. The code is pretty much commented so you shouldn't have any problem understanding it.

You can click here to see it in action.

Tagged as: No Comments

Tag Cloud

Categories

Archives

Akismet

Blogroll

Ads