Updates from December, 2009 Toggle Comment Threads | Keyboard Shortcuts

  • levin 1:04 pm on December 18, 2009 Permalink | Reply
    Tags:   

    WordPress Howto retrieve top parent category ID from the post 

    Add the following code in your theme functions.php

    function is_parent_category($cats, $_post = null)
    {
    	foreach ((array) $cats as $cat)
    	{
    		$descendants = get_term_children((int) $cat, "category");
    		if ($descendants && in_category($descendants, $_post))
    			return true;
    	}
    	return false;
    }
    
    ?>
    
    Usage:
    if (is_parent_category(1)) // Got true/false if parent category is 1
    {
    //Do something
    }
    
     
  • levin 4:20 pm on December 11, 2009 Permalink | Reply
    Tags: jQuery   

    Resolving jQuery conflicts 

    I’m a newbie on jQuery… when i integrate tons good wordpress plugin, it’s always a nightmare because there is always had var conflicts, so there have a function call jQuery.noConflict(); for solving such kind of conflicts, you just modify the control script to jQuery(foo) instead of $(foo), cool?
    (More …)

     
    • levin 12:16 pm on December 18, 2009 Permalink | Reply

      a better method is declare a distinguish var in jQuery.noConflict

      var $myjQ = jQuery.noConflict();

  • levin 6:44 pm on December 2, 2009 Permalink | Reply
    Tags: nextgen   

    NextGEN Gallery i18n gallary tags issue 

    I found that “nggtags gallary=” not yet support i18n tags, however “nggtags ablum=” did, is it include in future release or current version have bug? i don’t know…

    And then i tried to fix it using following mod.

    (More …)

     
  • levin 7:49 pm on March 27, 2009 Permalink | Reply
    Tags: horde,   

    horde/imp display gb2312 character interim solution 

    While too many gb2312 character in horde cannot converted as UTF-8, to give it a quick workaround, I’d just enforce horde to treat gb2312 encoding to gbk which is more compatible for chinese double-byte character.

    Replace the lines in lib/Horde/String.php from

    if (!$output && String::extensionExists(‘mbstring’)) {
    $output = @mb_convert_encoding($input , $to, $from);
    }

    to

    if (!$output && String::extensionExists(‘mbstring’)) {
    if ($from == ‘gb2312′) {
    $from = ‘GBK,GB2312′;
    }
    $output = @mb_convert_encoding($input , $to, $from);
    }

     
  • levin 2:19 pm on March 10, 2008 Permalink | Reply
    Tags:   

    MS-DOS executable (COM) file is actually chinese email 

    #>file mytest.txt

    mytest.txt: DOS executable (COM)

    reported a chinese email message as a DOS executable file

    Workaround:

    Comment out the line in /usr/share/file/magic

    #0      byte            0xe9            DOS executable (COM)
    #>0x1FE leshort         0xAA55          \b, boot code
    #>6     string          SFX\ of\ LHarc  (%s)

    and then rebuild it

    #> rm /usr/share/file/magic.mgc

    #> cd /usr/share/file/

    #> file -C magic

    Test it again.

    #> file mytest.txt

    mytest.txt: UTF-8 Unicode mail text
    Ref: https://bugzilla.redhat.com/show_bug.cgi?id=214718

     
  • levin 1:11 am on April 3, 2007 Permalink | Reply
    Tags: , , sophos   

    useful sophos scripts 

    When you brought a “Enterprise Product”…….. how come there has no automation tools solve your panic…… they give you the binary, “services?”… but nothing provide to you… why you still buy it…….

    (More …)

     
  • levin 11:10 am on July 20, 2006 Permalink | Reply
    Tags: ,   

    Perl smtp mailer script 

    If your server doesn’t have SMTP or maybe you have sendmail relay problem, also if you’re reporting the problem about mail service. This script allow you send out your message through SMTP insead local sendmail.

    Script Usage:

    echo “Hello! Perl script” | /path/to/mailer.sh “Subject” “Receiver_Name_1″ “Receiver_address_1″ “Receiver_Name_2″ “Receiver_address_2″
    <script> | /path/to/mailer.sh “Subject” “Receiver_Name_1″ “Receiver_address_1″ “Receiver_Name_2″ “Receiver_address_2″
    (More …)

     
  • levin 2:03 pm on July 17, 2006 Permalink | Reply
    Tags: ,   

    addusers in shell script 

    Add a user one by one.

    #!/bin/bash
    usage=”Usage: Enter password and username – addusers.sh username password group comment homedir shell ”
    sample=”Example: ./addusers.sh myname mypassword group1 ‘My Name’ /home/myname /bin/bash”
    (More …)

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel