An Error Occurred During The Signature Verification

November 25th, 2008

If you’re using ubuntu as your choice of linux distribution, and you like to add some unofficial repositories, you probably find some warnings when you run apt-get update command.

The warnings are probably like this

W: A error occurred during the signature verification. The repository is not updated and the previous index files will be used.GPG error: http://dl.google.com stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A040830F7FAC5991
 
W: Failed to fetch http://dl.google.com/linux/deb/dists/stable/Release  
 
W: Some index files failed to download, they have been ignored, or old ones used instead.
W: You may want to run apt-get update to correct these problems

That’s the warnings I got when I added google debian repository. There won’t be anything bad about it, since we could still install the packages from that repositories. But, I we could get rid the warnings, that’s would be a lot better. We could use gpg command to get the key.

Short Version

For you who don’t want to read pointless explanations below, here’s the short version

gpg --keyserver hkp://subkeys.pgp.net --recv-keys A040830F7FAC5991
gpg --export --armor 7FAC5991 | sudo apt-key add -

Long Version

Here’s the explained step. First we have to get the key from the key server.

gpg --keyserver hkp://subkeys.pgp.net --recv-keys A040830F7FAC5991

The A040830F7FAC5991 is from the warning shown before. You might want to change it if you have different repository. For the google repository, you should get this as the output

gpg: requesting key 7FAC5991 from hkp server subkeys.pgp.net
gpg: key 7FAC5991: public key "Google, Inc. Linux Package Signing Key <linux-packages-keymaster@google.com>" imported
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: Total number processed: 1
gpg:               imported: 1

After that, type

gpg --export --armor 7FAC5991 | sudo apt-key add -

Where the 7FAC5991 is from the output shown before.

After that you’ll get OK as the output. You may run apt-get update again.

Oh, one more thing, I only tested this method in opera and google repositories :)

CodeIgniter and Ajax Using JQuery Tutorial

May 27th, 2008

I created this tutorial because I was having a hard time finding good simple CodeIgniter + JQuery tutorial for newbie like me. The one I found, created by MR Forbes, is hard to understand and apparently isn’t working. Another one, pr0digy’s, is using Mootools for the AJAX framework.

So I decided to create my own CodeIgniter and JQuery tutorial based on pr0digy’s tutorial. I’m assuming you already know how to code using CodeIgniter. If you’re new to CodeIgniter, you need to find others tutorial first. The videos given in CodeIgniter’s site is a good start.

This tutorial is about creating simple CodeIgniter + database + ajax system. User will be shown a form to post a message. Then after he/she press the submit button, the system will save the message using ajax and then show the message. You could see the result first if you want.

Database

The first thing we need to do is creating a table to save the message. For this tutorial, We will use this:

1
2
3
4
5
CREATE TABLE IF NOT EXISTS `messages` (
  `id` tinyint(4) NOT NULL AUTO_INCREMENT,
  `message` varchar(256) NOT NULL,
  PRIMARY KEY  (`id`)
)

Controller

Then, we need to create a controller. My controller is named message. You could name your controller any name you like. After that, create 2 functions/methods, view and add.

view is used to get the default view and list of messages from the database. The codes are:

1
2
3
4
5
6
7
8
9
10
function view($type = NULL)
{
    // get data from database
    $data['messages'] = $this->Message_model->get();
 
    if ($type == "ajax") // load inline view for call from ajax
        $this->load->view('messages_list', $data);
    else // load the default view
        $this->load->view('default', $data);
}

We fetch messages from the database using Message_model->get() function. Then the data is passed to the view. Here, we have 2 views called. One for the default view, where we called the page using message/view, and the other is for calling from ajax.

add is a proccess used to insert the message to the database. The codes are:

1
2
3
4
5
6
7
8
9
function add()
{
    // if HTTP POST is sent, add the data to database
    if($_POST && $_POST['message'] != NULL) {
        $message['message'] = $_POST['message'];
        $this->Message_model->add($message);
    } else
        redirect('message/view');
}

This function is accessed when we press the submit button from the form. This function will save the message using Message_model->add() function.

Model

The next thing we need to create is the model. I use Message_model for the name. Here we create two functions, add and get. add is a function to insert the data into the database. get is a function to retrieve data from database. I think the codes are pretty self-explainatory, but you could drop me a message if you need some explainations on the codes.

1
2
3
4
function add($data)
{
    $this->db->insert('messages', $data);
}
1
2
3
4
5
6
7
function get($limit=5, $offset=0)
{
    $this->db->orderby('id', 'DESC');
    $this->db->limit($limit, $offset);
 
    return $this->db->get('messages')->result();
}

View

I use 2 files for view section. default.php and message_list.php. The message_list is used for displaying the messages taken from the database.

1
2
3
4
5
6
7
8
<div id="form">
    <input type="text" id="message" name="message" />
    <input type="submit" id="submit" name="submit" value="submit" />
</div>
<div id="content">
<?php $this->load->view('messages_list') ?>
 
</div>
1
2
3
4
5
<ol>
<?php foreach ($messages as $message): ?>
    <li><?= $message->message ?></li>
<?php endforeach ?>
</ol>

Hey, Where’s the JQuery?

Here we go. The last, and maybe the most important part of this tutorial. So, we the our controller, we had the model, and we had the views. I assume you already know how to include a jquery script to your view. The jquery codes are this:

1
2
3
4
5
6
7
8
9
10
11
$(document).ready(function() {
    $('#submit').click(function() {
 
        var msg = $('#message').val();
 
        $.post("<?= site_url('message/add') ?>", {message: msg}, function() {
            $('#content').load("<?= site_url('message/view/ajax') ?>");
            $('#message').val('');
        });
    });
});

So, when we click the submit button, the javascript will take the value of input textbox then send it to message/add using post method. When the action succeed, the script will call message/view/ajax. Note the ajax keyword. It will call the message_list view instead of the default one. Then the view will replace the content in div#content tag.

Well done. You could see the demo I made from the tutorial.

You could download the whole files used in this tutorial in tutorial.zip (1.98 KB).

Or, if you prefer to get one by one,
controller: message (904 bytes)
model: message model (583 bytes)
view: default (782 bytes)
view: message_list (111 bytes)

I hope this tutorial helps newbie like me. If you have any question, just drop a comment below ;)