Archive

Archive for August, 2011

Lion annoyance #1 – Ability to label desktop

August 18, 2011 Leave a comment

This is by far the biggest disappointment I have towards Lion – I simply can’t find a single solution to bring back the desktop labels. I can work around by assigning different wallpapers to different desktops but it’s still not as convenient as having the desktop numbers shown on the task bar.

Advertisements
Categories: lion, mac osx

Something to watch out while using ‘%’ in crontab

August 12, 2011 1 comment

% is a special character in crontab and it has to be escaped with another ‘%’ a ‘\’. I just found out through a fail-to-run crontab task:

Non-working version:

1 5 * * *       /bin/bash /path/to/myscript.sh `date +%Y%m%d -d '5 days ago'`

When a crontab fails it will drop an email to user’s mailbox. So here are the relavant lines I found in the mailbox (via command mail):

/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file

With those error messages I googled a bit and changed the crontab to the following
working version:
1 5 * * * /bin/bash /path/to/myscript.sh `date +%%Y%%m%%d -d ‘5 days ago’`

1 5 * * *       /bin/bash /path/to/myscript.sh `date +\%Y\%m\%d -d '5 days ago'`
Categories: linux, Tip

Attach targeted window using tmux

August 5, 2011 Leave a comment

In tmux sometimes we might need to attach a session with the specific window selected so that we can start working without additional switching window steps. I just found one of the ways to accomplish this is:

tmux select-window -t sess:win && tmux attach -t sess

Credit goes to http://tofu.org/drupal/node/183 [ lines 78 & 79 ]

Categories: Tip, tmux

Fixing Tunnelblick (3.1.7) kernel panic problem in Lion

August 3, 2011 Leave a comment

The currently stable version (3.1.7) of Tunnelblick would cause a kernel panic in Mac Lion while a connection is being made. Workaround is to use a beta version (3.2beta28) which is available at http://code.google.com/p/tunnelblick/downloads/detail?name=Tunnelblick_3.2beta28.dmg, released 7/31/2011.

[Edit 8/18/2011] Just updated Lion to 10.7.1 last night and version 3.2beta28 seems to be unstable as well. It has caused kernel panic two times in a row. Need to keep looking for a version that works. Did a re-installation of the same version and it works afterwards.

Passing array of checkbox values to php through jQuery (example)

August 2, 2011 7 comments

input.html

<!DOCTYPE html> 
<html> 
<head> 
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript">
                function doit() {
                        var p=[];
                        $('input.cb').each( function() {
                                if($(this).attr('checked')) {
                                        p.push($(this).attr('rel'));
                                }
                        } );
                        $.ajax( {
                                url:'/process.php',
                                type:'POST',
                                data: {list:p},
                                success: function(res) {
                                        alert(res);
                                }
                        });
                }
        </script>
</head>
<body>
        <input type="checkbox" class="cb" rel="1"></input>This is 1<br />
        <input type="checkbox" class="cb" rel="abc"></input>This is abc<br />
        <input type="checkbox" class="cb" rel="999"></input>This is 999<br />
        <a href="javascript:void(0)" onclick="doit()">Click</a>
</body>
</html>

process.php

<?php
        print_r(@$_POST['list']);

Test-run screenshot:

Live demo (Using google app engine therefore output is slightly different to the screenshot above. The relevant code that deals with the post request is as follow:

class Chkbox(webapp.RequestHandler):
    def get(self):
        ...

    def post(self):
        d=self.request.get_all( 'list[]' )
        self.response.out.write(d)

)

Categories: html, jQuery, php